Skip to content

Instantly share code, notes, and snippets.

@awdng

awdng/es.json

Created Dec 15, 2015
Embed
What would you like to do?
elasticsearch query built by elastica 2.x
{
"query": {
"function_score": {
"query": {
"filtered": {
"query": {
"bool": {
"minimum_number_should_match": 0
}
},
"filter": {
"bool": {
"must": [
{
"and": [
{
"or": [
{
"term": {
"availability.week_days.day": "3"
}
},
{
"term": {
"available_days.date": "2015-11-18"
}
}
]
},
{
"or": [
{
"term": {
"availability.week_days.day": "4"
}
},
{
"term": {
"available_days.date": "2015-11-19"
}
}
]
}
]
},
{
"term": {
"country": "gb"
}
}
],
"must_not": [
{
"nested": {
"path": "bookings",
"filter": {
"and": [
{
"range": {
"pickup_date": {
"lte": "2015-11-20T00:00:00+0100"
}
}
},
{
"range": {
"return_date": {
"gte": "2015-11-18T00:00:00+0100"
}
}
}
]
}
}
},
{
"nested": {
"path": "exceptional_dates",
"filter": {
"range": {
"date": {
"gte": "2015-11-18",
"lte": "2015-11-20"
}
}
}
}
}
]
}
}
}
},
"functions": [
{
"gauss": {
"location": {
"origin": "51.458866596222,-0.21000623703003",
"scale": "2km",
"offset": "1km",
"decay": 0.5
}
}
},
{
"script_score": {
"script": "_score * doc['boost'].value"
}
}
]
}
},
"fields": [
"_source"
],
"from": 0,
"size": 10,
"script_fields": {
"current_distance": {
"script": "doc['location'].distanceInKm(lat,lon)",
"params": {
"lat": 51.458866596222,
"lon": -0.21000623703003
},
"lang": "groovy"
}
},
"post_filter": {
"geo_distance_range": {
"to": "30km",
"location": {
"lat": 51.458866596222,
"lon": -0.21000623703003
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment