Advanced search operators
You can use advanced search operators to refine the search results for the CONTAINS function and the SCORE function.
In the following table, the first column describes the operator that you can use in a search query. (You must enter the logical operators NOT, AND, and OR in all uppercase letters.) The second column shows a sample query that you might enter. The third column describes the types of results that you might see from the example query.
Operators | Examples | Query results |
---|---|---|
AND |
|
Either query returns documents that contain
both the
phrase King Lear and the term Othello .
The
AND operator is the default conjunction operator. If no logical operator
is
between the two terms, the AND operator is used. In
these
examples, the first query handles synonyms differently than the second
query.
If the AND operator is used explicitly, synonyms are ignored. For
example,
if |
OR |
|
Returns documents that contain
either King Lear or
just Queen . The OR operator links the two terms and
finds
a matching document if either of the terms exist in a document. |
NOT |
|
Returns documents that contain Lear but
not Norman Lear . Do not use the NOT operator with
only one
term. For example, the following search will return no results: NOT
"King Lear" . A query should contain at least one
term that is contained
in the document. |
" " (Phrase search)
|
First query:
Second query:
|
The first query returns the exact phrase King
Lear . The second query returns only the word |
* (Wildcard character)
|
|
Returns documents that
can match possible variations
of the query. For example, the query mouse* returns
matches
such as mouse and moused .
The query mo*se returns matches such as mouse , moose ,
and mongoose . |
? (Wildcard character)
|
First query: Second
query:
|
The
first query returns all documents that contain the
word King and that might contain the word Lear .
The term that follows the ? is optional for the query. In the second
query,
the ? is used as a wildcard character for a single character. For
example,
the query returns all documents that contain the words |
^ (Score boost factor)
some word or phrase^number
|
|
A boost factor influences how documents
are ranked in the search results. Documents that match query terms
with high
boost factors are ranked higher than if the boost factor was not applied. Although a boost factor must be positive, the boost factor can be less than 1. For example, 0.2. The boost factor number has no limit. This query
forces
a higher weight for documents with the phrase |
+ (Includes)
|
|
Returns all documents that contain Lear and King ,
which is the same as the query Lear AND King . |
- (Excludes)
|
|
Returns documents that contain Lear but
not Lear Jet . |
(
) (Grouping)
|
|
Returns documents that contain plays and
either King or Lear . The parentheses
ensure
that plays is found and either term King or Lear is
present. |
\ (Escape character)
|
|
Returns documents that contain http://www.ibm.com .
Use the \ to clear special characters that are part of the query syntax.
Special
characters are + - & || ! ( ) { } [ ] ^ " ~ * ? : \. If a
special character
is cleared, the special character is analyzed as part of the query. |