Default Keywords and Operators
| Keyword or Symbol | Definition | Alternate Representation(s) | Canonical XML Representation |
|---|---|---|---|
| By default all terms or expressions must be matched in the results. | AND, and |
<operator logic="and> ... </operator> |
|
| "" | Enables you to group individual terms into phrases that will be searched for as a unit, as in "document clustering" |
No operator for this, it just means that the whole expression is part of a single term: <term str="document clustering" field="query" phrase="phrase"/> The phrase attribute is only important for non-segmented languages. It means that the user intended this term as a strict phrase (without it the term will be segmented and the multiple parts of the segmentation may end up being interpreted as an AND or a NEAR instead of a phrase). |
|
| () | Enables you to group expressions in order to guarantee precedence, as in document AND (cluster OR clustering) | Precedence is handled naturally by the XML tree structure. | |
| * | Wildcard operator that can be replaced by any number of characters. This can be either passed as an operator to the sources or expanded when the meta.wildcard-expand option is turned on. For example, *boat might be replaced by boat OR motorboat OR sailboat OR speedboat. |
<term str="*boat" field="query"> <operator logic="wildcard" char="*"/> </term> |
|
| ? | Wild character operator that can be replaced by any single character. This can be either passed as an operator to the sources or expanded when the meta.wildcard-expand option is turned on. For example, bo?t will be replaced by boat OR boot, where the latter is the German word for boat used in some nautical references. |
<term str="bo?t" field="query"> <operator logic="wildchar" char="?"/> </term> |
|
| $ | Unstemming operators, for example boat$ will be replaced by boat OR boats OR boating. This can be either passed as an operator to the sources or expanded when the meta.stem-expand option is turned on. |
<term str="boat$" field="query"> <operator logic="stem" char="$"/> </term> This is not natively supported by the Watson™ Explorer Engine search engine. |
|
| + | Must operator. Forces the use of a keyword, Tom +and Jerry will actually search for the keyword and |
<operator logic="must"> <term field="query" str="and"/> </operator> must is ignored by the Watson Explorer Engine search engine (it is just the same as having the term by itself). |
|
| BEFORE | The specified term or expression must appear before another term or expression in the search results, as in document BEFORE clustering. | FOLLOWEDBY, THRU |
<operator logic="thru"> <term str="document" field="query"/> <term str="clustering" field="query"/> </operator> |
| field: |
Enables you to restrict your query to a specific field, as in author:smith or title:"war and peace". These operators are activated for every field defined in your syntax (see the fields section). By default, the Watson Explorer Engine search engine supports the title field. When creating a search collection, you can extract for each document any number of contents and map these contents to searchable fields (this is specified in the form of the source associated with each collection). |
<term str="smith" field="author"/> <term str="war and peace" field="title"/> |
|
| NEAR | Both terms or expressions must be matched in the results with a certain proximity (for the Watson Explorer Engine search engine this is 32 words but this may vary for third party sources). It can be applied to any number of sub-expressions, e.g., (war AND peace) NEAR (novel OR book) | WITHIN 32 WORDS |
<operator logic="near"> ... </operator> |
| NOT | The specified term or expression must not be matched in the search results | NOT, - |
<operator logic="not"> ... </operator> |
| OR | Either term or expression must be matched in the results |
<operator logic="or"> ... </operator> |
Operators are defined at .
Operators which have been defined can be enabled at .
Operators have precedence, for example, if you look at the definition for the operators in , you will see that "or" has a precedence of 2, "OR" has a precedence of 0, and "AND" has a precedence of 1. Operator precedence is configurable. If you give "or" a precedence of 0, then your two logic:or operators will have the same behavior.
The difference that operator precedence makes can be seen by comparing queries like the following:
[a or b AND c] is parsed as [(a or b) AND c] because "or" has a higher precedence than "AND".
[a OR b AND c] is parsed as [a OR (b AND c)] because "AND" has a higher precedence than "OR".
For more information, see Comparison Operator Support and XPath Operator Support