advancedSyntaxFeatures
'advancedSyntaxFeatures' => [ 'exactPhrase', 'excludeWords' ]
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
Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is enabled.
By default, when advancedSyntax
is set to true,
all advanced syntax features are enabled.
With this setting, you can disable one or more advanced syntax features.
-
For example, you can allow users to do exact phrasing (putting words within quotes), but not allow them to exclude words.
-
Or you can allow users to exclude words (with a ‘-‘) but not do exact phrasing.
See advancedSyntax
for more information on its features and usage.
Options:
-
exactPhrase: A specific sequence of terms that must be matched next to one another. A phrase query needs to be surrounded by double quotes (
"
). For example,"search engine"
will only match records havingsearch
next toengine
.Note: Typo tolerance is disabled inside the phrase (i.e. within the quotes).
-
excludeWords: Excludes records that contain a specific term. This term has to be prefixed by a minus (
-
). For example,search -engine
will only match records containingsearch
but notengine
.
Examples
Enable all features (the default)
1
2
3
$index->setSettings([
'advancedSyntax' => true
]);
Enable only exact phrase
This example will allow users to use exact phrasing within quotes but not exclude words.
1
2
3
4
$results = $index->search('query', [
'advancedSyntax' => true,
'advancedSyntaxFeatures' => ['exactPhrase']
]);
Enable only exclude words
This example will allow users to exclude words but not do exact phrasing.
1
2
3
4
$results = $index->search('query', [
'advancedSyntax' => true,
'advancedSyntaxFeatures' => ['excludeWords']
]);