The following rules apply to queries of all kinds:
Queries are not case sensitive.
You can search for any word except for words on the exception list.
To use special characters in a query, (such as &, %7C, %5E, #, @, and $), enclose your query in quotation marks.
Date and time values are of the form yyyy/mm/dd hh:mm:ss or yyyy-mm-dd hh:mm:ss. The first two characters of the year and the entire time can be omitted. If you omit the first two characters of the year, the date is interpreted as being between 1930 and 2029. A 3-digit millisecond value can be specified after the seconds value. All dates and times are in Coordinated Universal Time. For example, 1997/12/8 13:10:03:452
Notes
Dates and times relative to the current date and time can be expressed with a minus sign (-) followed by one or more integer unit and time unit pairs. Time units are expressed as: y for years, q for quarters (three months), m for months, w for weeks, d for days, h for hours, n for minutes, and s for seconds.
Numeric values can be in decimal or hexadecimal. Hexadecimal values are preceded by "0x."
Contains and Equals operators
Use the CONTAINS operator to search for any word or phrase within a particular property. If no operator is specified, the CONTAINS operator is assumed.
The following queries are equivalent:
@DocTitle "the red dog"
@DocTitle Contains "the red dog"
The following table illustrates the use of the CONTAINS operator in both long and short form.
Long form Short form
%7Bprop name=DocTitle%7D Contains %7Bphrase%7Dthe red dog%7B/phrase%7D%7B/prop%7D @DocTitle"the red dog"
A document whose title property value is "The story of the red dog" would satisfy both of these queries.
The EQUALS operator specifies that the value of the property must exactly match the word or phrase in the query. The long form of the operator is EQUALS. The short form is the equal sign (=).
For example:
@DocTitle = "the red dog"
Only a document whose Title property value is "the red dog" will satisfy this query. Indexing Service would not return a document with the title "The story of the red dog" because it contains words that are not in the query.
Notes
To search for the word "contains" or "equals," you must use quotation marks.
In Indexing Service, the query @contents = text is invalid.
Boolean operators
You can use the Boolean operators AND, OR, and NOT in both content and property queries. The Boolean operator NEAR can be used only in content queries. You can use Boolean operators in both long-form and short-form queries.
When you use the NEAR operator in a query, a document matches the query if the words are within 50 words of each other in the document. The closer together the words are, the higher the rank that is assigned to the document in the result set. If the words are more than 50 words apart, they are not considered near enough, and the document is assigned a rank of zero. The NEAR operator can be applied only to words or phrases.
In content queries, use the NOT operator only after the AND operator. Use the NOT operator only to exclude documents that match a previous content restriction. For property-value queries, the NOT operator can be used apart from the AND operator.
The following table explains the Boolean operators and their associated symbols.
Operator Long form Short form
AND AND &
OR OR %7C
NOT AND NOT &!
NEAR NEAR Near, %7E
Boolean operators are available only in English.
The following table shows some examples of the use of Boolean operators:
To search for Long form Short form Result
Two terms in the same document red and dog red & dog Documents with both the words "red" and "dog"
Either of two terms in a document red or dog red %7C dog Documents with the words "red" or "dog"
One term without a second term red and not dog red & ! dog Documents with the word "red" but not "dog"
Documents not matching a property value not %7Bprop name=size%7D = 100 ! @size = 100 Documents that are not 100 bytes
Two terms that are close together in the same document red near dog red %7E dog Documents with the word "red" near the word "dog"
Either of two terms and not two other terms if they are close together red or dog and not (black near cat) red %7C dog &! (black%7Ecat) Documents with the word "red" or "dog" and not the words "black" and "cat" if they are within 50 words of each other
Note
Use quotation marks around the query phrase if it contains a word that is a Boolean operator. For example, "horse and rider" will be evaluated as a phrase, not as a Boolean expression.
Order of precedence rules
Boolean operators are evaluated in the following order:
NOT
AND or NEAR
OR
After precedence rules are applied, operators are processed left to right. You can use parentheses (( )) to override the normal precedence. For example, the first three queries are equivalent, but the fourth is not:
a AND b OR c
c OR a AND b
c OR (a AND b)
(c OR a) AND b
In the fourth query, the OR operator is evaluated first because the expression is enclosed in parentheses.
Free-text and phrase queries
Free-text queries
With free-text queries, you can enter a group of words or a complete sentence. Indexing Service finds pages that best match the words and phrases in the free-text query. It does this by finding pages that match the meaning, rather than the exact wording, of the query. Indexing Service ignores Boolean, proximity, and wildcard operators.
You can use free-text queries to search both contents and property values. If you submit only the query text without specifying the type of query or the property, Indexing Service uses the free-text query and the Contents property by default.
The following queries return documents that contain text that most nearly matches the phrase, "How do I print in Microsoft Excel?"
Long form Short form
%7Bfreetext%7D %7Bprop name=contents%7D How do I print in Microsoft Excel? How do I print in Microsoft Excel?
Or
$contents How do I print in Microsoft Excel
Phrase queries
To search for a phrase, either enclose it in quotation marks or precede it with the %7Bphrase%7D tag. Words in a phrase query must appear in document in the order entered, with no intervening words.
The following expressions are equivalent:
%7Bphrase%7D big red truck %7B/phrase%7D
"big red truck"
When the phrase tag is used, the sequence and position of the words are significant in determining whether a document matches the query. The %7Bphrase%7D and %7Bfreetext%7D tags are mutually exclusive and cannot be embedded or nested. Phrase queries can be used to search both contents and property values.
The following table provides examples of the long and short forms of the phrase tags.
Long form Short form
%7Bphrase%7D big red truck %7B/phrase%7D "big red truck"
Note
In phrase queries, words on the exception list are treated as place holders. For example, if you searched for "Word for Windows", the results could give you "Word for Windows" and "Word and Windows", because "for" appears in the exception list.

