gpt4 book ai didi

json - Elastic Search地理哈希返回完整的详细信息,而不仅仅是doc_count

转载 作者:行者123 更新时间:2023-12-02 22:41:54 25 4
gpt4 key购买 nike

我正在一个属性(property)农业网站上,该网站将存储数百个属性(property)。为了映射区域,我正在使用Elastic Search的GEO哈希来减少给定缩放级别返回的匹配数。

生成哈希的代码如下:

`GET _search
{
"from": 0,
"size": 0,
"query": {
"match_all": {}
},
"filter": {
"and": [{
"range": {
"property.price": {
"lte": 1000000000
}
}
}, {
"geo_bounding_box": {
"property.location": {
"top_left": {
"lat": 42.88679,
"lon": -73.5081419
},
"bottom_right": {
"lat": 41.2390897,
"lon": -69.9279921
}
}
}
}, {
"term": {
"property.rental": false
}
}, {
"term": {
"property.country": "US"
}
}]
},
"sort": [{
"property.price": "asc"
}],
"facets": {
"stat1": {
"statistical": {
"field": "price"
}
}
},
"aggs": {
"geohash": {
"filter": {
"geo_bounding_box": {
"property.location": {
"top_left": {
"lat": 42.88679,
"lon": -73.5081419
},
"bottom_right": {
"lat": 41.2390897,
"lon": -69.9279921
}
}
}
},
"aggregations": {
"locations": {
"geohash_grid": {
"field": "location",
"precision": 8
}
}
}
}
}

}`

生成的JSON随每个GeoHash的匹配数返回,并且可以正常工作,只是似乎没有任何方法可以在结果中包括属性详细信息,或者没有包含单击ID即可返回到它的ID?

结果如下:
`{
"took": 94,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 13,
"max_score": 0,
"hits": []
},
"facets": {
"stat1": {
"_type": "statistical",
"count": 50,
"total": 90640800,
"min": 1,
"max": 19500000,
"mean": 1812816,
"sum_of_squares": 628677324820002,
"variance": 9287244646544.04,
"std_deviation": 3047498.0962330457
}
},
"aggregations": {
"geohash": {
"doc_count": 16,
"locations": {
"buckets": [
{
"key": "drt05n43",
"doc_count": 2
},
{
"key": "drt0v0q8",
"doc_count": 1
},
{
"key": "drt0sr3e",
"doc_count": 1
},
{
"key": "drt0kgr8",
"doc_count": 1
},
{
"key": "drt07sdk",
"doc_count": 1
},
{
"key": "drt075vd",
"doc_count": 1
},
{
"key": "drt05n19",
"doc_count": 1
},
{
"key": "drt05jgv",
"doc_count": 1
},
{
"key": "drsbrgvh",
"doc_count": 1
},
{
"key": "drmpgznd",
"doc_count": 1
},
{
"key": "drmpft6c",
"doc_count": 1
},
{
"key": "drmpe6bg",
"doc_count": 1
},
{
"key": "drmp7ybz",
"doc_count": 1
},
{
"key": "drmgkj77",
"doc_count": 1
},
{
"key": "drkzzj3d",
"doc_count": 1
}
]
}
}

}
}`

在向结果中添加其他属性数据的任何帮助将不胜感激。

谢谢 :)

ps对于代码的意图感到抱歉,SO的JSON代码检测有点奇怪。

最佳答案

您可能使用嵌套聚合:
http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/nested-aggregation.html

http://www.fullscale.co/elasticjs/使用elastic.js

ejs.GeoHashGridAggregation('Geohash-Grid')
.field('Geohash')
.precision(precision)
.aggregation(
ejs.TermsAggregation('HouseType').field('HouseType')
)
.aggregation(
ejs.TermsAggregation('HouseColor').field('HouseColor')
)
);

但这只是一个例子。然后,输出将具有与每个geohash匹配的文档的嵌套聚合计数。

关于json - Elastic Search地理哈希返回完整的详细信息,而不仅仅是doc_count,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23654325/

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