Topic60

Topic 60
Search and the use of the Boolean operators (AND, OR and NOT) by Raymon

A search function is essential in a large database or information; not just in corporate databases, like Microsoft's client list, but in search indexes like Google. Which is easier, to just put in a few key words t search by in a box, or to trowel through Google's 8 billion indexed pages to find the one you need? Thus, search capabilities have naturally been introduced in many systems since the advent of personal computers.

However, just a search with one keyword is not that useful. Imagine trying to search Google for cancer in cows, but you can only use one word; neither "cancer" nor "cows" will help you very much. One could search for the exact phrase, but that is not always the best solution either. This is where Boolean operators come in. The basic Boolean values are TRUE and FALSE; Boolean operators take these values and fiddle with them.

It is fairly common knowledge that you can use or between keywords to include at least one of them and you can use "-" in front of keywords to search for pages without that word. It is not common knowledge, however, that these are what we call Boolean Operators. It used to be that we had to add "+" or "AND" in between Google keywords. This is the Boolean operator that means, not surprisingly, "and". It handles the two values next to it, and when both of them are true (Which means they exist), the entire statement is true. Now, Google adds AND automatically between all statements.

The "-" means "NOT", and this inverts the Boolean value – therefore, FALSE becomes TRUE and TRUE becomes FALSE. Thus, when the search finds a keyword, it turns out TRUE, but with NOT in front of it, it becomes FALSE. Combined with AND, this makes the whole thing false.

Finally, "or" obviously means "OR", and acts like AND, only both the statements do not have to be right; only one of them has to be right to make the OR statement true, but both the statements can be true also. There is another, less common, type of OR called XOR, or "exclusive or" which is like OR – except for the fact that exactly one of the statements has to be true. For instance, with the statement "dogs AND playing AND Frisbee OR Frisbees AND NOT ball XOR balls":

1. Dogs playing and catching Frisbees TRUE AND TRUE AND TRUE AND NOT(FALSE) = TRUE

2. Dogs playing with balls and Frisbees TRUE AND TRUE AND TRUE AND NOT(TRUE) = FALSE

3. Dogs playing with doughnuts TRUE AND TRUE AND FALSE AND NOT(FALSE) = FALSE

4. Dogs playing with Frisbees and a ball: A Frisbee is better than balls! TRUE AND TRUE AND TRUE AND TRUE AND NOT(FALSE) = TRUE

So, as one can see, Boolean operators are very important in creating rich and meaningful search functions.