Module: Dnif::Indexer
- Defined in:
- lib/dnif/indexer.rb
Defined Under Namespace
Modules: InstanceMethods
Instance Method Summary collapse
Instance Method Details
#define_index(&block) ⇒ Object
8 9 10 11 12 |
# File 'lib/dnif/indexer.rb', line 8 def define_index(&block) indexes[self.name] = Dnif::Index.new(&block) include InstanceMethods end |
#indexes ⇒ Object
14 15 16 |
# File 'lib/dnif/indexer.rb', line 14 def indexes @@indexes end |
#to_sphinx ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dnif/indexer.rb', line 18 def to_sphinx return nil if indexes.blank? xml = Builder::XmlMarkup.new(:indent => 2) xml.instruct! xml.sphinx(:docset) do schema = Schema.new(self) xml << schema.generate results = self results = where(*indexes[self.name].conditions) if indexes[self.name].conditions.present? results.find_each(:batch_size => 5000) do |object| document = Document.new(object) xml << document.generate end end xml.target! end |