Knowledge Search


×
 

Searching the KB using Boolean operators

  [KB19246] Show Article Properties


Summary:
Information on how to use boolean operators in the KB search
Symptoms:
Information on how to use boolean operators in the KB search
Solution:
The expected behavior for the Boolean operators and their arguments is as follows:
  1. There are three Boolean operators: OR, AND, NOT. The NOT operator can also be written as AND NOT. They must be in all caps in the query.

  2. A query which does not contain a Boolean operator triggers a search on that string as described in (4) below.

  3. When an operator joins two arguments, the resulting phrase has the following interpretation:
    • a OR b: Retrieve all documents containing either a or b or both.
    • a AND b: Retrieve all documents containing both a and b.
    • a NOT b: Retrieve all documents containing a but not containing b.

  4. When a string of tokens is an argument for a Boolean operator, the string has the following properties:
    • A string with no double quotes is interpreted as both that string and any of its inflected forms.
    • A string with double quotes around it is interpreted as just that exact string. *[Note – we’ve customized this component so it is not as strict]
    • A string with multiple tokens is always interpreted as a unit; the individual tokens will not be taken into consideration when conducting the search.


It is also possible to use more than one Boolean operator in a single query, such as “a NOT b OR c”. In these cases the NOT operator takes precedence over AND and OR, while AND takes precedence over OR. Linear precedence does not influence operator precedence. Thus the queries below have the interpretations indicated by the parentheses:
x AND y NOT z = x AND (y NOT z)
x AND y OR z = (x AND y) OR z
x OR y NOT z = x OR (y NOT z)
x OR y AND z = x OR (y AND z)
x NOT y OR z = (x NOT y) OR z
x NOT y AND z = (x NOT y) AND z

Using explicit parentheses in a Boolean query will override the default precedence.
Related Links: