ElasticSearch not returning results for terms query against string property

前端 未结 2 1807
盖世英雄少女心
盖世英雄少女心 2020-12-23 17:27

I have the following indexed document:

{
    \"visitor\": {
        \"id\": 
    }
}

The mapping for the document

2条回答
  •  没有蜡笔的小新
    2020-12-23 17:50

    Unless you specify the visitor.id field NOT to be analyzed, every fields are analyzed by default.

    It means that "ABC" will be indexed as "abc" (lower case).

    You have to use term query or term filter with string in LOWER CASE.

    I hope the query below will work. ^^

    {
        "query": {
            "filtered": {
                "query": {
                    "match_all": {}
                 }
            },
            "filter": {
                "term": { "visitor.id": "abc" }
            }
        }
    }
    

提交回复
热议问题