Elasticsearch lowercase filter search

后端 未结 2 1514
长发绾君心
长发绾君心 2021-02-13 10:13

I\'m trying to search my database and be able to use upper/lower case filter terms but I\'ve noticed while query\'s apply analyzers, I can\'t figure out how to appl

2条回答
  •  再見小時候
    2021-02-13 11:08

    The problem is that you have a field that you have analyzed during index to lowercase it, but you are using a term filter for the query which is not analyzed:

    Term Filter

    Filters documents that have fields that contain a term (not analyzed). Similar to term query, except that it acts as a filter.

    http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-filter.html

    I'd try using a query filter instead:

    Query Filter

    Wraps any query to be used as a filter. Can be placed within queries that accept a filter.

    Example:

    {
        "constantScore" : {
            "filter" : {
                "query" : {
                    "query_string" : {
                        "query" : "this AND that OR thus"
                    }
                }
            }
        } }
    

    http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-filter.html#query-dsl-query-filter

提交回复
热议问题