Operators
Operators are used to specify how a certain input needs to be parsed. They tell the software what syntactic constructs are supported in a certain input box.
When specifying an input element in a form, you must specify a set of operators in the syntax attribute. For example, assume that the following operators are defined (in the operators section):
<operator name="AND" middle-string="AND" logic="and" precedence="1" /> <operator name="OR" middle-string="OR" logic="or" precedence="2" /> <operator name="site" middle-string="site:" field="host" /> <operator start-string="(" end-string=")" logic="bracket" name="()" />
An input tag in a form is defined as follows:
<input name="q" field="query" logic="all" syntax="AND OR site ()"</input>
This means that:
- By default, this input box will query the query field (which we use as a default full-text field), request all the terms in the box, and use the q CGI parameter.
- The logical operators AND and OR (AND having precedence over OR) are supported, as well as parentheses. Operators with higher values for the precedence attribute take priority over those with lower values.
- The site: operator can be used to query the host field.
As a consequence, using this input definition, the following conversion will occur. The following input:
<param name="q" value="(A OR (B AND C)) site:z.com" />
would result in the following internal query:
<operator logic="and"> <operator logic="or"> <term str="A" field="query" /> <operator logic="and"> <term str="B" field="query" /> <term str="C" field="query" /> </operator> </operator> <term str="z".com" field="host" /> </operator>
If the input is part of an "input" form, the conversion will occur from left to right. When part of a source form, the conversion will occur from right to left. In the latter case, this input box won't be able to support a not syntax or any other fields except host and query.
Whenever you create a form using the Standard Form template, a list of checkboxes (corresponding to the list of operators defined in the operators section) will allow you to quickly select which operators are supported.
To extend this list, just go to the operators section and create new operators. See the online schema documentation for a complete specification of operators.
Operators will behave differently depending on the type of logic being used. This is because some forms of logic handle query information differently. For example, when using phrase logic in a query, any preceding or trailing white space is retained. That means that the phrase " my phrase " is not considered the same as "my phrase". To produce alternative behavior (for example, consistent operator functionality regardless of logic), a query modification macro should be used.