exactOnSingleWordQuery
'exactOnSingleWordQuery' => 'attribute'|'none'|'word'
Can be used in these methods:
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
browse,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
browse,
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
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
searchAsync,
setSettingsAsync,
browseAsync,
searchForFacetValues
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
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
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'
]);