[英]How can i do a whereIn query in ElasticSearch?
My Index looks like this 我的索引看起来像这样
{name : 'John Doe',group_id : '1'},
{ name : 'Jane Doe', group_id : '2'}
{ name : 'John Doe', group_id : '3'}
and i want to return all indexes that its group_id is in this array [1, 2] 我想返回其group_id在此数组[1,2]中的所有索引
thus it would return: 因此它将返回:
{name : 'John Doe',group_id : '1'},
{ name : 'Jane Doe', group_id : '2'}
You can use Terms Query for this. 您可以为此使用条款查询 。 Replace
<index>
with the name of the index and <type>
with the type you want to search on. 将
<index>
替换为<index>
的名称,并将<type>
替换为要搜索的类型。
POST <index>/<type>/_search
{
"query": {
"terms": {
"group_id": [
"1",
"2"
]
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.