API Reference / API Parameters / exactOnSingleWordQuery
Type: string
Engine default: attribute
Formerly: enableExactOnSingleWordQuery, useQueryEqualsOneAttributeInRanking
Parameter syntax
'exactOnSingleWordQuery' => 'attribute'|'none'|'word'

Can be used in these methods:
search, setSettings, browseObjects, searchForFacetValues, generateSecuredApiKey, addApiKey, updateApiKey

About this parameter# A

Controls how the exact ranking criterion is computed when the query contains only one word.

Usage notes#

If exactOnSingleWordQuery is set to word, only exact matches will be highlighted in the _highlightResult property of the search response: partials and prefixes will not be.

Options: #

  • attribute: (default): The exact ranking criterion is set to 1 if the query matches exactly an entire attribute value.

    For example, if you search for the TV show “Road”, and in your dataset you have 2 records, “Road” and “Road Trip”, only the record with “Road” is considered exact.

  • none: The exact ranking criterion is ignored on single word queries.

  • word: The exact ranking criterion is set to 1 if the query word is found in the record. The query word must be at least 3 characters long and must not be a stop word in any supported language.

    Continuing with our “Road” TV show example, in this case, both “Road” and “Road Trip” are considered to match exactly.

Examples# A

Set default exact ranking criterion computation on single word query#

1
2
3
4
5
$index->setSettings([
  'exactOnSingleWordQuery' => 'attribute'
  // 'exactOnSingleWordQuery' => 'none'
  // 'exactOnSingleWordQuery' => 'word'
]);

Override default exact ranking criterion computation on single word query for the current search#

1
2
3
4
5
$results = $index->search('query', [
  'exactOnSingleWordQuery' => 'none'
  // 'exactOnSingleWordQuery' => 'attribute'
  // 'exactOnSingleWordQuery' => 'word'
]);
Did you find this page helpful?
PHP v3