Twitter – Order of Operations for AND and OR in Boolean Search

searchtwitter

How does Twitter search interpret the order of boolean operators?

Does it support parentheses for clarifying the order of Boolean operators?

If one does a search like

A AND B OR C AND D 

what does Twitter actually search?

1: A AND (B OR (C AND D)) ?

or

2: (A AND B) OR (C AND D) ?

or

3: A AND (B OR C) AND D ?

or

4: ((A AND B) OR C) AND D ?

or something else?


I can now confirm that the answer of @w3d is correct, i.e., if you so a search like

A B OR C D OR E F

it is actually interpreted as

(A AND B) OR (C AND D) OR (E AND F)

Best Answer

Does it support parentheses for clarifying the order of Boolean operators?

It does appear to, although I've not found anything in the help docs to support this.

If one does a search like A AND B OR C AND D

OR appears to have a higher precedence than AND (which I'm not even sure is an operator - see below), so this would seem to be equivalent to your #3:

3: A AND (B OR C) AND D

And this returns the same (or very similar) results for me. Placing the parentheses differently returns very different results. I say "similar", because... (and this is an assumption) including parenthesis occasionally returns marginally different results, but I have put this down to the very dynamic nature of Twitter searches. Searching for the same phrase just minutes apart can return different results and then a few minutes later the same results again. (?)

However, as mentioned, I'm not convinced that AND is actually an operator. "and" is the default operator when words are separated by a space. There is no mention of an AND operator on the Twitter Advanced Search Help page. And omitting AND yields the same results. It is quite possible that "AND" is simply stripped from the search phrase as being a "common" word. A AND B OR C AND D is equivalent to A B OR C D