Can Otter API do composite logical AND OR query searches?

48 views
Skip to first unread message

Ed

unread,
Mar 21, 2012, 1:06:40 AM3/21/12
to Otter API to Topsy
I would like find all Topsy tweets based on composite logical
statement. For example:

"Mexico" AND ( "earthquake" OR "quake" OR "aftershock")

which is equivalent to:

"Mexico" AND "earthquake" (e.g. say this returns 10 tweets)

plus

"Mexico" AND "quake" (e.g. say this returns 20 tweets)

plus

"Mexico" AND "aftershock" (e.g. say this returns 30 tweets)

so I would have a total of 60 tweets.

As far as I can tell, I will have to do three separate Otter API
queries instead of one.

Thanks

Ed







vanessa

unread,
Mar 21, 2012, 8:39:43 PM3/21/12
to otte...@googlegroups.com
We don't allow nested Boolean operators, but instead read them in order, left to right. You can get the results you need, expanding with Boolean algebra laws:

A AND (B OR C) = (A AND B) OR (A AND C)

This way you can just use 1 query: Mexico AND earthquake OR Mexico AND quake OR Mexico AND aftershock

However, it is not true that you get 60 tweets if the individual queries were 10, 20, 30. Some of the results could have 'Mexico', 'earthquake' and 'quake' all together, in which case, they only get counted once in the composite query (and would get double counted with the separate calls).

Since our search goes not just through tweet text, but also link title/description, it is likely that a result will have 'Mexico' and 2 or all of the other 3 words appear together.

hth, -vh

Ed

unread,
Mar 22, 2012, 1:52:16 PM3/22/12
to Otter API to Topsy
Thanks Vanessa for clearing this up for me and your suggestions ! I
think you just save me lines of code and faster performance :-)
Reply all
Reply to author
Forward
0 new messages