Changeset 306
- Timestamp:
- 02/02/08 12:35:01 (8 months ago)
- Files:
-
- trunk/plugin/acts_as_ferret/lib/bulk_indexer.rb (modified) (1 diff)
- trunk/plugin/acts_as_ferret/lib/instance_methods.rb (modified) (1 diff)
- trunk/plugin/acts_as_ferret/lib/local_index.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plugin/acts_as_ferret/lib/bulk_indexer.rb
r250 r306 17 17 def index_records(records, offset) 18 18 batch_time = measure_time { 19 records.each { |rec| @index << rec.to_docif rec.ferret_enabled?(true) }19 records.each { |rec| @index.add_document(rec.to_doc, rec.ferret_analyzer) if rec.ferret_enabled?(true) } 20 20 }.to_f 21 21 @work_done = offset.to_f / @model_count * 100.0 if @model_count > 0 trunk/plugin/acts_as_ferret/lib/instance_methods.rb
r300 r306 49 49 def ferret_enabled?(is_bulk_index = false) 50 50 @ferret_disabled.nil? && (is_bulk_index || self.class.ferret_enabled?) 51 end 52 53 # Returns the analyzer to use when adding this record to the index. 54 # 55 # Override to return a specific analyzer for any record that is to be 56 # indexed, i.e. specify a different analyzer based on language. Returns nil 57 # by default so the global analyzer (specified with the acts_as_ferret 58 # call) is used. 59 def ferret_analyzer 60 nil 51 61 end 52 62 trunk/plugin/acts_as_ferret/lib/local_index.rb
r301 r306 150 150 # add record to index 151 151 # record may be the full AR object, a Ferret document instance or a Hash 152 def add(record) 153 record = record.to_doc unless Hash === record || Ferret::Document === record 154 ferret_index << record 152 def add(record, analyzer = nil) 153 unless Hash === record || Ferret::Document === record 154 analyzer = record.ferret_analyzer 155 record = record.to_doc 156 end 157 ferret_index.add_document(record, analyzer) 155 158 end 156 159 alias << add
