在下面的示例中,它已在es 2.3和1.7上调用。
刚开始我安装了插件:https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-stempel.html#analysis-stempel
接下来我的步骤是检查正确安装的插件: 结果在我的屏幕上:
Installed plugins in /home/adam/Desktop/elasticsearch-2.3.0/plugins:
- analysis-stempel
- marvel-agent
- license
接下来我添加了博客的映射:
curl -XPUT localhost:9200/my_index -d '{
"mappings": {
"blog": {
"properties": {
"title": {
"type": "string",
"fields": {
"polish": {
"type": "string",
"analyzer": "polish"
}
}
}
}
}
}
}
'
然后我添加了文件:
curl -XPUT localhost:9200/my_index/blog/1 -d
'{ "title": "Bardzo kocham zółwie"}'
我用的时候:
curl -XGET localhost:9200/_search -d
'{
"query": {
"multi_match": {
"type": "most_fields",
"query": "zółwie",
"fields": [ "title", "title.polish" ]
}
}
}
'
Elasticsearch返回正确的结果但是如果我把:
curl -XGET localhost:9200/_search -d
'{
"query": {
"multi_match": {
"type": "most_fields",
"query": "zolwie",
"fields": [ "title", "title.polish" ]
}
}
}'
Elasticsearch没有任何回报。
问题在于抛光特殊字符。
答案 0 :(得分:0)
第二个查询所需的是asciifolding
token filter。我建议使用以下映射,以涵盖更多用例:
{
"settings": {
"analysis": {
"analyzer": {
"folding": {
"tokenizer": "standard",
"filter": [
"lowercase",
"asciifolding"
]
}
}
}
},
"mappings": {
"blog": {
"properties": {
"title": {
"type": "string",
"fields": {
"folding": {
"type": "string",
"analyzer": "folding"
},
"polish": {
"type": "string",
"analyzer": "polish"
}
}
}
}
}
}
}
这个查询:
{
"query": {
"multi_match": {
"type": "most_fields",
"query": "zolwie",
"fields": [
"title.*"
]
}
}
}