如何将弹性搜索中的结果过滤到id包含[10,23,34,44]中任何元素的文档

How to filter the result in elastic search to the documents which id contains any of the elements in [10,23,34,44]

我是弹性搜索的新手。我正在使用以下库来帮助我构建搜索查询。 这里是图书馆:

https://github.com/sudo-suhas/elastic-builder

我有以下代码来创建我的查询:

        requestBody = elasticSearchBuilder.requestBodySearch()
        .query(
            elasticSearchBuilder.boolQuery()
                .must(elasticSearchBuilder.multiMatchQuery(feilds, searchQuery)
                    .type(sortAlgorithm)
                    .tieBreaker(tieBreaker)
                    .minimumShouldMatch(searchAccuracy))

这导致:

{
"bool": {
    "must": {
        "multi_match": {
            "query": "xxxxxxxxx",
            "fields": ["name", "owner", "byline_name", "head"],
            "type": "best_fields",
            "tie_breaker": 0.3
        }
    }
}

} }

现在我想添加另一个过滤器,在其中搜索 id 在这个数组中的文档:[10,23,34,44]。所以我正在寻找诸如 between 或 contains 之类的东西或......任何可以解决这个问题的东西。谁能帮我解决这个问题?

更新:

[
{
"id": "80092",
"categoryId": "43229",
"channelId": "54322",
"channelName": "xxxxxxxxxxxx",
"owner": "xxxxxxxxxxxxx",
"ownerChannel": "xxxxxxxxxxxxx",
"bylineName": "xxxxxxxxxxxxxx",
"bylinePublication": "xxxxxxxxxxxx"
 }
]

如果要对标识符执行此操作,可以使用一个名为 ids

的特殊查询
POST http://localhost:9200/your_index/your_type/_search
Content-type: application/json

{
   "query": {
       "ids" : {
           "values" : ["10", "23", "34", "44"]
       }
   }
}

对于其他字段,您可以使用 terms 查询。

{
   "query": {
      "constant_score" : {
         "filter" : {
            "terms" : { "otherField" : [10, 23, 34, 44]}
          }
       }
    }
}