How to do a "contains" search

89 views
Skip to first unread message

tallp

unread,
Dec 28, 2009, 1:12:54 AM12/28/09
to Searchlogic
I currently have Searchlogic implemented and it works great. I am
curious however if it can be used to search for the presence of
multiple words in a text_area field. For example, say I have a search
box and the user enters "uploading PDFs". I would like to search the
"answer" text_area field with something similar to "answer_like" but
would like Searchlogic to return records that contain any or all of
those words in any part of the "answer" field. As I try it now, it
only returns records that contain the exact string "uploading PDFs".
For example, a record containing "uploading photos and PDFs" would not
be returned with "answer_like". Is there a way to get this done?
Thanks in advance.

Ben Johnson

unread,
Jan 7, 2010, 4:04:44 AM1/7/10
to searc...@googlegroups.com
What you are wanting is more of a keyword search. My suggestion would be to do something like this in your controller

@search.answer_like_any = params[:search][:answer_like_any].split(" ")

I know that's not ideal, but at the same time a search like that should really leverage some other kind of search technology or tool. Some databases have full text support built in. If yours does, try creating a named scope for it and just use that. For something more complex you might look at thinking sphinx or something along those lines.

Hope this helps.

Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

> --
>
> You received this message because you are subscribed to the Google Groups "Searchlogic" group.
> To post to this group, send email to searc...@googlegroups.com.
> To unsubscribe from this group, send email to searchlogic...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/searchlogic?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages