attributeCriteriaComputedByMinProximity
false
'attributeCriteriaComputedByMinProximity' => true|false
Can be used in these methods:
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
browse_objects,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
browse_objects,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
browse,
searchForFacetValues,
generateSecuredApiKey,
addAPIKey,
updateAPIKey
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
Search,
SetSettings,
Browse,
SearchForFacetValues,
GenerateSecuredApiKey,
AddApiKey,
UpdateApiKey
Search,
setSettings,
browse,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
Search,
SetSettings,
BrowseObjects,
SearchForFacetValues,
GenerateSecuredAPIKey,
AddAPIKey,
UpdateAPIKey
search,
setSettings,
browse index,
search into facet values,
generateSecuredApiKey,
add key,
update key
About this parameter
When attribute
is ranked above proximity
in your ranking formula, proximity
is used to select which searchable attribute is matched in the attribute ranking stage.
Usage notes
This parameter can only impact relevance when attribute comes before proximity in the ranking formula. By default, this isn’t the case. The rationale for ranking proximity above attribute is detailed in the ranking criteria section. Generally, for objects with long text sections and a clear searchable attribute order (like documentation), it can be beneficial to rank by attribute before proximity.
attributeCriteriaComputedByMinProximity
works in the following way:
By default, searches that match multiple searchable attributes are ranked by their best matching attribute (depending on searchable attributes order). However, if you set this parameter to true
, the matched attribute is selected based on minimum proximity. In other words, if a search query matches on an object in multiple, different searchable attributes, the one with the smallest proximity is selected.
For example, consider an index of books, where you have set your searchable attributes to title
, author
, and description
(in that order), and where you’ve changed the ranking formula so that attribute
comes before proximity
. If the search for a book matches on both its title
, with a proximity of 6, and description
, with a proximity of 1, then title
remains the best matching attribute even though description
has a better proximity score. Setting attributeCriteriaComputedByMinProximity
to true
computes the best matching attribute based on minimum proximity; in our case, description
is used instead of title
.
Examples
Sets attributeCriteriaComputedByMinProximity to true for an index
1
2
3
$index->setSettings([
'attributeCriteriaComputedByMinProximity' => true
]);