DRYな備忘録

Don't Repeat Yourself.

Elasticsearchとはなにか的なメモ

Elasticsearchとはなにか的な

  • 全文検索エンジン
    • エンジンってなんやねん
    • InnoDBとかと同じレイヤのことば?
  • ストレージを持ってて、インデックスを定義できて、httpなAPIを持ってて、jsonなクエリで叩けるんだとさ

どうやって使うの的な

  • インストールする
  • 起動する
    • デフォでバックグラウンド起動っぽい。もち、フォアグラウンドで立てることもできる
  • 叩く
    • httpなAPIを提供するサーバが起動してるので、そこをcurlなりで叩く
  • ラッパーなど

インストールのメモ (MacOSX)

% brew search elasticsearch
elasticsearch
% brew install elasticsearch
elasticsearch: Java 1.7 is required to install this formula.

You can install Java from:
  http://www.oracle.com/technetwork/java/javase/downloads/index.html

Make sure you install both the JRE and JDK.
Error: An unsatisfied requirement failed this build.

言われた通り、Java SE - Downloads | Oracle Technology Network | Oracleここ行ってJavaを最新版にする

% brew install elasticsearch
==> Downloading https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.2.tar.gz
######################################################################## 100.0%
==> Caveats
Data:    /usr/local/var/elasticsearch/elasticsearch_otiai10/
Logs:    /usr/local/var/log/elasticsearch/elasticsearch_otiai10.log
Plugins: /usr/local/var/lib/elasticsearch/plugins/

To have launchd start elasticsearch at login:
    ln -sfv /usr/local/opt/elasticsearch/*.plist ~/Library/LaunchAgents
Then to load elasticsearch now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
Or, if you don't want/need launchctl, you can just run:
    elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml
==> Summary
🍺  /usr/local/Cellar/elasticsearch/1.4.2: 35 files, 29M, built in 15 seconds

launchは明示的でいいので、plistべつにほげほげしない。

% elasticsearch -h
Usage: /usr/local/bin/elasticsearch [-d] [-h] [-p pidfile]

ウッ、ぜんぜんヘルプしてくれない

まあ言われた通り

% elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml

Elasticsearch クイックスタート — Hello! Elasticsearch. — Medium

http用のデフォルトポートは9200らしい

別端末から

% curl :9200
{
  "status" : 200,
  "name" : "Orbit",
  "cluster_name" : "elasticsearch_otiai10",
  "version" : {
    "number" : "1.4.2",
    "build_hash" : "927caff6f05403e936c20bf4529f144f0c89fd8c",
    "build_timestamp" : "2014-12-16T14:11:12Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.2"
  },
  "tagline" : "You Know, for Search"
}

なるほど動いてる

参考になるかもしれない

高速スケーラブル検索エンジン ElasticSearch Server (アスキー書籍)

高速スケーラブル検索エンジン ElasticSearch Server (アスキー書籍)

Apache Solr入門 ―オープンソース全文検索エンジン

Apache Solr入門 ―オープンソース全文検索エンジン