gpt4 book ai didi

elasticsearch - elasticsearch聚合结果为0

转载 作者:行者123 更新时间:2023-12-03 02:01:42 25 4
gpt4 key购买 nike

以下是我对elasticsearch的查询:

GET index/_search
{
"size": 0,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"and": [
{
"term": {
"id_1": "xx"
}
},
{
"term": {
"level": "level2"
}
},
{
"or": [
{
"term": {
"type": "yyy"
}
},
{
"term": {
"type": "zzzz"
}
}
]
}
]
}
}
},
"aggs": {
"variable": {
"stats": {
"field": "score"
}
}
}
}

但是agg的结果如下:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 68,
"max_score": 0,
"hits": []
},
"aggregations": {
"variable": {
"count": 30,
"min": 0,
"max": 0,
"avg": 0,
"sum": 0
}
}
}

为什么min,max等为0。但是分数(0.18,0.25等)却有值。同样在映射中,得分类型很长。请帮我解决这个问题。提前致谢。

编辑:

索引值:
"score": 0.18

单一文件:
{
"_index": "index",
"_type": "ppppp",
"_id": "n0IiTEd2QFCnJUZOSiNu1w",
"_score": 1,
"_source": {
"name_2": "aaa",
"keyid": "bbbb",
"qqq": "cccc",
"level": "level2",
"type": "kkk",
"keytype": "Year",
"org_id": 25,
"tempid": "113",
"id_2": "561",
"name_1": "xxxxx",
"date_obj": [
{
"keyid": "wwwww",
"keytype": "Year",
"value": 21.510617952000004,
"date": "2015",
"id": "ggggggg",
"productid": ""
},
{
"keyid": "rrrrrr",
"keytype": "Year",
"value": 0.13,
"date": "2015",
"id": "iiiiii",
"productid": ""
}
],
"date": "2015",
"ddddd": 21.510617952000004,
"id_1": "29",
"leveltype": "nnnn",
"tttt": 0.13,
"score": 0.13 ------------------->problem
}
}

对应:
curl -XPUT ip:9200/index -d '{   
"mappings" : {
"places" : {
"properties" : {
"score" : { "type" : "float"}
}
}
}
}'

最佳答案

该修补程序应该简单到将score字段的类型更改为float(或double)而不是longlong是一个整数类型,引擎盖下将0.18索引为0。

"score" : {
"type" : "float",
"null_value" : 0.0
}

请注意,更改映射后,您需要重新索引数据。

关于elasticsearch - elasticsearch聚合结果为0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31848205/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com