replaceSynonymsInHighlight
false
'replaceSynonymsInHighlight' => 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
Whether to highlight and snippet the original word that matches the synonym or the synonym itself.
For example, let’s say you set up home
as a synonym for house
, and the user types home
.
Synonym logic will match any record that contains ‘house’ with the synonym ‘home’.
This setting will replace the word ‘house’ with ‘home’ in the response. The effect
of this is that all highlighting and snippeting will be on the synonym ‘home’.
Without this setting, the original word ‘house’ would have been returned and highlighted and snippeted.
Usage notes
-
When true, highlighting and snippeting will use words from the query rather than the original words from the objects.
-
When false, highlighting and snippeting will always display the original words from the objects.
-
Multiple words can be replaced by a one-word synonym, but not the other way round. For example, if “NYC” and “New York City” are synonyms, searching for “NYC” will replace “New York City” with “NYC” in highlights and snippets, but searching for “New York City” will not replace “NYC” with “New York City” in highlights and snippets.
Examples
Set default synonyms highlights replacement mode
1
2
3
$index->setSettings([
'replaceSynonymsInHighlight' => false
]);
Override default synonyms highlights replacement mode for the current search
1
2
3
$results = $index->search('query', [
'replaceSynonymsInHighlight' => true
]);