advancedSyntax
false
'advancedSyntax' => 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,
GenerateSecuredApiKeys,
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
Enables the advanced query syntax.
The advanced query syntax parameter introduces two advancedSyntaxFeatures
:
-
Exact phrase: only return records that match the exact words you put in double quotes (
"
). For example, the query"search engine"
will only return records if the exact phrase “search engine” appears in at least one of the record’s attributes.Typo tolerance doesn’t apply to a phrase within quotes.
-
Word exclusion: to exclude records that contain a specific word. To exclude a word, prefix it with a minus (
-
). A minus (-
) within double quotes ("
) isn’t treated as an excluded word.For example:
search -engine
matches records containing “search” but not “engine”search-engine
matches records containing “search” and “engine” (word exclusion isn’t applied)-search
matches every record except those containing “search”-search engine
matches records containing “engine” but not “search”"-engine"
matches records containing “-engine” (word exclusion isn’t applied).
Algolia doesn’t have a wildcard search feature where a character such as
*
represents one or more unknown characters. You can achieve similar results with:- Partial word matching for records that start with the query characters. For example, the query “foo” will find records that contain words like “food”, “fool”, “foot”, and so on.
- Empty queries retrieve all records that match other parameters (most likely, a filter).
Examples
Enable advanced syntax by default
1
2
3
$index->setSettings([
'advancedSyntax' => true
]);
Enable advanced syntax for the current search
1
2
3
$results = $index->search('query', [
'advancedSyntax' => true
]);