Last active
February 16, 2020 10:52
-
-
Save tobinbc/884e499abb5615e64ccfe1756c6f63f3 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
#set( $indexPath = "/tree/_doc/_search" ) | |
#set( $input = $ctx.args.input) | |
#set( $distance = $util.defaultIfNull($input.km, 10) ) | |
#set( $creds = "zx5dej31tt:5inkmy78lz") | |
{ | |
"version": "2018-05-29", | |
"method": "POST", | |
"resourcePath": "$indexPath", | |
"params": { | |
"headers" : { | |
"Content-Type" : "application/json", | |
"Authorization":"Basic $util.base64Encode($creds)" | |
}, | |
"body": { | |
"size": #if( $input.limit ) $input.limit #else 100 #end, | |
"sort": [{ | |
"_geo_distance": { | |
"location": $util.toJson($input.location), | |
"order": "asc", | |
"unit": "km", | |
"distance_type": "plane" | |
} | |
}], | |
"query": { | |
"bool" : { | |
"must" : { | |
"match_all" : {} | |
}, | |
"filter" : { | |
"geo_distance" : { | |
"distance" : "${distance}km", | |
"location" : $util.toJson($input.location) | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment