Boolean Tips

Operator Syntax Description Prece- dence
( ) (word1 | word2) & word3 Parentheses can be used to overide the precedence of other operators and can be nested to any depth. 1
not, ^ not word1 ^word1 word1 must not be found in the document. 2
and, &, but word1 and word2
word1 & word2
word1 but not word2
word1 word2
Both word1 and word2 must be found in the documents. If no operator is present between two query terms, and is the default. 3
within word1 word2 within N word1 must be found within N words of word2 4
adj word1 word2 adj N word1 must be found within N words of word2, and word1 must come before word2 4
between word1 between word2 and word3 word1 must be found between word2 and word3. 4
or, |   either word1 or word2 must be found in the document. 5

The BUT operator means the same as the AND operator, and is typically used in conjunction with NOT("this BUT NOT that", or "this AND NOT that").

AND/OR: In Boolean queries, the use of AND is assumed; the use of OR must be stated within the query. For example if you enter electronic communication as your query, the Query program will search for documents containing both of these words and won't return any document that doest not contain both words. If you enter electronic or communication as your query, the Query program will search for documents containing either of those words.

NOT: If your query may produce related responses you are not interested in, use
NOT to eliminate responses you won't want. For example:

   bill clinton not hillary

   automatic or not manual

   not wsj and not ap and not reuters

WITHIN: You can use the WITHIN phrase in Boolean queries to increase precision through proximity constraints. The WITHIN phrase specifies that certain words must appear within so many words of each other. The WITHIN number represents the number of "jumps" required to get from one word to the next.

For example:

   network and security within 1

finds network and security adjacent to one another. Likewise:

   network and security within 3

finds network and security with two intervening words.

The WITHIN operator will also work with a longer search string. For example: network and security and virus and password within 50

This query would return documents that contain all four of these terms within a 50 word span.

ADJ: The adjacency operator tests word proximity like the WITHIN operator does, but also check that the two words are in order. For example:

   faberge and egg adj 5

This query checks that the two words appear within 5 words of one another, and that "Faberge" comes first.

NESTED STATEMENTS: Enclosed within parentheses, nested statements can also improve accuracy:

   (voting and record) and ("house of representatives" or house)
   and (members) within 50.

This query returns documents containing the voting records of members of the House of Representatives. If you want the WITHIN operator to apply to only part of the search string, structure the query so that the word WITHIN falls inside the parentheses.

BETWEEN: Use the BETWEEN operator to search for text between any two other terms. This feature enables you to find information in certain parts of a document(e.g.title,body,etc) even when no fielded search is available. The form is:

   x between b and c

where x is the expression inside the b and c expressions. You must have one expression to the left of the BETWEEN operator, and two expressions to the right of it. If you do not type AND, the system will assume AND is the operator.

For example:

   3/11/99 between date and subject

The above query would return documents where the date "3/11/99" falls somewhere after word "date", but before the word "subject".

Images in the news

Day in pictures
Day in pictures | Today's Sun photos | Search
Entertainment photos | Sports photos

Caption Call
We post the photo, you write a funny caption for Mr. T's new career

Ravens training camp
The Ravens prepare for the season at McDaniel College in Westminster
THINGS TO DO
Plein Air- Easton
Observe artists and artisans, purchase their works and more through July 27.
Search events

RECENT BLOG UPDATES FROM THE BEACH LIFE

FROM B, THE PAPER
School of Rock
A playlist of popular music that has fueled anti-school rebellion

RECENT BLOG UPDATES FROM BTHESITE.COM
FEATURED GALLERY
Artscape
Share photos from the annual arts festival in the city.

FEATURED USER
Susansz
This picture was taken on the beach in Ocean City.


Reader videos | Talk forums | Trivia quizzes

Today's columnists

Columnists: News | Sports | Business | Lifestyle

About our coverage

The Sun is committed to publishing information quickly and accurately. We take our readers' concerns seriously and will promptly investigate when we are alerted to possible errors.
• To report an error, use our feedback page.
• To submit questions to Sun reporters and editors, visit Under The Sun, a blog offering insight into how decisions are made at The Sun.