Skip to content

Instantly share code, notes, and snippets.

@marija17
Last active September 6, 2016 03:14
Show Gist options
  • Save marija17/383010b65c07616e39530f484fa50494 to your computer and use it in GitHub Desktop.
Save marija17/383010b65c07616e39530f484fa50494 to your computer and use it in GitHub Desktop.
GET _search
{
"query": {
"match_all": {}
}
}
DELETE weather_index
# Map an index with a geo_point location
PUT weather_index
{
"mappings": {
"weather_type": {
"properties": {
"location": {
"type": "geo_point",
"lat_lon": true
}
}
}
}
}
# Query and sort for a timePredicted and geo_point location
GET weather_index/weather_type/_search
{
"query": {
"constant_score": {
"filter": {
"and": {
"filters": [
{
"term": {
"timePredicted": 1470744000000
}
},
{
"geo_distance": {
"distance": "10km",
"location": {
"lat": 45,
"lon": -90
}
}
}
]
}
}
}
},
"sort": [
{
"_geo_distance": {
"location": {
"lat": 45,
"lon": -90
},
"order": "asc",
"unit": "km"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment