Basic Boolean Query Tutorial

Boolean query is a type of search allowing you to combine keywords or phrases with operators such as AND, NOT and OR to further produce more relevant results. For example, a Boolean query could be "book" AND "Harry Potter". This would limit the search results to only those documents containing the two keywords.

Boolean Query Operator: AND

Use AND to narrow your search: all of your search terms will present in the retrieved documents.

Example: Phone AND Battery AND Screen AND Apple

A space is an “implied AND,” and you don’t have to type it, as every blank space is interpreted as an AND operator.

Example: Phone Battery Screen Apple

Boolean Query Operator: OR

The OR operator broadens your search results by connecting multiple keywords or phrases. The OR operator is interpreted as “at least one is required, more than one or all can be returned.”

Although it isn't require to encapsulate OR statements with parentheses, if you don’t your search will run but execute in a way that you probably did not intent. As a best practice, you should always use parentheses around OR statements as a matter of good search syntax.

Example: Phone AND Battery AND Screen AND (Apple OR Android OR Blackberry)

The returned results must mention at least one of the following: Apple, Android, Blackberry. However, if a document mention 1 or all 3, it will be returned.

Boolean Query Operator: NOT

Use NOT to exclude term(s) from your search results.

Example: "higher education" NOT "community colleges"

Using Multiple Query Operators

Basic example:

  • (Smartwatch OR "Smart Watch") AND Best
  • (Smartwatch OR "Smart Watch") AND ("Best" OR "Excellent")
  • (Smartwatch OR "Smart Watch") AND ("Best" OR "Excellent") AND NOT (Microsoft OR Blackberry)

Asterisk Wildcard

You can use an asterisk (*) in the place of a character in your search term to indicate that any number of characters can be substituted in place of the asterisk.

For example: admin* will return: administrator, administration, administer, administered, etc.

The asterisk is a time saver because it saves you from creating long OR statements and having to think of every way a particular word can be expressed.

Parentheses

Use parentheses to encapsulate OR statements for the search engines to execute them properly.

The OR operator is interpreted as "I would like at least one of these terms."

For example: (apache OR weblogic OR websphere)

If you don’t enclose all of your OR statements, your search may run but it will NOT run as intended.

Quotation Marks

Quotation marks must be used when searching for exact phrases of more than one word, or else you may get documents with the phrase split up into single word components.

For example: Nobel Prize Winners 2010

Your results could bring back pages that have Nobel Prize, winners of prizes, 2010 winners of prizes, 2010 winners of prizes..and the list goes on. Probably not what you were hoping for, to say the least.

However, using quotation marks around your phrases takes care of this problem. When you use quotation marks around a phrase, you are telling the system to only bring back pages that include these search terms in this exact order. For example:

"Nobel Prize Winners 2010"

Your search results now will only bring back pages that have all these words in the exact order that you typed them in.

Disable Stemming

Stemming is the process of reducing inflected (or sometimes derived) words to their word stem, base or root form. For example, if the user enters "viewer" as the query, the search engine reduces the word to its root ("view") and returns all documents containing the root - like documents containing view, viewer, viewing, preview, review etc.

To disable stemming, just append the dollar sign ($) to the end of the keyword. For example, searching for the keyword "simplivity" will also return documents containing the word "simple" since we index the stemmed version of the verb, but if you want to find documents that contain "simplivity" and nothing else, search for "simplivity$".

Basic Boolean Query Tutorial


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.