elasticsearch - QueryParsingException无法找到geo_point字段

标签 elasticsearch

我正在获取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字段的经纬度设置为double-可能与此有关。

最佳答案

好的,事实证明这是由于我定义geo_point的精度(需要包装在fielddata属性中)而发生的,奇怪的是我使用的JS API没有引发任何我记得的错误:

正确:

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

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

瞧...

关于elasticsearch - QueryParsingException无法找到geo_point字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28856860/

相关文章:

elasticsearch - Elasticsearch 上的 Large bool 问题

elasticsearch - 如何在Grafana量规中显示最后一个值

elasticsearch - 如何在jelastic cloud上安装elasticsearch?

java - Spring数据存储库聚合

django - NgramField根据查询词的子字符串返回结果

elasticsearch - Elasticsearch中 “LIMIT”的替代方法

ElasticSearch bool should_not 过滤器

elasticsearch - 将文件插入Elasticsearch索引中,并由分析器进行分析

search - elasticsearch前瞻性搜索解决方案

elasticsearch - 在Kibana中将Filebeat消息字段拆分为多个字段