带有通配符的弹性搜索不区分大小写的query_string查询 [英] Elasticsearch case-insensitive query_string query with wildcards

查看:1773
本文介绍了带有通配符的弹性搜索不区分大小写的query_string查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的ES映射中,我有一个'uri'字段,当前设置为not_analysed,我不允许更改映射。我想使用这样的query_string查询来搜索uri部件(这个ES查询是自动生成的,这就是为什么它有点复杂,但我们只关注query_string部分)

In my ES mapping I have an 'uri' field which is currently set to not_analysed and I'm not allowed to change the mapping.I wanted to search for uri parts with a query_string query like this (this ES query is autogenerated, that is why it is a bit complicated but let's just focus on the query_string part)

{
  "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}

现在它通常工作,但我有以下url存储(虚构的url) : http://w3.org/2014/01/Abc.html 和这个由于A-a的差异,查询不会带回来。将扩展术语设置为false也不能解决这个问题。我应该怎么做这个查询是不区分大小写?

Now it is usually working, but I've the following url stored (fictional url): http://w3.org/2014/01/Abc.html and this query does not bring it back because of the A-a difference. Setting the expanded terms to false also not solves this. What should I do for this query to be case insensitive?

感谢您的帮助提前。

推荐答案

从文档中,您似乎需要一个新的分析器,首先将其转换为小写,然后可以运行搜索。你试过了吗?
http://www.elasticsearch.org /guide/en/elasticsearch/guide/current/sorting-collat​​ions.html

From the docs, it seems like you need a new analyzer that first transforms to lowercase and then can run the search. Have you tried that? http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/sorting-collations.html

当我阅读它,你的模式,smallcase_expanded_terms只适用于扩展,不定期的话
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html

lowercase_expanded_terms
通配符,前缀,模糊和范围查询的术语是否要自动更低级别(因为它们不被分析)。默认为

As I read it, your pattern, lowercase_expanded_terms, only applies to expansions, not to regular words 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

这篇关于带有通配符的弹性搜索不区分大小写的query_string查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆