【问题标题】:QueryParsingException failed to find geo_point fieldQueryParsingException 找不到 geo_point 字段
【发布时间】:2015-03-04 22:58:46
【问题描述】:

我收到了QueryParsingException[[listings] failed to find geo_point field [location.coords]]; }],但不知道为什么。

我的查询

esClient.search({
    index: 'listings',
    body: {
        query: {
            filtered: {
                query: {
                    match_all: {}
                },
                filter: {
                    geo_distance: {
                        distance: '10km',
                        'location.coords': {
                            lat: parseFloat(query.point.lat),
                            lon: parseFloat(query.point.lon)
                        }
                    }
                }
            }
        }
    }
}, function(err, response) {
    if(err) return console.log(err);
    console.log(response);
});

我的映射(如您所见 - 是的,我确实使用了 geo_point 类型)

    body: {
        properties: {
            location: {
                type: 'object',
                properties: {
                    country: {
                        type: 'integer'
                    },
                    address: {
                        type: 'string'
                    },
                    suburb: {
                        type: 'string'
                    },
                    coords: {
                        type: 'geo_point',
                        precision: '3m'
                    }
                }
            }
        }
    }

编辑:

查看 http://localhost:9200/listings/_mapping/my-mapping 后,我注意到 coords 字段的 lat、lon 设置为双倍 - 这可能与此有关吗?

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    好吧,事实证明这是因为我如何定义 geo_point 的精度(需要包含在 fielddata 属性中),奇怪的是我使用的 JS api 没有抛出任何我记得的错误:

    正确:

    coords: {
        type: 'geo_point',
        fielddata: {
            format: 'compressed',
            precision: '3m'
        }
    }
    

    不正确:

    coords: {
            type: 'geo_point',
            precision: '3m'
        }
    }
    

    然后瞧……

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-24
      • 1970-01-01
      • 2018-08-08
      • 1970-01-01
      • 2020-01-02
      • 2018-11-06
      相关资源
      最近更新 更多