Elastic search exact match

后端 未结 3 1607
花落未央
花落未央 2020-12-31 07:29

I\'m using elasticsearch and am having a devil of a time getting an exact match to happen. I\'ve tried various combinations of match, query_string, etc, and I either get not

相关标签:
3条回答
  • 2020-12-31 07:48

    Hash two value which you need to search into hash key, then search it.

    0 讨论(0)
  • 2020-12-31 07:50

    Fields are analyzed with the standard analyzer by default. If you would like to check exact match, you could store your field not analyzed also e.g:

    "dog":{
                "type":"multi_field",
                "fields":{
                    "dog":{
                        "include_in_all":false,
                        "type":"string",
                        "index":"not_analyzed",
                        "store":"no"
                    },
                    "_tokenized":{
                        "include_in_all":false,
                        "type":"string",
                        "index":"analyzed",
                        "store":"no"
                    }
                }
            }
    

    Then you can query the dog-field for exact matches, and dog._tokenized for analyzed queries (like fulltext)

    0 讨论(0)
  • 2020-12-31 07:55

    I think that your problem is that field term is being analyzed (check your mapping) with the standard analyzer and is filtering stopwords such as the or that. For that reason you get the same score for Dog and The Dog. So maybe you can solve your problem by configuring a custom analyzer => documentation page

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