ES位置查询的问题[geo_distance] query malformed报错

不添加条件查询出来数据:

POST http://localhost:9200/show/test/_search
{
    "took": 5,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": 4,
        "max_score": 1,
        "hits": [
            {
                "_index": "show",
                "_type": "test",
                "_id": "SzrntWoBFL5R1ZtAHrkc",
                "_score": 1,
                "_source": {
                    "id": 3,
                    "username": "农家商装",
                    "description": "现在想要修改为string类型",
                    "position": {
                        "location": {
                            "lat": 22.6515108793,
                            "lon": 114.1106377105
                        }
                    }
                }
            }
        ]
    }
}

第二次查询

POST http://localhost:9200/show/test/_search
{
    "query": {
        "bool": {
            "filter": {
                "geo_distance": "100km",
                "location": {
                    "lat": 22.6497899384,
                    "lon": 114.1258725301
                }
            }
        }
    }
}

报错:

{
    "error": {
        "root_cause": [
            {
                "type": "parsing_exception",
                "reason": "[geo_distance] query malformed, no start_object after query name",
                "line": 5,
                "col": 21
            }
        ],
        "type": "parsing_exception",
        "reason": "[geo_distance] query malformed, no start_object after query name",
        "line": 5,
        "col": 21
    },
    "status": 400
}
阅读 6.8k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进