Last active
December 3, 2018 22:39
-
-
Save adrianhall/33347294b12d600adca4b2c7b9b7672f to your computer and use it in GitHub Desktop.
This file contains hidden or 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($query = { | |
"bool": { | |
"must": [ | |
{ "match": { "typeName": "LOCATION" } } | |
] | |
} | |
}) | |
#if (! $util.isNull($context.args.byGPS )) | |
$util.qr($query.bool.put("filter", { | |
"geo_distance": { | |
"distance": "${context.args.byGPS.radius}km", | |
"gps": $context.args.byGPS.gps | |
} | |
})) | |
#end | |
#if (! $util.isNull($context.args.byAddress )) | |
#if (! $util.isNull($context.args.byAddress.street )) | |
$util.qr($query.bool.must.add({ "match": { "address.street": "$context.args.byAddress.street" } })) | |
#end | |
#if (! $util.isNull($context.args.byAddress.city )) | |
$util.qr($query.bool.must.add({ "match": { "address.city": "$context.args.byAddress.city" } })) | |
#end | |
#if (! $util.isNull($context.args.byAddress.state )) | |
$util.qr($query.bool.must.add({ "match": { "address.state": "$context.args.byAddress.state" } })) | |
#end | |
#if (! $util.isNull($context.args.byAddress.zipcode )) | |
$util.qr($query.bool.must.add({ "match": { "address.zipcode": "$context.args.byAddress.zipcode" } })) | |
#end | |
#end | |
{ | |
"version":"2017-02-28", | |
"operation":"GET", | |
"path":"/_search", | |
"params":{ | |
"body": { | |
"query": $util.toJson($query) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment