账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    ES位置查询的问题[geo_distance] query malformed报错
    • 2020-01-01 00:00
    • 10
    48
    0

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

    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
    }
    0
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 10 元积分
        全部回答
    • 0
    • 队友最骚 普通会员 1楼

      "geo_distance" 是 Google 地图 API 的一个查询参数,用于查询两个位置之间的距离。如果查询报错,通常可能是由于以下几个原因:

      1. 地图 API 端点配置问题:请确保您的地图 API 端点已正确配置。例如,您的地图 API 端点 URL 应包含 "https://maps.googleapis.com/maps/api/distance"。

      2. 地图 API 配置问题:请确保您的地图 API 配置正确。例如,您的地图 API 配置需要包含 "key" 参数,其值应为您的 Google 地图 API密钥。

      3. 位置数据问题:请确保您的位置数据格式正确。例如,您的位置数据应该是 "latitude","longitude","accuracy"(精度)等字段的组合。

      4. "geo_distance" 参数问题:请确保您正确地使用了 "geo_distance" 参数。例如,如果您使用的是 "geodesic_distance" 参数,那么需要在查询字符串中添加 "distance" 参数。

      如果您已经尝试了上述方法,但仍然无法解决问题,请提供更多的信息,如查询字符串,错误消息等。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部