Skip to content

Instantly share code, notes, and snippets.

@mastermunj
Created June 5, 2014 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mastermunj/a58298bc56615b54d643 to your computer and use it in GitHub Desktop.
Save mastermunj/a58298bc56615b54d643 to your computer and use it in GitHub Desktop.
ElasticsearchParseException[field must be either 'lat', 'lon' or 'geohash']
# Delete old Index, if exists.
curl -XDELETE 'localhost:9200/listing?pretty'
# Create Index
curl -XPUT 'localhost:9200/listing?pretty' -d '{}'
$ Put Mapping
curl -XPUT 'localhost:9200/listing/listing/_mapping?pretty' -d '{"listing": {"properties": {"rent": {"type": "intger"}, "location": {"type": "geo_point", "lat_lon": true}}}}'
# Add Data
curl -XPUT 'localhost:9200/listing/listing/1?pretty' -d '{"rent": 5000, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/2?pretty' -d '{"rent": 5500, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/3?pretty' -d '{"rent": 5600, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/4?pretty' -d '{"rent": 5700, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/5?pretty' -d '{"rent": 5800, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/6?pretty' -d '{"rent": 5900, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/7?pretty' -d '{"rent": 6000, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/8?pretty' -d '{"rent": 6100, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/9?pretty' -d '{"rent": 6200, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/10?pretty' -d '{"rent": 6300, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/11?pretty' -d '{"rent": 6400, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/12?pretty' -d '{"rent": 6500, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/13?pretty' -d '{"rent": 6600, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/14?pretty' -d '{"rent": 6700, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/15?pretty' -d '{"rent": 6800, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/16?pretty' -d '{"rent": 6900, "location":{"lat":19.1297376,"lon":72.8291555}}'
curl -XPUT 'localhost:9200/listing/listing/17?pretty' -d '{"rent": 7000, "location":{"lat":19.1297376,"lon":72.8291555}}'
# Query for geo_distance facet.
curl -XGET 'http://localhost:9200/grabhouse/listing/_search?pretty' -d '{"query": {"match_all": {}}, "size": 0, "facets": {"distance": { "geo_distance": { "location": [72.8101887,19.1878388],"ranges": {"to": 3}}}}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment