Elasticsearch-匹配所有arraylist字段
我几乎没有数组“项目”的文档,我只想选择“ items.name”等于“红色”的那些文档。如果有一种带有一种红色和另一种颜色的文档,则不应产生结果。
1。
{
"items": [
{
"id": "4",
"name": "red"
},
{
"id": "5",
"name": "blue"
}
]
}
{
"items": [
{
"id": "3",
"name": "red"
}
]
}
{
"items": [
{
"id": "2",
"name": "red"
},
{
"id": "1",
"name": "red"
}
]
}
现在,在这里,我需要一个查询,其中只能出现文件2和3的结果,因为所有“ items.name”中都存在“红色”。文档1被忽略,因为它也包含蓝色。
I have few documents with array "items" , i want to only pick those documents where "items.name" is equal to "red". If there is any document with one red and another color, then it should not come in result.
1.
{
"items": [
{
"id": "4",
"name": "red"
},
{
"id": "5",
"name": "blue"
}
]
}
{
"items": [
{
"id": "3",
"name": "red"
}
]
}
{
"items": [
{
"id": "2",
"name": "red"
},
{
"id": "1",
"name": "red"
}
]
}
Now, here i need a query where only document 2 and 3 should come in result, as "red" is present in all the "items.name". document 1 is ignored as it contains blue also.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我第一个带有脚本的解决方案:
这是我的正则表达式解决方案:
在发送请求之前,您需要准备下面的索引:
Here is my first solution with the script :
Here is my regular expression solution :
Before going to send the request, you need to prepare your index below :