ElasticSearch如何设置geo_point [英] ElasticSearch how to setup geo_point
本文介绍了ElasticSearch如何设置geo_point的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1)创建映射:
PUT jay / geotest / _mapping
{
geotest:{
properties:{
name:{
type:string
},
pin:{
type:geo_point
}
}
}
}
2)验证映射:
code> GET jay / geotest / _mapping
3)添加一条数据
put jay / geotest / 1
{
name:test1,
pin :{
lat:0,
lon:0
}
}
4)查询该数据:
GET jay / geotest / _search?search_type = count
{
filtered:{
filter:{
geo_distance:{
distance:100km,
pin:{
lat:0,
lon:0
}
}
}
}
}
我的预期结果是我会得到一个命中返回,而是没有任何返回的查询。
提前感谢
解决方案
请求的查询部分。
POST jay / geotest / _search
{
查询:{
filtered:{
filter:{
geo_distance:{
distance:100km,
pin {
lat:0,
lon:0
}
}
}
}
}
}
我刚刚测试过您的步骤,并使该更改返回文档。
I'm trying to setup a geo_point object on ES 1.0.0 and run a simple proof of concept query against it but the query is failing to return any hits. Here are my setup steps:
1) Create the mapping:
PUT jay/geotest/_mapping
{
"geotest" : {
"properties" : {
"name" : {
"type" : "string"
},
"pin" : {
"type": "geo_point"
}
}
}
}
2) verify the mapping:
GET jay/geotest/_mapping
3) Add a piece of data
put jay/geotest/1
{
"name": "test1",
"pin": {
"lat": 0,
"lon": 0
}
}
4) query for that data:
GET jay/geotest/_search?search_type=count
{
"filtered" : {
"filter" : {
"geo_distance" : {
"distance" : "100km",
"pin" : {
"lat" : 0,
"lon" : 0
}
}
}
}
}
My expected result is that I will get one hit returned but instead nothing is returned by the query.
Thanks in advance!
解决方案
I think you're missing the "query" part of the request.
POST jay/geotest/_search
{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "100km",
"pin": {
"lat": 0,
"lon": 0
}
}
}
}
}
}
I've just tested your steps, and making that change returns the document.
这篇关于ElasticSearch如何设置geo_point的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文