curtis.hatter at insightbb.com
2006-Nov-16 16:45 UTC
[Ferret-talk] Strange indexing issues with CachedModel, STI, and AAF
I started using robotcoop''s CachedModel class in my project but have encountered problems when using it with the acts_as_ferret plugin. It seems it doesn''t index everything in my STI model, also if I do a search from my base STI class I get a result count but no results. If I run the same search from one of the children STI models I get the appropriate results (if the information was indexed). Here''s my setup: class Record < CachedModel acts_as_nested_set acts_as_ferret( :fields => { :lft { :index => :untokenized_omit_norms }, :name => {}, :desc => {}, :body => {:strore => :yes}, :role => {}, }) def self.inheritance_column ''role'' end # methods below ..... end class FirstRecord < Record end class SecondRecord < Record end class ApplicationController < ActionController::Base after_filter { CachedModel.cache_reset } end Here''s my CachedModel setup: - config/environment.rb: # Include your application configuration below require ''cached_model'' CachedModel.use_local_cache = true - config/environments/development.rb (last line) CACHE = MemCache.new ''localhost:11211'', :namespace => ''ohio_development'' - config/environments/production.rb (last line) CACHE = MemCache.new ''localhost:11211'', :namespace => ''ohio_production'' As far as I can tell I''ve set both up properly. Also I get the same problems when running in production mode. This is on a FreeBSD 6.1 server, with memcached-1.1.12_3, mysql 5.0.26, and rails 1.1.6. Any help would be appreciated as I''ve been at this one for 2 days. Here''s example output I get from irb:>> Record.find_by_contents("search code")=> #<FerretMixin::Acts::ARFerret::SearchResults:0x8d9f6e0 @total_hits=212, @reults=[]> This makes me think it has something to do with the ''find'' method being overridden by CachedModel but not sure how to verify that at this point. Thanks, Curtis
Curtis Hatter
2006-Nov-21 02:41 UTC
[Ferret-talk] [Libraries] Strange indexing issues with CachedModel, STI, and AAF
I solved this problem finally. After investigating Ferret, Acts_As_Ferret and CachedModel I finally turned to checking out Rails. It turns out Rails 1.1.6 does not properly scope queries for STI models if they have an abstract_class. This seems to be fixed now (http://dev.rubyonrails.org/ticket/5704). The problem was that Rails current method did not check to see if the class'' parent was abstract. Hope this helps someone else who may try to use STI and CachedModel together. Now that it works I''m very pleased with the solution. Almost split my data into separate tables. Sorry for the noise, Curtis ----- Original Message ----- From: <curtis.hatter at insightbb.com> To: <ferret-talk at rubyforge.org>; <libraries at lists.robotcoop.com> Sent: Thursday, November 16, 2006 11:45 AM Subject: [Libraries] Strange indexing issues with CachedModel, STI, and AAF> I started using robotcoop''s CachedModel class in my project but haveencountered problems when using it with the acts_as_ferret plugin. It seems it doesn''t index everything in my STI model, also if I do a search from my base STI class I get a result count but no results. If I run the same search from one of the children STI models I get the appropriate results (if the information was indexed).> > Here''s my setup: > > class Record < CachedModel > acts_as_nested_set > acts_as_ferret( :fields => { > :lft { :index => :untokenized_omit_norms }, > :name => {}, > :desc => {}, > :body => {:strore => :yes}, > :role => {}, > }) > > def self.inheritance_column > ''role'' > end > > # methods below ..... > end > > class FirstRecord < Record > end > > class SecondRecord < Record > end > > class ApplicationController < ActionController::Base > after_filter { CachedModel.cache_reset } > end > > Here''s my CachedModel setup: > - config/environment.rb: > # Include your application configuration below > require ''cached_model'' > CachedModel.use_local_cache = true > > - config/environments/development.rb (last line) > CACHE = MemCache.new ''localhost:11211'', :namespace => ''ohio_development'' > > - config/environments/production.rb (last line) > CACHE = MemCache.new ''localhost:11211'', :namespace => ''ohio_production'' > > As far as I can tell I''ve set both up properly. Also I get the sameproblems when running in production mode.> > This is on a FreeBSD 6.1 server, with memcached-1.1.12_3, mysql 5.0.26,and rails 1.1.6.> > Any help would be appreciated as I''ve been at this one for 2 days. > > Here''s example output I get from irb: > >> Record.find_by_contents("search code") > => #<FerretMixin::Acts::ARFerret::SearchResults:0x8d9f6e0 @total_hits=212,@reults=[]>> > This makes me think it has something to do with the ''find'' method beingoverridden by CachedModel but not sure how to verify that at this point.> > Thanks, > Curtis > _______________________________________________ > Libraries mailing list > Libraries at lists.robotcoop.com > http://lists.robotcoop.com/mailman/listinfo/libraries