在我的 ES 映射中,我有一个“uri”字段,当前设置为 not_analysis,并且不允许更改映射。我想使用这样的 query_string 查询来搜索 uri 部分(此 ES 查询是自动生成的,即为什么它有点复杂,但我们只关注 query_string 部分)
{
"sort": [{"updated": {"order": "desc"}}],
"query": {
"bool": {
"must":[{
"query_string": {
"query":"*w3\\.org\\/2014\\/01\\/a*",
"lowercase_expanded_terms": true,
"default_field": "uri"
}
}],
"minimum_number_should_match": 1
}
}, "size": 50}
现在它通常可以工作,但我存储了以下网址(虚构网址):http://w3.org/2014/01/Abc.html由于 A-a 差异,此查询不会将其返回。将扩展项设置为 false 也无法解决此问题。我应该怎么做才能使该查询不区分大小写?
我在这里先向您的帮助表示感谢。
从文档来看,您似乎需要一个新的分析器,它首先转换为小写,然后可以运行搜索。你尝试过吗?http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/sorting-collations.html
当我读到它时,您的模式 lowercase_expanded_terms 仅适用于扩展,不适用于常规单词http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
lowercase_expanded_terms
Whether terms of wildcard, prefix, fuzzy, and range queries are to be automatically lower-cased or not (since they are not analyzed). Default it true
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)