elasticsearch 在ES中组合过滤查询和布尔查询,elasticsearch,elasticsearch" /> elasticsearch 在ES中组合过滤查询和布尔查询,elasticsearch,elasticsearch" />

elasticsearch 在ES中组合过滤查询和布尔查询

elasticsearch 在ES中组合过滤查询和布尔查询,elasticsearch,elasticsearch,我在合并两个查询时遇到困难。 第一个: { query: { filtered: {filter:{bool: {must_not: [{ids: {values: ["one", "two"]}}]}}} } } 第二个: { query: { bool: { must_not: [ { wildcard: {url: "*.biz"} } ] } } } 如果我单独运行它们,它们就可以正常工作。但是,如果我将

我在合并两个查询时遇到困难。 第一个:

{
  query: {
    filtered: {filter:{bool: {must_not: [{ids: {values: ["one", "two"]}}]}}}
  }
}
第二个:

{
  query: {
    bool: {
      must_not: [
        { wildcard: {url: "*.biz"} }
      ]
    }
  }
}
如果我单独运行它们,它们就可以正常工作。但是,如果我将它们合并为:

{
  query: {
    filtered: {filter:{bool: {must_not: [{ids: {values: ["one", "two"]}}]}}},
    bool: {must_not: [{ wildcard: {url: "*.biz"} }]}
  }
}
我得到了以下错误(为了简洁起见,省略了大部分错误):

我的ES版本是1.1.1


如何解决这个问题?

将查询与筛选器结合起来应该使用,这需要
query
filter
参数:

{
  "query": {
    "filtered": {
      "query": {
        "bool": {
          "must_not": [
            { wildcard: {url: "*.biz"} }
          ]
        }
      },
      "filter": {
        "bool": {
          "must_not": [
            {ids: {values: ["one", "two"]}
          ]
        }
      }
    }
  }
}
试试
{“查询”:{“bool”:{“不得”:[{“通配符”:{“url”:“*.biz”}},{“id”:{“值”:[“一”,“两”]}}}}}
{
  "query": {
    "filtered": {
      "query": {
        "bool": {
          "must_not": [
            { wildcard: {url: "*.biz"} }
          ]
        }
      },
      "filter": {
        "bool": {
          "must_not": [
            {ids: {values: ["one", "two"]}
          ]
        }
      }
    }
  }
}