API Reference / API Parameters / advancedSyntaxFeatures
Feb. 26, 2019

advancedSyntaxFeatures

Type: list of strings
Engine default: ["exactPhrase", "excludeWords"]
Parameter syntax
'advancedSyntaxFeatures' => [
  'exactPhrase',
  'excludeWords'
]

Can be used in these methods:

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. Example.

  • Or you can allow users to exclude words (with a ‘-‘) but not do exact phrasing. Example.

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 having search next to engine.

    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 containing search but not engine.

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']
]);

Did you find this page helpful?