node.js - 如何根据当前 agg 进行 Elasticsearch Agg 查询?
问题描述
我的文档看起来像这样
{ cool_things: [{ name, id }, { name, id }] }
我如何找到我目前在聚合中的 id。例如,这是我正在使用的查询。
params.body.aggs = {
uniqueCoolThings: {
terms: {
field: 'cool_things.name.keyword'
},
aggs: {
value: {
top_hits: {
size: 1,
_source: {
includes: ['cool_things.id', 'cool_things.name.keyword']
}
}
}
}
}
}
}
然而这会回来
...hits._source: {
uniqueCoolThings: [
{
"id": 500,
"name": "Bob Sagget"
},
{
"id": 501,
"name": "Matt Damon"
}
]
} ...
我想知道如何做一个 where 条件,以便它只返回与它当前所在的唯一 cool_things.name.keyword 匹配的 ID。
我需要获取所有 unique_cool 事物的列表,然后让他们的 ID 与该响应一起返回(如果这有意义的话)
任何帮助将不胜感激!!!!
解决方案
推荐阅读
- java - Java自定义注解默认值等于类字段名
- python - 检查两个列表是否在一个熊猫列中
- java - 在访问没有“this”的实例方法时,让 Eclipse 抛出警告。
- c# - 通过邮递员发送时,后控制器值始终为空
- javascript - 自定义 cookie 不通过导航持久化
- sql - hive 从字符串创建一个数组
- r - R 和 Java/JavaScript 中的 MD5 和 Base64 编码不匹配
- javascript - 似乎无法在 React 的动态导入中使用 JavaScript 变量
- sql - 使用元数据和分组的复杂沙发库查询
- php - 在 HTML FORM + IMAGE UPLOAD + PHP + MYSQL 中选择