Ruby Forum Ferret > acts_as_ferret - same index in two apps, reindexing issue

Posted by Josh Adams (knewter)
on 13.05.2008 17:12
I've got a site that has the main site as well as an admin app.  Both of
them use the same ferret index.  Objects from the main site are
namespaced in the admin site, and those namespaced objects share the
same db with the main site.

Case in point: class Photo < ActiveRecord::Base in the main site is
class MainSite::Photo < MainSite::Base in the admin site, where
MainSite::Base specifies the main site's database.  So admin objects
live in their own db, and main objects are shared between apps.

Anyway, there's a ferret index on Photos and their categorization scheme
(Branches, Facets, etc).  If I'm on the main site and I update the
categorization info (add a few tags) for a photo, ferret updates
immediately.  If I do the same thing from the admin site, ferret has to
be manually reindexed.

Can anyone give me any pointers on why this would be?  Are the differing
class names causing the trouble?  I just don't understand...

Thanks in advance for any help, and I can provide more details as
requested.

-Josh
Posted by Josh Adams (knewter)
on 19.05.2008 22:04
Just pinging.  This one's got me stumped.
Posted by Josh Adams (knewter)
on 19.05.2008 22:06
Oh yes, as an update - the ferret server itself just doesn't seem to be 
adding to the index on create just with the *one* app.  Sample:

class Term < ActiveRecord::Base
  acts_as_ferret :fields => [ :name ]
end

>> t=Term.find_or_create_by_name 'jail'
=> #<Term id: 1, name: "jail", created_at: "2008-05-19 19:56:26", 
updated_at: "2008-05-19 19:56:26">
>> Term.find_by_contents('jail')
=> #<ActsAsFerret::SearchResults:0xb6613a30 @per_page=0, 
@current_page=nil, @total_hits=0, @total_pages=0, @results=[]>
>> Term.rebuild_index
=> nil
>> Term.find_by_contents('jail')
=> #<ActsAsFerret::SearchResults:0xb6608f54 @per_page=1, 
@current_page=nil, @total_hits=1, @total_pages=1, @results=[#<Term id: 
1, name: "jail", created_at: "2008-05-19 19:56:26", updated_at: 
"2008-05-19 19:56:26">]>

So creating the term didn't update the index.  I was running it as a drb 
server if that matters at all, and manually rebuilding the index 
succeeds.

Any help?

Josh Adams wrote:
> I've got a site that has the main site as well as an admin app.  Both of
> them use the same ferret index.  Objects from the main site are
> namespaced in the admin site, and those namespaced objects share the
> same db with the main site.
> 
> Case in point: class Photo < ActiveRecord::Base in the main site is
> class MainSite::Photo < MainSite::Base in the admin site, where
> MainSite::Base specifies the main site's database.  So admin objects
> live in their own db, and main objects are shared between apps.
> 
> Anyway, there's a ferret index on Photos and their categorization scheme
> (Branches, Facets, etc).  If I'm on the main site and I update the
> categorization info (add a few tags) for a photo, ferret updates
> immediately.  If I do the same thing from the admin site, ferret has to
> be manually reindexed.
> 
> Can anyone give me any pointers on why this would be?  Are the differing
> class names causing the trouble?  I just don't understand...
> 
> Thanks in advance for any help, and I can provide more details as
> requested.
> 
> -Josh