elasticsearch - Why am I not able to query by geolocation in elastic search? -



elasticsearch - Why am I not able to query by geolocation in elastic search? -

so experimenting elasticsearch , did.

1) added geo_point mapping on index called "test"

curl -xpost localhost:9200/test -d '{ "mappings" : { "type1" : { "_source" : { "enabled" : false }, "properties" : { "location" : { "type" : "geo_point", "index" : "not_analyzed" } } } } }'

2) indexed document under test:

curl -xput 'localhost:9200/test/type1/1?pretty' -d '{ "location" : { "lat" : 74, "lon" : 90 } }'

3) wrote query geolocation filter this:

curl -xpost 'localhost:9200/test2/_search?pretty' -d '{ "filtered" : { "query" : { "match_all" : {} }, "filter" : { "geo_distance" : { "distance" : "200km", "location" : { "lat" : 40, "lon" : -70 } } } } }'

for get:

"error" : "searchphaseexecutionexception[failed execute phase [query], shards failed; shardfailures {[qpgehtdcreeymt8x2tg26g][test2][0]: remotetransportexception[[jester][inet[/10.58.91.21:9301]][search/phase/query]]; nested: searchparseexception[[test2][0]: from[-1],size[-1]: parse failure [failed parse source [na]]]; nested: elasticsearchparseexception[failed derive xcontent org.elasticsearch.common.bytes.channelbufferbytesreference@60d8bc76];

first off, in query (i.e. 3rd piece of code), localhost:9200/test2/_search?pretty should localhost:9200/test/_search?pretty, i.e. you're not querying right index.

then query missing query keyword (i.e. filtered should enclosed in query), should this:

curl -xpost 'localhost:9200/test/_search?pretty' -d '{ "query": { "filtered": { "query": { "match_all": {} }, "filter": { "geo_distance": { "distance": "200km", "location": { "lat": 40, "lon": -70 } } } } } }

elasticsearch geolocation

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -