kidpollo / tanker

IndexTank Integration with your fav ORM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any way to search multiple models with conditions?

usctrojan opened this issue · comments

I'm trying to search multiple models with conditions like so:

@results = Tanker.search([Topic, Post], 'blah', :conditions => "topics.public is true")

The results I got didn't filter the results based on conditions (i.e. the results still searched for all topics instead of just public topics). I also tried using named scopes too:

@results = Tanker.search([Topic.public, Post], 'blah')

...but got an undefined method "per_page" error. How would I search multiple models with conditions correctly (if at all possible)?

Conditions in tanker dont work as SQL association filterings, its more based on the way Index Tank Supports filtering, assuming you are indexing the public attribute public you could do something SIMILAR TO :condtiotions => {'NOT public' => '1'}

I dont know what do you mean by named scopes in de contxt of indexing your models. Indextank is a full text search service not a relational database system. Checkout the indextank ducumentation or even play around with the raw api so you can have an idea of what can be done.

Oh okay, awesome. Thanks for the clarification, kidpollo. I appreciate the info!