Elasticsearch / OpenSearch-数组中的共同值的交集
给定的
a = [1,2,3,4]
以及
b = [1,3]
c = [5,6]
d = [1,6]
如何在Elasticsearch中使用a
的确切数量a
?
我希望:
b -> 2
c -> 0
d -> 1
given
a = [1,2,3,4]
and
b = [1,3]
c = [5,6]
d = [1,6]
how can i find the exact number of common values of a
with b,c,d
in elasticsearch?
I would expect:
b -> 2
c -> 0
d -> 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让您考虑以下是您的Elasticsearch文档,
您的 elasticsearch Query 将看起来如下:
在这里,您需要使用第一个术语聚合,并且需要应用SUM_BUCKET聚合。
示例响应:
您可以使用
b_sum
,c_sum
和d_sum
的值。Let consider below is your elasticsearch document,
Your Elasticsearch Query will looks like below:
Here, You need to use first terms aggregation and above that you need to apply sum_bucket aggregation.
Sample Response:
You can use value of
b_sum
,c_sum
andd_sum
from below response.