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
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
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
So can i achieve that ? presently i know that it just searches the
–
Jens Krämer
http://www.jkraemer.net/ - Blog
http://www.omdb.org/ - The new free film database
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk
–
Jens Krämer
http://www.jkraemer.net/ - Blog
http://www.omdb.org/ - The new free film database
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?
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?