When used with a standard attribute of type geocode, the EQL DISTANCE function indicates a filter based on the distance of that geocode attribute from a given reference point.
DISTANCE(geoAttribute, TO_GEOCODE(latitude,longtitude))where geoAttribute is a standard attribute of type geocode.
The distance limits in geocode filters are always expressed in kilometers. The records are filtered by the distance from the geocode reference point to the latitude/longitude pair.
Note that both DISTANCE and TO_GEOCODE operate only on single-assign geocode attributes.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <Request xmlns="http://www.endeca.com/MDEX/conversation/3/0"> <Language>en</Language> <State> <DataSourceFilterString> COUNTRY_NAME = 'United States of America' </DataSourceFilterString> <SelectionFilterString> DISTANCE(Location, TO_GEOCODE(40.758224, -73.917404)) BETWEEN 1 AND 500 </SelectionFilterString> </State> <RecordListConfig Id="RecordList MaxPages="20"> <RecordsPerPage>5</RecordsPerPage> </RecordListConfig> </Request> </soapenv:Body> </soapenv:Envelope>
The query returns only records whose location (in the Location property) is between 1 and 500 kilometers from the reference point.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <Request xmlns="http://www.endeca.com/MDEX/conversation/3/0"> <State> <DataSourceFilterString> COUNTRY_NAME = 'United States of America' </DataSourceFilterString> <SelectionFilterString> DISTANCE(Location, TO_GEOCODE(40.758224, -73.917404)) > 200 </SelectionFilterString> </State> <RecordListConfig Id="RecordList MaxPages="20"> <RecordsPerPage>5</RecordsPerPage> </RecordListConfig> </Request> </soapenv:Body> </soapenv:Envelope>
The query returns only records whose location (in the Location property) is equal to or greater than 200 kilometers from the reference point.
An example of a less-than query would be the same except for the use of the < (less-than) operator.