elasticsearch - 嵌套字段上的 Elasticsearch 桶排序
问题描述
我对 Elastic 7.1.0 上的嵌套字段的存储桶排序有问题:我的索引具有以下映射:
{
"mapping": {
"dynamic": "strict",
"properties": {
"created_at_timestamp": {
"type": "date"
},
"url": {
"type": "keyword",
},
"title": {
"type": "keyword",
},
"entities": {
"type": "nested",
"properties": {
"counter": {
"type": "long"
},
"metric": {
"type": "long"
},
"id": {
"type": "long"
},
"relevance": {
"type": "float"
},
"weighted_metric": {
"type": "float"
}
}
}
}
}
}
我需要通过“weighted_metric”对这些文档进行排序,并针对特定的实体 ID 进行过滤。我写了这个查询:
GET my_index/_search?size=0
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "entities",
"query": {
"term": {
"entities.id": "27374"
}
}
}
}
],
"must_not": [
{
"term": {
"title": {
"value": ""
}
}
}
]
}
},
"aggs": {
"by_url_and_title": {
"composite": {
"sources": [
{
"final_url": {
"terms": {
"field": "final_url"
}
}
},
{
"title": {
"terms": {
"field": "title"
}
}
}
]
},
"aggs": {
"sum_metric": {
"nested": {
"path": "entities"
},
"aggs": {
"weightedmetric": {
"filters": {
"filters": {
"new": {
"bool": {
"should": [
{
"term": {
"entities.id": "27374"
}
}
]
}
}
}
},
"aggs": {
"wmetric": {
"sum": {
"field": "entities.weighted_metric"
}
}
}
},
"w_sort": {
"bucket_sort": {
"sort": [
{
"weightedmetric.wmetric": {
"order": "desc"
}
}
],
"size": 10
}
}
}
}
}
}
}
}
我有这个错误:
{
"error": {
"root_cause": [],
"type": "search_phase_execution_exception",
"reason": "",
"phase": "fetch",
"grouped": true,
"failed_shards": [],
"caused_by": {
"type": "class_cast_exception",
"reason": "org.elasticsearch.search.aggregations.bucket.nested.InternalNested cannot be cast to org.elasticsearch.search.aggregations.InternalMultiBucketAggregation"
}
},
"status": 503
}
如果我不尝试订购水桶,一切正常。有人可以帮我解决这个问题吗?我需要按 weighted_metric 订购桶。谢谢
解决方案
推荐阅读
- complexity-theory - 加法下渐近有界函数的证明
- assembly - 将 XMM 寄存器设置为重复字节模式(广播常量字节)
- jquery - 自定义模式 - 如何停止保存按钮的默认行为,以便自定义模式可以先做它的事情?
- javascript - Mongodb绑定多个ip
- spring-boot - SpringBoot中的@Putmapping删除关系对象
- node.js - 当我尝试保存对象数组时出现猫鼬验证错误
- python - Django Ajax 表单提交两次
- laravel - Laravel 6 数据库通知在生产中不起作用
- r - 如何根据单独的列变量汇总列?
- ios - 颤振横幅广告在真实设备上不起作用