elasticsearch - [field] 下应为 [START_OBJECT],但在 [geohash_grid] 中得到了 [VALUE_STRING]
问题描述
我需要在受限区域中获取序列号或序列号的最后注册记录,我还应该根据地图中的缩放精度对这些记录进行聚类。我正在使用 Elasticsearch,并且我已经将我的文档映射成这种形状:
{
"mappings": {
"AssetStatus": {
"properties": {
"location": {
"type": "geo_point"
},
"createdate": {
"type": "date"
},
"serialnumber": {
"type": "text",
"fielddata": "true"
}
}
}
}
}
因此,我写了这个查询。
{
"query": {
"bool": {
"must": [
{
"term": {
"serialnumber": "sn2"
}
},
{
"geo_bounding_box": {
"location": {
"top_left": "52.4, 4.9",
"bottom_right": "52.3, 5.0"
}
}
}
],
"must_not": [],
"should": []
}
},
"from": 0,
"size": 0,
"aggregations": {
"SerialNumberGroups": {
"terms": {
"field": "serialnumber"
},
"aggs": {
"tops": {
"top_hits": {
"sort": [
{
"createdate": {
"order": "desc"
}
}
],
"size": 1
},
"aggs": {
"geohash_grid": {
"field": "location",
"precision": 12
}
}
}
}
}
}
}
在这个查询中,首先我限制文档依赖于它们的序列号和它们的位置,因此我按序列号按查询分组并按createdate 排序以获取该区域中每个序列号的最后注册记录。问题出在查询的最后一部分,当我应该使用 geohash_grid 对结果进行聚类时。我得到这个错误
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "Expected [START_OBJECT] under [field], but got a [VALUE_STRING] in [geohash_grid]",
"line": 1,
"col": 374
}
],
"type": "parsing_exception",
"reason": "Expected [START_OBJECT] under [field], but got a [VALUE_STRING] in [geohash_grid]",
"line": 1,
"col": 374
},
"status": 400
解决方案
推荐阅读
- android - 通过网络调用验证 android 中的 URL
- c++ - 使用类从 clang 生成 IR
- classpath - com.faizan.org 包可从多个模块访问:在 Eclipse 2019-12 构建期间使用 JDK 9+ 的 ProjectA、ProjectB
- android - 如何获取图像android的路径?
- django - Django 用户和权限
- javascript - 如何在不重复代码的情况下制作 if 语句?
- node.js - 使用 Firebase 功能重定向到 URL - 谷歌云功能
- c++ - 链表中写访问冲突的未知原因
- r - 如何通过 $ 后跟函数访问 data.frame 列?
- aem - 如何在 aem 的 css.txt 中合并可创作的 css 文件