I have multiple models all with: acts_as_ferret :fields => [...] (models = profiles, blogs, comments ) 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. Any ideas? Can acts_as_ferret handle this? Thanks Adam -- Posted via http://www.ruby-forum.com/.
On 2/28/06, A. Roth <adamjroth at gmail.com> wrote:> I have multiple models all with: > > acts_as_ferret :fields => [...] > > (models = profiles, blogs, comments ) > > > 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. > > Any ideas? Can acts_as_ferret handle this?Hi Adam, I''m assuming here that you used the acts_as_ferret code on the lower part of this page; http://ferret.davebalmain.com/trac/wiki/FerretOnRails 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. Cheers, Dave> > > Thanks > Adam > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk >
Hi David, 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. Thanks you in advance. Adam David Balmain wrote:> On 2/28/06, A. Roth <adamjroth at gmail.com> wrote: >> is being updated. >> >> Any ideas? Can acts_as_ferret handle this? > > Hi Adam, > > I''m assuming here that you used the acts_as_ferret code on the lower > part of this page; > > http://ferret.davebalmain.com/trac/wiki/FerretOnRails > > 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. > > Cheers, > Dave-- Posted via http://www.ruby-forum.com/.
Also, I was using the version found here: https://svn.jkraemer.net/svn/projects/ferret-demo/trunk/vendor/plugins/acts_as_ferret/ His changelog mentions how the index per model structure... should I be using the one on the wiki page? Adam -- Posted via http://www.ruby-forum.com/.
Hi Adam, 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. Cheers, Dave On 3/1/06, aroth <adamjroth at gmail.com> wrote:> Also, I was using the version found here: > > https://svn.jkraemer.net/svn/projects/ferret-demo/trunk/vendor/plugins/acts_as_ferret/ > > His changelog mentions how the index per model structure... should I be > using the one on the wiki page? > > Adam > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk >
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? On 3/1/06, aroth <adamjroth at gmail.com> wrote:> Also, I was using the version found here: > > https://svn.jkraemer.net/svn/projects/ferret-demo/trunk/vendor/plugins/acts_as_ferret/ > > His changelog mentions how the index per model structure... should I be > using the one on the wiki page? > > Adam > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk >
aroth wrote:> Also, I was using the version found here: > > https://svn.jkraemer.net/svn/projects/ferret-demo/trunk/vendor/plugins/acts_as_ferret/ >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. Thomas -- Posted via http://www.ruby-forum.com/.
David Balmain wrote:> 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: 1. 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. 2. Is there a way to limit the results that you get back? (IE, limit to 10, or pass a limit/offset for paging). 3. 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 Thanks again. Adam -- Posted via http://www.ruby-forum.com/.
On Wed, Mar 01, 2006 at 06:50:46AM +0100, Adam Roth wrote:> > 3. 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 > endyou can use Luke (http://www.getopt.org/luke/) to inspect an existing ferret index. I''ll try to reproduce and fix the problems you had concerning multiple indexes/classes with the acts_as_ferret version from the svn repository. Jens -- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66
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. I tried to checkout the code from https://svn.jkraemer.net/svn/projects/ferret-demo/trunk/vendor/plugins/acts_as_ferret/ but it is requiring a username and password, even though I can access it fine through the web. I was hoping I could send you some diffs for some of the things we''ve done. Is there a guest account I could use to checkout? Thanks -Lee On 3/1/06, Jens Kraemer <kraemer at webit.de> wrote:> On Wed, Mar 01, 2006 at 06:50:46AM +0100, Adam Roth wrote: > > > > 3. 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 > > you can use Luke (http://www.getopt.org/luke/) to inspect an existing > ferret index. > > I''ll try to reproduce and fix the problems you had concerning multiple > indexes/classes with the acts_as_ferret version from the svn repository. > > Jens > > -- > webit! Gesellschaft f?r neue Medien mbH www.webit.de > Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de > Schnorrstra?e 76 Tel +49 351 46766 0 > D-01069 Dresden Fax +49 351 46766 66 > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk >
On Wed, Mar 01, 2006 at 10:18:10AM -0700, Lee Marlow wrote:> 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. > > I tried to checkout the code from > https://svn.jkraemer.net/svn/projects/ferret-demo/trunk/vendor/plugins/acts_as_ferret/ > but it is requiring a username and password, even though I can access > it fine through the web. I was hoping I could send you some diffs for > some of the things we''ve done. Is there a guest account I could use > to checkout?Ooops, my mistake, read-only access via svn should work now without any authentication. patches are welcome of course :-) btw: I just fixed the issue reported in this thread. Jens -- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66
On Wed, Mar 01, 2006 at 06:50:46AM +0100, Adam Roth wrote: [..]> 1. 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.> 2. Is there a way to limit the results that you get back? (IE, limit to > 10, or pass a limit/offset for paging).I just added this to the svn version of the plugin. You can have a look at test/unit/content_test.rb from the demo project (https://svn.jkraemer.net/svn/projects/ferret-demo/trunk/test/unit/content_test.rb) for an example. As the other issue concerning multiple indexes is now fixed, too, you could give the svn version another try. Regards, Jens -- webit! Gesellschaft f?r neue Medien mbH www.webit.de Dipl.-Wirtschaftsingenieur Jens Kr?mer kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66
Jens, 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? Thanks Adam -- Posted via http://www.ruby-forum.com/.
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. On 3/2/06, aroth <adamjroth at gmail.com> wrote:> Jens, > > 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? > > Thanks > Adam > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk >-------------- next part -------------- A non-text attachment was scrubbed... Name: indexer.rake Type: application/octet-stream Size: 1476 bytes Desc: not available Url : http://rubyforge.org/pipermail/ferret-talk/attachments/20060302/7b274620/indexer-0001.obj
So is it correct then that you have to use inheritance to get it to work across multiple models? Lee Marlow 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.-- Posted via http://www.ruby-forum.com/.