Searching with the Boolean operators AND and OR

You can combine search terms with other search terms using the Boolean operators "&" (AND) and "|" (OR):

SELECT AUTHOR, TITLE
        FROM DB2EXT.TEXTTAB
        WHERE CONTAINS(COMMENT, 
                              '"author" | "pulitzer"') = 1

You can also combine several terms by using Boolean operators:

SELECT AUTHOR, TITLE
        FROM DB2EXT.TEXTTAB
        WHERE CONTAINS(COMMENT, 
                       '"author" | "pulitzer" & "book"') = 1

If you use more than one Boolean operator, these are evaluated from left to right. However, the logical AND operator (&) binds stronger than the logical OR operator (|). You can see this evaluation in the following example, which does not include parentheses:

"book" & "pulitzer"| year" & "author"

Therefore, Net Search Extender evaluates the boolean operators in the following way:

("book" & "pulitzer") | (year & "author")

So, to correctly evaluate the boolean operators, you must include parentheses:

"book" & ("pulitzer" | year") & "author"

You can also combine Boolean operators with search terms that are chained together using the comma separator:

("author", "pulitzer") & "book"

In this case, however, the comma is interpreted as a Boolean OR operator:

("author"| "pulitzer") & "book"

For additional information, also see Searching with the Boolean operator NOT.