Geospatial range filter queries will filter records based on the distance of a geocode property from a given reference point.
The reference point is a latitude/longitude pair
of floating-point values that are arguments to the
endeca:geocode()
function. These queries are triggered
by the
endeca:distance()
function, which in turn uses the
endeca:geocode()
function as one of two arguments in
its predicate. The syntax for a geospatial range query is:
collection()/record[endeca:distance(geoPropName, endeca:geocode(latValue,lonValue)) rangeOp distLimit]
where:
geoPropName
is the name (in NCName format) of an Oracle Commerce geocode property.latValue
is the latitude of the location in either an integer or a floating point value. Positive values indicate north latitude and negative values indicate south latitude.lonValue
is the longitude of the location either an integer or a floating point value. Positive values indicate east longitude and negative values indicate west longitude.rangeOp
is either the < (less than) or > (greater than) operator. These range operators specify that the distance from the geocode property to the reference point is either less (<) or greater (>) than the given distance limit (thedistLimit
argument).distLimit
is a numerical literal value used for the comparison by the range operator. Distance limits are always expressed in kilometers.
When the geospatial filter query is made, the records are filtered by the distance from the geocode property to the geocode reference point (the latitude/longitude pair of values).
For example, Oracle Commerce’s main office is located at 42.365615 north latitude, 71.075647 west longitude. Assuming a geocode property named Location, a geospatial filter query would look like this:
collection()/record [ endeca:distance(Location, endeca:geocode(42.365615,-71.075647)) < 10 ]
The query returns only those records whose location (as specified in the Location property) is less than 10 kilometers from Oracle Commerce’s main office.