aroundPrecision
10
'aroundPrecision' => number_of_meters
Can be used in these methods:
search,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
browse_objects,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
browse_objects,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
browse,
searchForFacetValues,
generateSecuredApiKey,
addAPIKey,
updateAPIKey
search,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
searchAsync,
browseAsync,
searchForFacetValues
Search,
Browse,
SearchForFacetValues,
GenerateSecuredApiKey,
AddApiKey,
UpdateApiKey
Search,
browse,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
Search,
BrowseObjects,
SearchForFacetValues,
GenerateSecuredAPIKey,
AddAPIKey,
UpdateAPIKey
search,
browse index,
search into facet values,
generateSecuredApiKey,
add key,
update key
About this parameter
Precision of geo search (in meters), to add grouping by geo location to the ranking formula.
When ranking hits, the engine groups geo distances into ranges of aroundPrecision
size. All hits within the same range are considered equal with respect to the geo
ranking parameter.
For example, if you set aroundPrecision
to 100
, any object in the range 0-99
from the searched location is considered equal. Same goes for 100-199
, 200-299
, etc.
If you want a non-linear precision, you can specify an array of objects containing the keys from
and value
to specify a precision for a given distance.
For example, if you set aroundPrecision
to [{ "from": 0, "value": 25 }, { "from": 1000, "value": 2000 }]
, all objects in the range 0-999
have a precision of 25 meters, and all objects above 1,000 have a precision of 2 kilometers.
Usage notes:
- For this setting to take effect, the geo criterion must be present in your ranking formula (which is the case by default).
- The default value for
aroundPrecision
is 10 meters, which is the smallest precision we provide. If you set a value less than ten, we round it to 10 meters.
Examples
Set geo search precision
1
2
3
$results = $index->search('query', [
'aroundPrecision' => 100 // 100 meters precision
]);
Set non-linear geo search precision
1
2
3
4
5
6
$results = $index->search('query', [
'aroundPrecision' => [
['from' => 0, 'value' => 25], // 25 meters precision by default
['from' => 2000, 'value' => 1000] // 1,000 meters precision after 2 km
],
]);