elasticsearch - 需要帮助以启用弹性搜索查询的排序和分页
问题描述
我对弹性搜索比较陌生。我正在尝试对具有多个聚合的以下 ES 查询启用分页和排序。我尝试了复合 agg,它对排序没有帮助。以下是查询:
{
"size": 0,
"query": {
"bool": {
"must": [
{
"match_phrase": {
"customerId.keyword": "{{customerId_value}}"
}
},
{
"query_string": {
"query": "*{{search_query}}*",
"minimum_should_match": "75%",
"fields": [
"neName.keyword^3",
"productFamily.keyword^2",
"productId.keyword^2",
"ipAddress.keyword^2",
"swVersion.keyword^2"
]
}
},
{
"range": {
"lastReset": {
"to": "now",
"from": "{{range}}"
}
}
}
]
}
},
"aggs": {
"unique_devices": {
"terms": {
"field": "neInstanceId.keyword",
"size": 10000
},
"aggs": {
"device_stats": {
"stats": {
"field": "lastReset"
}
},
"required_fields": {
"top_hits": {
"size": 1,
"_source": {
"includes": [
"neInstanceId",
"neName",
"productFamily",
"productId",
"swVersion",
"ipAddress",
"serialNumber"
]
}
}
}
}
}
}
}
期望:对所有字段进行分页和排序。感谢任何回应。
解决方案
推荐阅读
- r - 更改 sjTable 格式?
- javascript - 虽然设置了 keyExtractor,但我得到了 VirtualizedList:缺少项目的键,请确保指定一个键或提供自定义 keyExtractor
- spring-tool-suite - 为什么 spring-tool-suite-4-4.10.0.RELEASE-e4.19.0-win32.win32.x86_64.self-extracting.jar 对我的电脑有害
- knative - 使用“kn service update hello-example --request”设置资源限制时出错
- javascript - 为多个系列创建多个 Pie Highcharts
- java - 我无法在 win10 上使用 `mvn spring-boot:build-image` 和远程 docker 守护进程
- dolphindb - 使用 group by 时 DolphinDB 中的错误消息
- c# - 使用 QuickSort 对字符串中的字符进行排序
- arrays - 使用 kotlin 如何将数组附加到二维数组
- python-3.x - 为什么 print 函数在方法中不起作用:get_details() 并且没有为 print(x.increment_odometer) 返回?