API Reference / API Parameters / attributeCriteriaComputedByMinProximity


Type: boolean
Engine default: false
Parameter syntax
'attributeCriteriaComputedByMinProximity' => true|false

Can be used in these methods:

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.


Sets attributeCriteriaComputedByMinProximity to true for an index

  'attributeCriteriaComputedByMinProximity' => true

Did you find this page helpful?