4

谁能帮我解决这个问题?我收到一个错误返回:“没有为 [or] 注册查询”我的结构是否错误?它应该过滤所有区域为 530 且开始为空白或区域为 530 且开始为“06192013”​​的结果,然后在此基础上使用其他过滤器提升文档。

{
  "query": {
    "custom_filters_score": {
      "query": {
        "bool": {
          "must": [
            {"field":{"sector":"sector1"}},
            {"term":{"user_type":"ghost"}},
            {"term":{"area":"530"}}
          ]
        },
        "filter":{
          "or": [
            {
              "and": [
                {"term":{"area":"530"}},
                {"term":{"start":"06192013"}}
              ]
            },
            {
              "and": [
                {"term":{"area":"530"}},
                {"term":{"start":"blank"}}
              ]
            }
          ]
        }
      },
      "filters": [
        {"filter":{"term":{"relevance" :5726}},"boost":"1000"},
        {"filter":{"term":{"relevance2":5726}},"boost":"100"}
      ],
      "score_mode":"total"
    }
  }
}
4

1 回答 1

5

包含 or 过滤器的过滤器对象放错了位置。我猜您想使用包含 bool 查询和 or 过滤器的过滤查询,如下所示:

{
    "filtered" : {
        "bool": {
          "must": [
            {"field":{"sector":"sector1"}},
            {"term":{"user_type":"ghost"}},
            {"term":{"area":"530"}}
          ]
        },
        "filter" : {
            "or": [
            {
              "and": [
                {"term":{"area":"530"}},
                {"term":{"start":"06192013"}}
              ]
            },
            {
              "and": [
                {"term":{"area":"530"}},
                {"term":{"start":"blank"}}
              ]
            }
          ]
        }
    }
}
于 2013-06-12T07:54:27.813 回答