在query_string中搜索多个值弹性搜索

时间:2020-04-19 12:29:45

标签: elasticsearch query-string elasticsearch-5

我以弹性方式使用这些查询,但是问题是当我替换值时会得到不同的结果,或者当我单独使用每个单词时我们会得到不同的结果。这是我查询的一部分

"query_string" : {
      "query" : "businessId : 1848 4335",
      "fields" : []
}
result : "hits": {"total": 81,....}

当替换businessIds时:

"query_string" : {
      "query" : "businessId : 4335 1848",
      "fields" : []
}
result :  "hits": {"total": 162,...}

当我搜索“ 4335”时

"query_string" : {
      "query" : "businessId : 4335",
      "fields" : []
}
result :  "hits": {"total": 0,...}

搜索“ 1848”

"query_string" : {
      "query" : "businessId : 1848",
      "fields" : []
}
result :  "hits": {"total": 14,...}

当我在字段中使用“ businessId”时

"query_string" : {
      "query" : "4335 1848",
      "fields" : ["businessId"]
}
result :  "hits": {"total": 14,...}

我很困惑为什么会发生这些结果?

1 个答案:

答案 0 :(得分:1)

docs对此很清楚:

任何一个

{
  "query": {
    "query_string": {
      "query": "businessId:4335 OR businessId:1848"
    }
  }
}

{
  "query": {
    "query_string": {
      "query": "businessId:(4335 OR 1848)"
    }
  }
}
相关问题