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.

Table 1. Advanced search operators and complex query examples
Operators Examples Query results
AND
"King Lear" AND "Othello"
"King Lear" "Othello"
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 Othello is a synonym of Richard and a document contains King Lear and Richard, the second query will return this document. However, the first query will not return this document.

OR
"King Lear" OR Queen 
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
"Lear" 
NOT "Norman Lear" 
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:
"King Lear" 
Second query:
"king"
The first query returns the exact phrase King Lear.

The second query returns only the word king and no other forms, such as kings.

*
(Wildcard character)
mouse* 
mo*se
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:
?Lear King
Second query:
mo?se
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 moose and mouse but not the words morose or mongoose.

^
(Score boost factor)
some word or phrase^number
"King Lear"^4 "Richard III"
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 "King Lear" than the phrase "Richard III" in the list of search results.

+
(Includes)
+Lear King
Returns all documents that contain Lear and King, which is the same as the query Lear AND King.
-
(Excludes)
"Lear" -"Lear Jet"
Returns documents that contain Lear but not Lear Jet.
( )
(Grouping)
(King OR Lear) AND plays
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)
http\://www.ibm.com
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.