API Reference / API Parameters / advancedSyntax
Type: boolean
Engine default: false
Parameter syntax
'advancedSyntax' => true|false

Can be used in these methods:

About this parameter

Enables the advanced query syntax.

This advanced syntax brings two additional features:

  • Phrase query: 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, the query "search engine" only returns a record if it contains “search engine” exactly in at least one attribute.

    Note: Typo tolerance is disabled inside the phrase (i.e. within the quotes).

  • Prohibit operator: excludes records that contain a specific term. To exclude a term, you need to prefix it with a minus (-). The engine only interprets the minus (-) as a prohibit operator when you place it at the start of a word. A minus (-) within double quotes (") is not treated as a prohibit operator.

    Some examples:

    • search -engine only matches records containing “search”, but not “engine”
    • search-engine matches records containing “search” and “engine” (there’s no exclusion because the minus (-) is in the middle of the word)
    • -search matches every record except those containing “search”
    • -search engine matches records containing “engine”, but not “search”
    • "-engine" matches records containing “-engine” (no exclusion performed)

Examples

Enable advanced syntax by default

1
2
3
$index->setSettings([
  'advancedSyntax' => true
]);
1
2
3
$results = $index->search('query', [
  'advancedSyntax' => true
]);
Did you find this page helpful?