optional

Purpose

The function optional() is used to specify that the argument is not required and can be skipped while searching.

This function can only be used inside sequence search functions (phrase(), follow(), near(), snear(), sfollow(), sentence(), paragraph(), pattern()) or with and operator.

Syntax

optional(argument)

Arguments

The function accepts single argument.

Returned Value

Documents matching the query.

Examples

phrase(production, of, optional(lemma(adjective)), lemma(noun_genitive)) matches «production of crude oil», «production of synthetic drugs», «production of finished goods», as well as «production of aluminium», because the presence of an adjective in the sequence is not obligatory;

optional(lemma(adjective)) is an incorrect query because the optional() function is not used inside a sequence search function or with and operator;

phrase(optional(produce, construct), engine) is an incorrect query because the optional() function can only accept one argument. The correct query would be phrase(optional(orn(produce, construct)), engine).