beautypg.com

Nested boolean filtering using meta tags – Google Search Appliance Protocol Reference User Manual

Page 45

background image

Google Search Appliance: Search Protocol Reference

Request Format

45

Boolean AND [ . ]

Returns results that satisfy both meta tag constraints.

Example: author:William.author:Jones

Combined OR and AND with [ ( ) ]

Evaluates conditions in parentheses first: (department=Sales OR department=Finance) AND
(author=Williams OR author=Jones).

Example: (department:Sales|department:Finance).(author:William|author:Jones)

Boolean operators are left associative with equal precedence. You can use parentheses to change the
order of precedence. For example, A . (B | C | D) evaluates the OR (|) operators in the parentheses
before the AND (.) operator. It is advisable to use brackets, braces, or parenthesis to clarify the
precedence in complex queries.

Nested Boolean Filtering Using Meta Tags

Using the Google Search Appliance, the user can search over the meta tags in documents by writing
complex queries using AND, OR, NOT operators nested within each other. Using nested metadata
queries gives the user more power with the expressive capabilities of search requests.

Arbitrarily nested boolean queries can be written using requirefields and partialfields in
conjunction with AND (.), OR (|), and NOT (-) operators. However, there is no way to specify range search
with requirefields and partialfields, as noted. Nested boolean queries cannot be used with
inmeta. Because precedence cannot be specified in the search box, when you use inmeta, the normal
precedence operators take over and the query is executed. However, a single query can include both
inmeta for range search and a nested boolean statement using requirefields and partialfields.

Before executing a search, the search appliance simplifies the search query by pushing NOTs down the
query tree. This process is an application of De Morgan’s Laws and Double Negation Elimination. As a
result of this process, if there are any NOT nodes in the query, they are just above the leaf nodes.

For example, consider the following query:

NOT (a OR b)

The following simplified query is the result of pushing NOTs down the query tree. The NOT nodes are
above the leaf nodes:

(NOT a) AND (NOT b)

Not all combinations of operators are valid for searches. The following queries in a simplified query tree
are invalid:

A query in which there is any OR node with even a single child as a NOT node.

A query in which there is any AND node with all children as NOT nodes.

The following table contains examples of invalid queries.

Query

Simplified Query

Reason

NOT(a OR b OR c)

(NOT a) AND (NOT b) AND (NOT c)

Invalid because AND has 3 children (NOT
a, NOT b, NOT c) and all are NOT’ed

a OR b OR NOT
(NOT (NOT c))

a OR b OR (NOT c)

Invalid because OR has one child, which is
a NOT