大佬教程收集整理的这篇文章主要介绍了如何解决 Elastic Search 中的 Top hit ERROR,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的文档类似于以下格式,我没有做任何映射,但是当我使用两个字段来执行热门聚合时,结果会有所不同
"max_score": 1.0,"hits": [
{
"_index": "data","_type": "test","_ID": "UzzwY3cBOTCkvi7mN2VG","_score": 1.0,"_source": {
"hdID": 20210120,"hrID": 5348,"timestamp": 1612289417551,"timestampString": "2021-02-03 02:10:17.551","ooID": "672848824","okCount": 17,"@R_835_10586@lVol": 4220842,"type": "test"
}
}
]
我想使用“热门”聚合来找出每个 ID 的最新记录 我的查询就像
{
"query": {
"bool": {
"must": {
"terms": {
"ooID": [672848824,672848823]
}
},"filter": {
"match": {
"type": "test"
}
}
}
},"size": 1,"aggs": {
"unique_ID": {
"terms": {
"fIEld": "ooID","size": 1
},"aggs": {
"top_result": {
"top_hits": {
"size": 1,"_source": ["ooID","@R_835_10586@lVol","okCount"],"sort": {
"timestamp" : "desc"
}
}
}
}
}
}
}
when i do the about query,it shows the ERROR
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception","reason": "Text fIElds are not optimised for operations that require per-document fIEld data like aggregations and sorTing,so these operations are Disabled by default. Please use a keyword fIEld instead. Alternatively,set fIElddata=true on [ooID] in order to load fIEld data by uninverTing the inverted index. Note that this can use significant memory."
}
],"type": "search_phase_execution_exception","reason": "all shards Failed","phase": "query","grouped": true,"Failed_shards": [
{
"shard": 0,"index": "test","node": "CzM0ERKGTVyQc3mSiRBY2A","reason": {
"type": "illegal_argument_exception",set fIElddata=true on [ooID] in order to load fIEld data by uninverTing the inverted index. Note that this can use significant memory."
}
}
],"caused_by": {
"type": "illegal_argument_exception",set fIElddata=true on [ooID] in order to load fIEld data by uninverTing the inverted index. Note that this can use significant memory.","caused_by": {
"type": "illegal_argument_exception",set fIElddata=true on [ooID] in order to load fIEld data by uninverTing the inverted index. Note that this can use significant memory."
}
}
},"status": 400
}
但是当我使用另一个字段“hdID”代替“ooID”进行查询时,它不会出错
喜欢`
"aggs": {
"unique_ID": {
"terms": {
"fIEld": "hdID",
结果没问题
{
"took": 7,"timed_out": false,"_shards": {
"@R_835_10586@l": 1,"successful": 1,"skipped": 0,"Failed": 0
},"hits": {
"@R_835_10586@l": {
"value": 104,"relation": "eq"
},"max_score": null,"hits": []
},"aggregations": {
"unique_ID": {
"doc_count_error_upper_bound": 0,"sum_other_doc_count": 0,"buckets": [
{
"key": 20210119,"doc_count": 54,"top_result": {
"hits": {
"@R_835_10586@l": {
"value": 54,"relation": "eq"
},"hits": [
{
"_index": "data","_ID": "jk4bXHgBsdomP0OQIkT1","_score": null,"_source": {
"@R_835_10586@lVol": 29613406,"ooID": "672848823","okCount": 64
},"sort": [
1616452982797
]
}
]
}
}
},{
"key": 20210120,"doc_count": 50,"top_result": {
"hits": {
"@R_835_10586@l": {
"value": 50,"_ID": "FU4DW3gBsdomP0OQwCdo","_source": {
"@R_835_10586@lVol": 29296696,"okCount": 66
},"sort": [
1616436374297
]
}
]
}
}
}
]
}
}
}
我不想使用 hdID 作为查询参数,如何修复错误,
谢谢
杰夫
以上是大佬教程为你收集整理的如何解决 Elastic Search 中的 Top hit ERROR全部内容,希望文章能够帮你解决如何解决 Elastic Search 中的 Top hit ERROR所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。