Elasticsearch case-insensitive query_string query with wildcards

前端 未结 2 529
遇见更好的自我
遇见更好的自我 2021-01-21 10:36

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 q

相关标签:
2条回答
  • 2021-01-21 11:18

    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

    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

    0 讨论(0)
  • 2021-01-21 11:37

    Try to use match query instead of query string.

    {
    "sort": [
        {
            "updated": {
                "order": "desc"
            }
        }
    ],
    "query": {
        "bool": {
            "must": [
                {
                    "match": {
                        "uri": "*w3\\.org\\/2014\\/01\\/a*"
                    }
                }
            ]
        }
    },
    "size": 50
    }
    

    Query string queries are not analyzed and but match queries are analyzed.

    0 讨论(0)
提交回复
热议问题