elasticsearch 同义词配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elasticsearch 同义词配置相关的知识,希望对你有一定的参考价值。
在elasticsearch-2.3.1/config目录下面,存放synonyms.txt
curl -XPOST ‘http://localhost:9200/sy‘ -d ‘{
"analysis": {
"analyzer":{
"mysynonym":{
"type": "custom",
"tokenizer":"ik_smart",
"filter":[
"local_synonym"
]
}
},
"filter":{
"local_synonym":{
"expand":true,
"ignore_case":true,
"type":"synonym",
"synonyms_path":"synonym.txt"
}
}
}
}‘
curl -XPOST ‘http://localhost:9200/sy/sy/_mapping‘ -d ‘{
"sy":{
"_all":{
"search_analyzer":"ik_smart",
"analyzer":"mysynonym"
},
"properties":{
"name":{
"type":"string"
},
"title":{
"type":"string"
},
"number":{
"type": "long"
}
}
}
}
}‘
curl -XPOST http://127.0.0.1:9200/sy/sy/1?pretty -d‘
{"name":"番茄" , "title" : "FQtitle" , "number" : 10000}
‘
curl -XPOST http://127.0.0.1:9200/sy/sy/2?pretty -d‘
{"name":"西红柿" , "title" : "XHStitle" , "number" : 20000}
‘
curl -XPOST http://127.0.0.1:9200/sy/sy/3?pretty -d‘
{"name":"圣女果" , "title" : "SVGtitle" , "number" : 30000}
‘
curl -XGET ‘http://10.2.19.172:9200/sy/sy/_search?pretty‘ -d ‘{
"from" : 0,
"size" : 2,
"query": {
"bool" : {
"must" : {
"query_string" : {
"query" : "圣女果"
}
}
}
}
}‘
以上是关于elasticsearch 同义词配置的主要内容,如果未能解决你的问题,请参考以下文章
[大数据]-Logstash-5.3.1的安装导入数据到Elasticsearch5.3.1并配置同义词过滤