Skip to content

Instantly share code, notes, and snippets.

@mjambon
Created October 15, 2012 23:02
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 mjambon/3896214 to your computer and use it in GitHub Desktop.
Save mjambon/3896214 to your computer and use it in GitHub Desktop.
elasticsearch not indexing/finding geo_point in a subfield
cluster.name: elasticsearch_dev
path.data: ./data/
path.logs: ./log/
network.host: 0.0.0.0
#! /bin/sh
set -e
set -x
index=test$(date +%s)
curl -XPUT http://127.0.0.1:9200/$index -d '{
"mappings": {
"doc": {
"properties": {
"id": { "type": "string", "index": "not_analyzed" },
"location.coord": { "type": "geo_point", "lat_lon": true },
"location2": { "type": "geo_point", "lat_lon": true }
}
}
}
}
'
sleep 1
curl -XPOST http://127.0.0.1:9200/$index/doc/100 -d '
{
"id": "100",
"location": {
"coord": { "lat": 37, "lon": -122 }
},
"location2": {"lat": 37, "lon": -122 }
}
'
sleep 1
echo "--- Check that document 100 is there ---"
curl -XGET "http://127.0.0.1:9200/$index/doc/100?pretty=true"
echo "--- Search simple field location2 ---"
curl -XPOST "http://127.0.0.1:9200/$index/doc/_search?pretty=true" -d '
{
"query": {
"filtered": {
"query": { "match_all": {} },
"filter": {
"geo_distance": {
"distance": "20km",
"location2": { "lat": 37, "lon": -122 }
}
}
}
}
}
'
echo "--- Search nested field location.coord ---"
curl -XPOST "http://127.0.0.1:9200/$index/doc/_search?pretty=true" -d '
{
"query": {
"filtered": {
"query": { "match_all": {} },
"filter": {
"geo_distance": {
"distance": "20km",
"location.coord": { "lat": 37, "lon": -122 }
}
}
}
}
}
'
echo "FYI: curl -XDELETE http://127.0.0.1:9200/$index"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment