Created
October 15, 2012 23:02
-
-
Save mjambon/3896214 to your computer and use it in GitHub Desktop.
elasticsearch not indexing/finding geo_point in a subfield
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cluster.name: elasticsearch_dev | |
path.data: ./data/ | |
path.logs: ./log/ | |
network.host: 0.0.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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