bin/elasticsearch
A must-have plugin for elasticsearch
bin/plugin install mobz/elasticsearch-head
Plugin that analyzes morphological elements
bin/plugin install elasticsearch/elasticsearch-analysis-kuromoji/2.5.0
If it is troublesome (restart elasticsearch)
config/elasticsearch.yml
index.analysis.analyzer.default.type: custom
index.analysis.analyzer.default.tokenizer: kuromoji_tokenizer
If you set by index
curl -XPUT http://localhost:9200/index1/ -d '
{
"index": {
"analysis": {
"tokenizer": {
"kuromoji": {
"type": "kuromoji_tokenizer"
}
},
"analyzer": {
"analyzer": {
"type": "custom",
"tokenizer":"kuromoji"
}
}
}
}
}'
Check analyzer
curl -XPOST http://localhost:9200/index1/_analyze?analyzer=analyzer&petty -d 'this is a pen'
{
"tokens": [
{
"token": "this",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 1
},
{
"token": "Is",
"start_offset": 2,
"end_offset": 3,
"type": "word",
"position": 2
},
{
"token": "pen",
"start_offset": 3,
"end_offset": 5,
"type": "word",
"position": 3
},
{
"token": "is",
"start_offset": 5,
"end_offset": 7,
"type": "word",
"position": 4
}
]
}
Umm. It looks like it's working properly.
Sample registration 1
curl -XPUT http://localhost:9200/index1/type1/1 -d '{"text":"This is bread"}'
Sample registration 2
curl -XPUT http://localhost:9200/index1/type1/2 -d '{"text":"this is a pen"}'
Search!
curl -XGET http://localhost:9200/index1/type1/_search -d '{"query": {"match": {"text": "pen"}}}'
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.15342641,
"hits": [
{
"_index": "index1",
"_type": "type1",
"_id": "2",
"_score": 0.15342641,
"_source": {
"text": "this is a pen"
}
}
]
}
}
$ pip install elasticsearch
Recommended Posts