SiteScripter Help

Friday, November 21, 2008

Searching - Order of Evaluation

In general, the order of evaluation is not important. The search terms are processed from left to right. Parenthesis can be used to group searches together, effectively changing the order of evaluation. For example these three are the same:

juliet not ophelia helena
not ophelia juliet helena
helena juliet not ophelia

but these two are not the same:

juliet not ophelia helena
juliet not (ophelia helena)

The first finds all pages that contain both "juliet" and "helena", but do not contain "ophelia". The second finds all that contain "juliet", and contain either "ophelia" or "helena", but not both.

It is often helpful in understanding searches to use the boolean terms and parenthesis. So the above two become:

juliet AND (not ophelia) AND helena
juliet AND (not (ophelia AND helena))

These four examples are all the same search:

juliet not ophelia and helena
(juliet) AND (NOT ophelia) AND (helena)
juliet not ophelia helena
helena and juliet and not ophelia

Looking at the the first three searches, all the pages with "juliet" are found first. Then all pages that do not contain "ophelia" are found. Those two lists are then combined with the boolean AND operator resulting with a list of pages that include "juliet" but not "ophelia". Finally, that list is ANDed with the list of pages that contain "helena".

However it is always possible to force the order of evaluation by using parenthesis. For example:

juliet not (ophelia and helena)

retrieves pages with "juliet" that do not contain both words "ophelia" and "helena".