When I restart the server and perform any crud operation on one of the
above models, the index is created/updated. If I then go and perform
any crud operation on ANOTHER model, …the index from that first model
is being updated.
There should only be one index for all models, not one index each.
Each document in the index contains a ferret_class field which will
contain the name of the model so searches on a specific model will
only find documents for that model. I hope that makes sense. Basically
there should be one index that gets updated whenever any of the models
are updated.
Yes… that makes sense. Why, however, are there directories created for
each model in RAILS_ROOT/index/RAILS_ENV if only one is needed? The
first model hit will be the index that is written to for all models
(like I had mentioned). Is that correct? For example:
I start up the server
A “blog” page is hit and updated
The index in RAILS_ROOT/index/Development/Blog is updated
A “comment” page is updated
The index is RAILS_ROOT/index/Development/Blog is updated again,
despite there being a /Development/Comment dir.
I’m probably missing something. I would appriciate if you could fill in
my understanding based on my comments above.
There should only be one index for all models, not one index each.
Each document in the index contains a ferret_class field which will
contain the name of the model so searches on a specific model will
only find documents for that model. I hope that makes sense. Basically
there should be one index that gets updated whenever any of the models
are updated.
One other thing. When you say the blog index is being updated when you
modify comments, does that mean only the blog index ever gets updated?
Does the comments index remains empty?
That version is supposed to work with seperate indexes. I had a quick
look at the code but I’m not sure what is wrong. Perhaps you could
drop Jens an email about it. Or you could try the other acts_as_ferret
plugin. Sorry I can’t be of more help.
Actually, I believe he merged bits and pieces from both versions on the
wiki along with some of his own changes. I haven’t looked closely at the
code, yet, but I from an initial glance it looks like it incorporates my
additions pretty cleanly. I’m not quite certain why you would be seeing
the behavior described. Could you post some snippets from your code
(like the acts_as_ferret lines from each model and any configuration
from environment.rb)?
Jens just recently set up this SVN repository and gave Kasper and I
access to it for furthur updates – this will be the source for future
versions of the plugin. One of us will hopefully be updating the wiki
soon to reflect this.
One other thing. When you say the blog index is being updated when you
modify comments, does that mean only the blog index ever gets updated?
Does the comments index remains empty?
I used the second block of code on the wiki and it now works with 1
index… however, I can’t seem to get any results back. Editing any of
the models forces the index to update, so I know something is going on.
Hopefully you guys can answer a few questions:
Are all the “fields” of a model indexed? When I used that
acts_as_ferret code from the svn repository, I had to specify the
fields. And despite the problems, I was also getting results back.
Is there a way to limit the results that you get back? (IE, limit to
10, or pass a limit/offset for paging).
Is there a way I can “dump” the information Ferret has indexed so
that I can see if the correct data is there? I’d like to figure out why
no results are coming back from:
def test_ferret @results = Comment.find_by_contents( params[‘query’] )
render_text @results.inspect
end
We have also been using our own version of acts_as_ferret, put
together from the wiki and a version that was on the rails mailing
list. We added a simple rake task for rebuilding the index and
pagination. We kept the one index for all models as I expect Ferret
to be fast enough to handle it and maybe we’ll want to query across
models one day.
On Wed, Mar 01, 2006 at 06:50:46AM +0100, Adam R. wrote:
Is there a way I can “dump” the information Ferret has indexed so
that I can see if the correct data is there? I’d like to figure out why
no results are coming back from:
def test_ferret @results = Comment.find_by_contents( params[‘query’] )
render_text @results.inspect
end
Your fix works great. Thank you. Another quick question. I notice the
“rebuild_index.rb” in the plugin dir. If I try to run this directly, it
doesnt want to run (complains about not being able to require ‘ferret’).
Anyway, I’d like to know how I can use Ferret or acts_as_ferret to index
all of my existing content based on the fields/models I have declared as
‘acts_as_ferret’. Right now, they are added to the index after any CRUD
operation – is there a way to force this outside of the scope of the
web?
On Wed, Mar 01, 2006 at 06:50:46AM +0100, Adam R. wrote:
[…]
Are all the “fields” of a model indexed? When I used that
acts_as_ferret code from the svn repository, I had to specify the
fields. And despite the problems, I was also getting results back.
You have to specify the fields when using the second code snippet from
the wiki, too. If no fields are specified, only the id and the class
name will be indexed.
Is there a way to limit the results that you get back? (IE, limit to
10, or pass a limit/offset for paging).
Here is our rake task which uses a slightly different version of
acts_as_ferret. It will try to load up all models in app/models and
call ferret_update on each instance.
So is it correct then that you have to use inheritance to get it to work
across multiple models?
Lee M. wrote:
Here is our rake task which uses a slightly different version of
acts_as_ferret. It will try to load up all models in app/models and
call ferret_update on each instance.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.