“提升”不适用于“术语”查询

Seb*_*ian 5 elasticsearch

我正在运行 Elasticsearch 1.5.2 并尝试以下查询:

{
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "gender": "male"
              }
            }
          ]
        }
      },
      "query": {
        "bool": {
          "must": [
            {
              "match_all": {}
            }
          ],
          "should": [
            {
              "term": {
                "top_users": 1,
                "boost": 2
              }
            }
          ]
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

一切都很好,直到我将"boost": 2 添加到 should -> term 部分。完整的查询要复杂得多,这就是我需要 boost 的原因,但其余查询没有任何区别:如果term查询获得boost参数,ES 将返回错误 400 :

QueryParsingException[[index_name] [_na] 查询格式错误,必须以 start_object 开头]

有什么建议?

And*_*fan 6

应该是这样的

{
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "gender": "male"
              }
            }
          ]
        }
      },
      "query": {
        "bool": {
          "must": [
            {
              "match_all": {}
            }
          ],
          "should": [
            {
              "term": {
                "top_users": {
                  "value": "1",
                  "boost": 2
                }
              }
            }
          ]
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)