我正在尝试在这个查询的基础上进行一些构建。我正在搜索的索引还有一个带有 id 的“实体”字段。因此,一些记录将具有“实体”:16、“实体”156 等,具体取决于实体的 ID。我需要以这样的方式扩展此查询,以便可以传递数组或某些值列表,例如 {:term => {:entity => [1, 16, 100]}} 并获取具有这些整数之一作为它们的实体值。到目前为止我还没有运气,有人可以帮助我吗?
{
"query" : {
"bool" : {
"must" : [
{
"term" : {"user_type" : "alpha"}
},
{
"term" :{"area" : "16"}
}
],
"must_not" : [],
"should" : []
}
},
"filter": {
"or" : [{
"and" : [
{ "term" : { "area" : "16" } },
{ "term" : { "date" : "05072013" } }
]
}, {
"and" : [
{ "term" : { "area" : "16" } },
{ "term" : { "date" : "blank" } }
]
}
]
},
"from" : 0,
"size" : 100
}
Use "terms"
代替"term"
.
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html
{ "terms" : { "entity" : [ 123, 1234, ... ] }}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)