bin/elasticsearch
Un plug-in indispensable pour la recherche élastique
bin/plugin install mobz/elasticsearch-head
Plugin qui analyse la morphologie
bin/plugin install elasticsearch/elasticsearch-analysis-kuromoji/2.5.0
Si cela pose problème (relancez la recherche élastique)
config/elasticsearch.yml
index.analysis.analyzer.default.type: custom
index.analysis.analyzer.default.tokenizer: kuromoji_tokenizer
Si vous définissez par index
curl -XPUT http://localhost:9200/index1/ -d '
{
"index": {
"analysis": {
"tokenizer": {
"kuromoji": {
"type": "kuromoji_tokenizer"
}
},
"analyzer": {
"analyzer": {
"type": "custom",
"tokenizer":"kuromoji"
}
}
}
}
}'
Vérifier l'analyseur
curl -XPOST http://localhost:9200/index1/_analyze?analyzer=analyzer&petty -d 'c'est un stylo'
{
"tokens": [
{
"token": "cette",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 1
},
{
"token": "Est",
"start_offset": 2,
"end_offset": 3,
"type": "word",
"position": 2
},
{
"token": "stylo",
"start_offset": 3,
"end_offset": 5,
"type": "word",
"position": 3
},
{
"token": "est",
"start_offset": 5,
"end_offset": 7,
"type": "word",
"position": 4
}
]
}
Umm. Il semble que cela fonctionne correctement.
Enregistrement d'échantillon 1
curl -XPUT http://localhost:9200/index1/type1/1 -d '{"text":"C'est du pain"}'
Enregistrement de l'échantillon 2
curl -XPUT http://localhost:9200/index1/type1/2 -d '{"text":"c'est un stylo"}'
Chercher!
curl -XGET http://localhost:9200/index1/type1/_search -d '{"query": {"match": {"text": "stylo"}}}'
{
"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": "c'est un stylo"
}
}
]
}
}
$ pip install elasticsearch
Recommended Posts