Forum: Ruby on Rails how to search all fields for a string in SQL ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
71477e5162d702dae2a072d66a855fec?d=identicon&s=25 wbsurfver@yahoo.com (Guest)
on 2009-04-30 22:46
(Received via mailing list)
Using SQL or activerecord I am not sure how to search all fields for a
specific value ?
I know how to do this by just writing ruby code. To do it in SQL or an
activerecord find w/condition,
I don't know how. I actually am supposed to combine an find w/
condition and a search all fields for a
value and AND those together. I think perhaps it can't be done with a
single find ?
280b78a61a968391b7e07e912be102a8?d=identicon&s=25 Robert Walker (robert4723)
on 2009-04-30 22:54
wbsurfver@yahoo.com wrote:
> Using SQL or activerecord I am not sure how to search all fields for a
> specific value ?
> I know how to do this by just writing ruby code. To do it in SQL or an
> activerecord find w/condition,
> I don't know how. I actually am supposed to combine an find w/
> condition and a search all fields for a
> value and AND those together. I think perhaps it can't be done with a
> single find ?

What you're probably looking for is a full-text search engine. Here's an
article I found using the Sphinx engine:

http://www.neeraj.name/blog/articles/599-working-w...

If you needs are pretty basic and you don't mind a database specific
implementation you can also look at MySQL's full-text search
capabilities. SQL was just not designed for such queries.
53be54e5db4dc58e4980db5a8255621b?d=identicon&s=25 Harold (Guest)
on 2009-04-30 23:06
(Received via mailing list)
I would suggest going with the thinkingsphinx plugin instead of
ultrasphinx. Thinkingsphinx's syntax is much cleaner.

http://ts.freelancing-gods.com/usage.html
http://railscasts.com/episodes/120-thinking-sphinx

On the other hand, if your dataset is small enough, you could try
scoped-search, which helps you construct the SQL to perform your
searches: http://wiki.github.com/wvanbergen/scoped_search
But as Robert said, databases/SQL are not great for this type of
queries and you may not be able to scale much when you have many
conditions and/or big volumes of data.


On Apr 30, 4:54 pm, Robert Walker <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.