一个好的开始是使用elasticsearch的索引模板文档: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
您的方案可以用于标题字段的示例:
"custom_template" : { "order" : 1, "template" : "doo*", "settings" : { "index" : { "analysis" : { "analyzer" : { "myCustomAnalyzer" : { "filter" : [ "standard", "lowercase", "asciifolding" ], "tokenizer" : "standard" } } }, "refresh_interval" : "5s" } }, "mappings" : { "your_type": { "properties": { "title": { "type": "text", "analyzer": "myCustomAnalyzer" } } } }, "aliases" : { } }
另一种方法是更改动态映射。你可以在这里找到一个很好的例子来表示字符串。 https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html#match-mapping-type
你能展示你的文件的映射吗?
(GET / my_index / my_doc / _mapping)
您在查询中作为参数提供的分析器仅在搜索时应用,而不是在索引时应用。因此,如果您没有在映射中设置此分析器,则字符串仍然使用“默认”分析器编制索引,因此它与您的结果不匹配。
您在搜索时提供的分析器将应用于您的查询字符串,但随后它将查看索引数据,索引数据被索引为“Yaound ”,而不是“yaounde”。