SpatialSearchExtension
Extension for an IndexQuery to carry out a spatial search using the index. The configuration object serves as an extension for an existing IndexQuery and offers the possibility to filter and score results according to distance. The search is always based on the specified center point (required) and the distance in km (default 25). The default method is SPATIAL_METHOD_RADIUS Unless otherwise defined, the search is carried out on the #LOCATION ('location') system field of the index.
Methods
getCenterPoint
getCenterPoint():
number[]
Returns
number[]the specified center point (lat,lon) for the spatial search as an array, or null if not specified.
getDistance
getDistance():
number
Returns
numberthe searched distance in km used for spatial search. Default is 25km.
getLocationEntityField
getLocationEntityField():
string
Returns the entity field whose index field is used for spatial search. IMPORTANT: The index field must have the index field type LOCATION!
Returns
stringThe entity field whose index field is used for spatial search or null if not specified.
getLocationField
getLocationField():
string
Returns the index field used for spatial search. If not specified, the system field #LOCATION ('location') is used. IMPORTANT: The field must have the index field type LOCATION!
Returns
stringThe index field used by the spatial search or null if not specified.
getMethod
getMethod():
string
Returns
stringThe spatial search method that is used. Default: SPATIAL_METHOD_RADIUS
isBoostNearestResults
isBoostNearestResults():
boolean
Returns
booleantrue if the score of a document should be higher depending on its proximity to the specified center point.
isFilterResults
isFilterResults():
boolean
Returns
booleantrue (default), if only documents within the specified distance should be included in the result.
setBoostNearestResults
setBoostNearestResults(
pBoostNearestResults):SpatialSearchExtension
Parameters
booleantrue if the score of a document should be higher depending on its proximity to the specified center point.
Returns
SpatialSearchExtensionsetCenterPoint
setCenterPoint(
pLat,pLon):SpatialSearchExtension
Sets the center point (lat,lon) for the spatial search.
Parameters
numberThe latitude of the center point.
numberThe longitude of the center point.
Returns
SpatialSearchExtensionsetDistance
setDistance(
pDistance):SpatialSearchExtension
Sets the distance in km used for spatial search. Default is 25km.
Parameters
numberthe distance in km.
Returns
SpatialSearchExtensionsetFilterResults
setFilterResults(
pFilterResults):SpatialSearchExtension
Specifies whether only documents within the specified distance should be included in the result. Default is true
Parameters
booleantrue (default), if only documents within the specified distance should be included in the result.
Returns
SpatialSearchExtensionsetLocationEntityField
setLocationEntityField(
pLocationEntityField):SpatialSearchExtension
Sets the entity field whose index field is used for spatial search. If not specified, the system field #LOCATION invalid input: '<'/ tt> ('_location_') is used. **IMPORTANT:** The index field must have the index field type <var>LOCATION</var>!
Parameters
string | number | booleanthe name of the entity field.
Returns
SpatialSearchExtensionsetLocationField
setLocationField(
pLocationField):SpatialSearchExtension
the index field used for spatial search. If not specified, the system field #LOCATION ('location') is used. IMPORTANT: The field must have the index field type LOCATION!
Parameters
string | number | booleanthe index field used by the spatial search.
Returns
SpatialSearchExtensionsetMethod
setMethod(
pMethod):SpatialSearchExtension
Sets the search method of the spatial search. Possible values are indexsearch.SPATIAL_METHOD_RADIUS and indexsearch.SPATIAL_METHOD_BOX
Parameters
string | number | booleanThe search method used for spatial search.
Returns
SpatialSearchExtensionExample
var spatialExt = indexsearch.createSpatialSearchExtension() .setMethod(indexsearch.SPATIAL_METHOD_RADIUS) // setting the search method (default: radius) .setCenterPoint(50.0, 50.0) // setting the center point (required!) .setDistance(10.0) // setting a new distance in km (default: 25) .setFilterResults(true) // enable / disable filtering of results outside the given distance (default: true) .setBoostNearestResults(false); // enable / disable scoring of results by distance (default: true) var query = indexsearch.createIndexQuery().addExtension(spatialExt); // adding the extension to an index query indexsearch.searchIndex(query);