Ticket #48 (new defect)

Opened 5 months ago

Last modified 2 months ago

[PATCH] rebuild_solr_index doesn't obey :if parameter of models

Reported by: pclegg@nsv.com Assigned to: somebody
Priority: critical Milestone:
Component: component1 Version:
Keywords: Cc:

Description

I have a model that references other objects polymorphically; some of those types I don't want to index, so I did this:

acts_as_solr :if => proc{|x| ["ClassA", "ClassB"].include?(x.element_type) == false }

Doing rebuild_solr_index on this class, I noticed I was still getting those classes indexed. I dug through the code and believe I found the problem to be the fact that the rebuild_solr_index bypasses the :if clause, which solr_save does on each request (because the rebuild groups saves together)

Attachments

frk_conditional_rebuild_index.patch (1.3 kB) - added by jake.sutton@gmail.com on 02/28/2008 03:43:14 PM.
patch for conditional indexing when batch_size is specified

Change History

02/28/2008 03:43:14 PM changed by jake.sutton@gmail.com

  • attachment frk_conditional_rebuild_index.patch added.

patch for conditional indexing when batch_size is specified

(follow-up: ↓ 3 ) 02/28/2008 03:44:57 PM changed by jake.sutton@gmail.com

This is actually only a problem if you use the batch size parameter now.

The issue is that the rebuild_solr_index method uses solr_save if there's no batch_size and solr_add if there is. http://acts-as-solr.railsfreaks.com/acts_as_solr/browser/trunk/lib/class_methods.rb

solr_save checks the :if (at least it does these days... it didn't used to ;)

Anyway, I've done the attached patch for my own use. Not sure if it's the best trick in town, but it seems to work.

02/28/2008 03:56:01 PM changed by jake.sutton@gmail.com

  • summary changed from rebuild_solr_index doesn't obey :if parameter of models to [PATCH] rebuild_solr_index doesn't obey :if parameter of models.

(in reply to: ↑ 1 ) 05/05/2008 11:44:43 AM changed by anonymous

Replying to jake.sutton@gmail.com:

Anyway, I've done the attached patch for my own use. Not sure if it's the best trick in town, but it seems to work.

I've since changed the reject to a compact:

add_batch = items.collect { |content| content.to_solr_doc if content.solr_indexable? }.compact


Add/Change #48 ([PATCH] rebuild_solr_index doesn't obey :if parameter of models)




Change Properties
Action