Bumping this one up. Any advice on the query?

On Tue, May 13, 2014 at 6:17 PM, Utkarsh Sengar <utkarsh2...@gmail.com>wrote:

> I have a usecase where I have 2 types of locations (i.e. with geo_point
> type):
>
> 1. Location 1: Has a lat/lon with say radius=90 miles (it will vary) and
> type=outgoing
> 2. Location 2: Has a lat/lon with no radius and type=incoming
>
> Now, when a query comes in with: lat/lon and radius=20, I expect this to
> happen:
>
> 1. Simple geo lookup: If the input lat/lon is within 20miles of location
> 2, return location 2.
> 2. If input lat/lon is within 90 miles of Location 1, return location 1
> too in the result. If you notice, I want input radius to be overwritten by
> the saved radius for a specific type of location.
>
> This is what I have come up with using script:
> {
>   "query": {
>     "match_all": {}
>   },
>   "filter": {
>     "script": {
>       "script": "!doc['geopoint'].empty && doc['coverage_type'].value ==
> 'outgoing' ? doc['geopoint'].distanceInMiles(37,-121) <=
> doc['radius'].value : doc['geopoint'].distanceInMiles(37,-121) <= 20"
>     }
>   }
> }
> Where "37,-121" is input lat/lon and 20 is the input radius.
>
>
> What do you think?
>
> --
> Thanks,
> -Utkarsh
>



-- 
Thanks,
-Utkarsh

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CADjjot9Qxaq2Zd%2BdsCcX3YjJ4%3DKhAQ_fzv0BsUva5R-KWcSKOg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to