How to use thinking sphinx

I want to use thinking sphinx in my application, basically i have a
filter criteria screen, and depending on the user input, the sql query
is generated, which joins all the tables based on user input, now i want
to use thinking sphinx for this query,
my problem is how to pass sql query to thinking sphinx and then how to
differentiate between fields which has same name but are from different
tables(eg, id will be there in all the tables)

Check this out:

http://railscasts.com/episodes/120-thinking-sphinx

Have a look at the thinking sphinx documentation.
I believe field conditions might what you need.

http://freelancing-god.github.com/ts/en/searching.html#conditions

Konstantinos