Skip to content

Instantly share code, notes, and snippets.

@clintongormley
Created September 17, 2013 16: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 clintongormley/6596872 to your computer and use it in GitHub Desktop.
Save clintongormley/6596872 to your computer and use it in GitHub Desktop.
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"mappings" : {
"test" : {
"properties" : {
"loc" : {
"type" : "geo_point"
}
}
}
}
}
'
curl -XPUT 'http://127.0.0.1:9200/test/test/1?pretty=1' -d '
{
"loc" : [
{
"lat" : 0,
"lon" : 5
},
{
"lat" : 0,
"lon" : 10
}
]
}
'
curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1' -d '
{
"sort" : {
"_geo_distance" : {
"unit" : "km",
"mode" : "min",
"loc" : {
"lat" : 0,
"lon" : 3
}
}
}
}
'
# {
# "hits" : {
# "hits" : [
# {
# "_source" : {
# "loc" : [
# {
# "lat" : 0,
# "lon" : 5
# },
# {
# "lat" : 0,
# "lon" : 10
# }
# ]
# },
# "sort" : [
# 222.638981586541
# ],
# "_score" : null,
# "_index" : "test",
# "_id" : "1",
# "_type" : "test"
# }
# ],
# "max_score" : null,
# "total" : 1
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "took" : 1
# }
curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1' -d '
{
"sort" : {
"_geo_distance" : {
"unit" : "km",
"mode" : "min",
"loc" : {
"lat" : 0,
"lon" : 11
}
}
}
}
'
# {
# "hits" : {
# "hits" : [
# {
# "_source" : {
# "loc" : [
# {
# "lat" : 0,
# "lon" : 5
# },
# {
# "lat" : 0,
# "lon" : 10
# }
# ]
# },
# "sort" : [
# 111.319490793262
# ],
# "_score" : null,
# "_index" : "test",
# "_id" : "1",
# "_type" : "test"
# }
# ],
# "max_score" : null,
# "total" : 1
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "took" : 2
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment