Hello, noob here. I have a table called ''entries'' with lots of sentences, one per row (id). I need to find specific sentences that have the words I''m looking for anywhere in them. For example:>1. The bird entered the kitchen through the door. > >2. You left the door of your car open. > >3. Close the window or the bird will get out of the car.If I search for ''bird'' and ''door'', I want only the sentence with the id 1 to come up. If I search for ''door'' and ''car'', I want only the sentence with the id 2 to come up. If I search for ''bird'' and ''car'', I want only the sentence with the id 3 to come up. So, basically, what this grep command would do:> cat my.file | grep bird | grep doorBut I''m not getting anywhere with any search technique or plugin I''ve tried so far. Any ideas? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
isn''t that just the condition ''sentence like %bird%door%''? Although that will only get them where they appear in that particular order. You could interate all the possibilities ie conditions => [''sentence like %bird%door% or sentence like %door%bird%''] but that will get messy the more words you have in your search. but there might be something else you can do in SQL. Cheers Simon On Sat, 07 Feb 2009 10:58:32 +0900, Ralph Wood <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hello, noob here. > > I have a table called ''entries'' with lots of sentences, one per row > (id). I need to find specific sentences that have the words I''m looking > for anywhere in them. For example: > >> 1. The bird entered the kitchen through the door. >> >> 2. You left the door of your car open. >> >> 3. Close the window or the bird will get out of the car. > > If I search for ''bird'' and ''door'', I want only the sentence with the id > 1 to come up. If I search for ''door'' and ''car'', I want only the sentence > with the id 2 to come up. If I search for ''bird'' and ''car'', I want only > the sentence with the id 3 to come up. > > So, basically, what this grep command would do: > >> cat my.file | grep bird | grep door > > But I''m not getting anywhere with any search technique or plugin I''ve > tried so far. Any ideas?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Simon Macneall wrote:>but that will get messy the more words you have in your > search.Yeah, I was figuring I was gonna have to do something like an ''explode'' with the search terms at some point. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Would conditions => [''sentence like %bird% and sentence like %door%''] do the job? 2009/2/7 Ralph Wood <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > Simon Macneall wrote: > >but that will get messy the more words you have in your > > search. > > Yeah, I was figuring I was gonna have to do something like an ''explode'' > with the search terms at some point. > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, Feb 6, 2009 at 5:58 PM, Ralph Wood <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I have a table called ''entries'' with lots of sentences, one per row > (id). I need to find specific sentences that have the words I''m looking > for anywhere in them.If you''re using MySQL, you can create a FULLTEXT index on the field(s) in question and use MATCH: <http://dev.mysql.com/doc/refman/5.0/en/fulltext-natural-language.html> Other RDBMSs may have an equivalent. HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---