ElasticSearch:值数组的精确值

时间:2018-05-21 11:57:54

标签: elasticsearch

设置映射

"set": {
                        "type": "string",
                        "index": "not_analyzed",
                        "doc_values": true,
                        "fields": {
                           "criteria": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "analyzer": "analyzer_exact"
                           },
                           "fulltext": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "analyzer": "insight_analyzer_fulltext"
                           }
                        }
                     }

设置值:

"set": [
                     "Cleaning",
                     "Physical Abilities"
                  ],

查询时,

{
  "fields": ["set"], 
  "query": {
    "query_string": {
      "default_field": "FIELD",
      "query": "(set.criteria: \"cleaning\")"
    }
  }
}

结果:

  

清洗

     

身体能力

这是现有的系统,我的任务是分割确切的结果和共同出现的结果。对于上述查询,这意味着结果必须是"清洁"仅

有什么方法可以通过更改查询或数据映射来获得它吗?

1 个答案:

答案 0 :(得分:0)

我不太了解,但如果您只想返回与精确值匹配的结果,则应使用“查询字词”:

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html