On Mon, Mar 30, 2015 at 3:55 PM, Fredrik Boström <
fbos...@gmail.com> wrote:
> Maybe I expressed myself a bit unclearly. I'm not trying to reinvent SQL or
> create a new database implementation, that's insane!
Okay. Maybe I jumped the gun a bit too; I've seen lots of zealous
people, at the stage where they "know enough to be dangerous", head
down such a path. :-)
> What I'm after is a way to
> do more complex filtering of the result set using query parameters than what
> ActiveRecord now supports.
Perhaps you could take query params that included embedded ANDs and
ORs and some parentheses, and pass them off to some gem that can
handle that on each field. So, you would wind up with a URL like:
GET /api/users?name=Doris OR Fred&location=Stockholm&hobbies=horseback
OR swimming
Then, inside your controller (or better yet, User.search method or
UserSearch.call or whatever), have it take whatever searchable params
were given and hand them off to, say, Solr or ThinkingSphinx or
whatever.
Or-ing THOSE together, so as to look for anyone who's in Stockholm OR
is interested in horseback or swimming, is another story. I think you
can do that with Solr (been a while since I've used it) but of course
the handling and syntax would be different.
In summary, check out the assorted search gems, especially full-text
search, see what they can do for you, and base your syntax on what can
be easily broken up into the kinds of pieces your preferred search gem
expects.
-Dave