2.2.11.8 Text Expression

The protocol server MUST interpret text expressions as a sequence of one or more text restrictions joined implicitly (without AND, OR, +, or - operators between them) or using operators AND and OR.

If there are no operators between restrictions, the protocol server MUST interpret an expression depending on the value of the ImplicitAndBehavior element in the QueryPacket. If the ImplicitAndBehavior element is set to "true", then the text expression MUST match the item if every restriction is matching the item. If the ImplicitAndBehavior element is set to "false" and the query string does not contain any of the operators AND, OR, NOT, NEAR, or WORDS, then the expression MUST match the item if the item contains any unqualified tokens and all other restrictions match the item. If any of the preceding operators are used in the query string then the protocol server MUST interpret the expression as if the ImplicitAndBehavior element was set to "true".

The protocol server MUST allow a restriction to be negated by using the NOT operator.

The protocol server MUST use the following rules to match the text expression against the items:

  • When AND operator is used, the expression matches the item if both restrictions on the left and right of the operator match the item;

  • When OR operator is used, the expression matches the item if any one or both restrictions on the left and right of the operator match the item;

  • When NOT operator is used, the expression matches the item if the restriction does not match the item;

The ordering of priority is explicitly expressed by the following grammar rules. NOT has highest priority, then AND, then OR, and an implicit join has the lowest priority.

 text-expression = text-or-expression
 text-expression =/ text-expression *ws text-or-expression
 text-or-expression = text-and-expressionCommon
 text-or-expression =/ text-or-expression *ws or-operator *ws text-and-expression
 text-and-expression = text-not-expression
 text-and-expression =/ text-and-expression *ws and-operator *ws text-not-expression
 text-not-expression = text-restriction
 text-not-expression =/ not-operator *ws text-restriction