我想将 ids
查询与 must_not
子句结合起来。我在 Rails 应用程序中使用(重新)轮胎 gem。
我正在做这样的事情:
query do
ids ["foo", "bar", "test"]
end
哪个有效。但是,当我尝试将它与 must_not
子句结合使用时,我遇到了错误 – must_not
仅适用于 boolean
范围,它确实不包括 ids
查询。有什么方法可以合并这两个查询吗?
最佳答案
您需要使用的 ES 查询是这个:
GET /some_index/some_type/_search
{
"query": {
"bool": {
"must": [
{
"ids": {
"values": ["foo", "bar", "test"]
}
}
],
"must_not": [
{
"match": {
"name": "whatever"
}
}
]
}
}
}
因此,您需要 bool 范围,must
与您的 ids
和 must_not
与您的 must not match 查询。
关于ruby-on-rails - Elasticsearch – 将 ids 查询与 must_not 子句结合起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26607518/