isha kakodkar
2007-Jul-24 07:33 UTC
[Ferret-talk] Act as Ferret supports Conditional search?
Hi all, Im a newbie to ferret.I have installed the act_as_ferret gem and i actually want to search for some content in the model,but per user. My model has data,user_id.So within the data column i have to serach for a word if it exists for a given user. So can i achieve that ? presently i know that it just searches the "data" column irrespective of the user given. Can someone help me with this? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ferret-talk/attachments/20070724/5c3f59fe/attachment.html
Jens Kraemer
2007-Jul-24 08:47 UTC
[Ferret-talk] Act as Ferret supports Conditional search?
On Tue, Jul 24, 2007 at 12:33:47AM -0700, isha kakodkar wrote:> Hi all, > Im a newbie to ferret.I have installed the act_as_ferret gem and i > actually want to search for some content in the model,but per user. > My model has data,user_id.So within the data column i have to serach for a > word if it exists for a given user. > So can i achieve that ? presently i know that it just searches the "data" > column irrespective of the user given. > Can someone help me with this?Index the user_id field (as untokenized) and append " user_id:#{user.id}" to the query. cheers, Jens -- Jens Kr?mer http://www.jkraemer.net/ - Blog http://www.omdb.org/ - The new free film database
isha kakodkar
2007-Jul-25 06:39 UTC
[Ferret-talk] Act as Ferret supports Conditional search?
thanx..i actually did it using the :conditions with find_by_contents. But when i do find_id_by_contents,which searches from the filesystem,can i search within data based on this index value?and not just the full data field? On 7/24/07, Jens Kraemer <jk at jkraemer.net> wrote:> > On Tue, Jul 24, 2007 at 12:33:47AM -0700, isha kakodkar wrote: > > Hi all, > > Im a newbie to ferret.I have installed the act_as_ferret gem and i > > actually want to search for some content in the model,but per user. > > My model has data,user_id.So within the data column i have to serach for > a > > word if it exists for a given user. > > So can i achieve that ? presently i know that it just searches the > "data" > > column irrespective of the user given. > > Can someone help me with this? > > Index the user_id field (as untokenized) and append " user_id:#{user.id}" > to the query. > > cheers, > Jens > > > -- > Jens Kr?mer > http://www.jkraemer.net/ - Blog > http://www.omdb.org/ - The new free film database > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ferret-talk/attachments/20070724/3ec92088/attachment.html
Jens Kraemer
2007-Jul-26 06:36 UTC
[Ferret-talk] Act as Ferret supports Conditional search?
On Tue, Jul 24, 2007 at 11:39:15PM -0700, isha kakodkar wrote:> thanx..i actually did it using the :conditions with find_by_contents. > But when i do find_id_by_contents,which searches from the filesystem,can i > search within data based on this index value?and not just the full data > field?yes, every attribute you index is stored in it''s own Ferret field, and you can run queries (or parts of queries) against just one Ferret field by specifying the field name like I did in the example below. Jens> > On 7/24/07, Jens Kraemer <jk at jkraemer.net> wrote: > > > >On Tue, Jul 24, 2007 at 12:33:47AM -0700, isha kakodkar wrote: > >> Hi all, > >> Im a newbie to ferret.I have installed the act_as_ferret gem and i > >> actually want to search for some content in the model,but per user. > >> My model has data,user_id.So within the data column i have to serach for > >a > >> word if it exists for a given user. > >> So can i achieve that ? presently i know that it just searches the > >"data" > >> column irrespective of the user given. > >> Can someone help me with this? > > > >Index the user_id field (as untokenized) and append " user_id:#{user.id}" > >to the query. > > > >cheers, > >Jens > > > > > >-- > >Jens Kr?mer > >http://www.jkraemer.net/ - Blog > >http://www.omdb.org/ - The new free film database > >_______________________________________________ > >Ferret-talk mailing list > >Ferret-talk at rubyforge.org > >http://rubyforge.org/mailman/listinfo/ferret-talk > >> _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk-- Jens Kr?mer http://www.jkraemer.net/ - Blog http://www.omdb.org/ - The new free film database
isha kakodkar
2007-Jul-27 11:13 UTC
[Ferret-talk] Act as Ferret supports Conditional search?
Thats cool...I could get that working too.Thanks a lot..1 more problem i have before getting it to completion... I currently have 2 models,chat having a "Has_many" relationship with messages model. A chat has a name and messages have message content.So when i search a keyword,i want 2 go against both these fields. So if i want 2 do single index on chat module.but for both the fields...how do i go about doing it? so i have chat.rb model and message.rb model. In chat.rb acts_as_ferret :store_class_name => true, :fields => { :name , :msg } def msg return "#{self.message.find(:all,:select=>''msg'')}" end msg is supposed to be a array of messages for one chat...So can i index on all elements of the msg array within chat module? And thereafter whenever a msg gets inserted in message model,will its contents be automatically indexed? I tried doing t vice-versa by putting index on messages.It works.But in case of row pagination doesnt come out well... if many messages have the keyword,it sends me those many msgIds and they all belong to just 1 chat....total hits become more and actual records i would show are less...So extra page numbers gets displayed. A better option for me would be the first approach..So can you help me on it? On 7/25/07, Jens Kraemer <jk at jkraemer.net> wrote:> > On Tue, Jul 24, 2007 at 11:39:15PM -0700, isha kakodkar wrote: > > thanx..i actually did it using the :conditions with find_by_contents. > > But when i do find_id_by_contents,which searches from the filesystem,can > i > > search within data based on this index value?and not just the full data > > field? > > yes, every attribute you index is stored in it''s own Ferret field, and > you can run queries (or parts of queries) against just one Ferret field > by specifying the field name like I did in the example below. > > Jens > > > > > On 7/24/07, Jens Kraemer <jk at jkraemer.net> wrote: > > > > > >On Tue, Jul 24, 2007 at 12:33:47AM -0700, isha kakodkar wrote: > > >> Hi all, > > >> Im a newbie to ferret.I have installed the act_as_ferret gem and i > > >> actually want to search for some content in the model,but per user. > > >> My model has data,user_id.So within the data column i have to serach > for > > >a > > >> word if it exists for a given user. > > >> So can i achieve that ? presently i know that it just searches the > > >"data" > > >> column irrespective of the user given. > > >> Can someone help me with this? > > > > > >Index the user_id field (as untokenized) and append " user_id:#{user.id > }" > > >to the query. > > > > > >cheers, > > >Jens > > > > > > > > >-- > > >Jens Kr?mer > > >http://www.jkraemer.net/ - Blog > > >http://www.omdb.org/ - The new free film database > > >_______________________________________________ > > >Ferret-talk mailing list > > >Ferret-talk at rubyforge.org > > >http://rubyforge.org/mailman/listinfo/ferret-talk > > > > > > _______________________________________________ > > Ferret-talk mailing list > > Ferret-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/ferret-talk > > -- > Jens Kr?mer > http://www.jkraemer.net/ - Blog > http://www.omdb.org/ - The new free film database > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ferret-talk/attachments/20070727/79b2f0ab/attachment-0001.html