elasticsearch
文書の過去の版を表示しています。
elasticsearch
Luceneをベースにした全文検索エンジン。
インストール
macOS
brew install elasticsearch
日本語形態素解析エンジンkuromoriを使う
インストール
プラグインとして提供されている
/usr/local/Cellar/elasticsearch/5.6.3/bin/elasticsearch-plugin install analysis-kuromoji
curl -XPOST http://localhost:9200/_analyze --data '{"tokenizer":"kuromoji_tokenizer","text": "オープンソースの全文検索エ ンジン"}' 2>/dev/null | jq . { "tokens": [ { "token": "オープン", "start_offset": 0, "end_offset": 4, "type": "word", "position": 0 }, { "token": "ソース", "start_offset": 4, "end_offset": 7, "type": "word", "position": 1 }, { "token": "の", "start_offset": 7, "end_offset": 8, "type": "word", "position": 2 }, { "token": "全文", "start_offset": 8, "end_offset": 10, "type": "word", "position": 3 }, { "token": "検索", "start_offset": 10, "end_offset": 12, "type": "word", "position": 4 }, { "token": "エンジン", "start_offset": 12, "end_offset": 16, "type": "word", "position": 5 } ] }
ユーザ辞書を使う
辞書なしの場合
curl -XPOST http://localhost:9200/_analyze --data '{"tokenizer":"kuromoji_tokenizer","text": "にゃんにゃんわんわん"}' 2>/dev/null | jq . { "tokens": [ { "token": "に", "start_offset": 0, "end_offset": 1, "type": "word", "position": 0 }, { "token": "ゃんにゃんわんわん", "start_offset": 1, "end_offset": 10, "type": "word", "position": 1 } ] }
辞書ありの場合
text.txtを作成し、/usr/local/etc/elasticsearch/ に設置
にゃん,にゃん,ニャン,名詞 わん,わん,ワン,名詞
curl -XPOST http://localhost:9200/_analyze --data '{"tokenizer":{"type":"kuromoji_tokenizer","user_dictionary": "test.txt"},"text": "にゃんにゃんわんわん"}' 2>/dev/null | jq . { "tokens": [ { "token": "にゃん", "start_offset": 0, "end_offset": 3, "type": "word", "position": 0 }, { "token": "にゃん", "start_offset": 3, "end_offset": 6, "type": "word", "position": 1 }, { "token": "わん", "start_offset": 6, "end_offset": 8, "type": "word", "position": 2 }, { "token": "わん", "start_offset": 8, "end_offset": 10, "type": "word", "position": 3 } ] }
elasticsearch.1508834014.txt.gz · 最終更新: 2017/10/24 08:33 by nullpon