Skip to main content

ANALYZER()

Sets an analyzer for the fulltext search query. The analyzer applies to all nested functions which do not have an analyzer argument. If a nested function has its own analyzer, then that analyzer takes precedence over what you choose here.

The default analyzer is identity.

Syntax

ANALYZER(expr, analyzer)

KeyTypeDescription
exprexpressionA valid search expression.
analyzerstringName of the analyzer.

Example 1

Using the ANALYZER() function, you can specify an analyzer type. For example:

FOR doc IN viewName
SEARCH ANALYZER(doc.text == "bar", "text_en")
RETURN doc

The second argument in the ANALYZER() function specifies a text_en analyzer. The expression doc.text == "bar" must be wrapped by the ANALYZER() function. Otherwise, the expression would be evaluated with the default identity analyzer.

Example 2

In the following query, the search expression is swapped by ANALYZER() to set the text_en analyzer for both PHRASE() functions:

FOR doc IN viewName
SEARCH ANALYZER(PHRASE(doc.text, "foo") OR PHRASE(doc.text, "bar"), "text_en")
RETURN doc

Without a specified ANALYZER():

FOR doc IN viewName
SEARCH PHRASE(doc.text, "foo", "text_en") OR PHRASE(doc.text, "bar", "text_en")
RETURN doc

Example 3

In this example, ANALYZER() sets a default text_en analyzer. In the nested function that searches for bar, the identity analyzer overrides the higher-level choice.

FOR doc IN viewName
SEARCH ANALYZER(PHRASE(doc.text, "foo") OR PHRASE(doc.text, "bar", "identity"), "text_en")
RETURN doc