Last active
September 6, 2016 03:14
-
-
Save marija17/383010b65c07616e39530f484fa50494 to your computer and use it in GitHub Desktop.
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
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