Module: Tinia::Index::ClassMethods

Defined in:
lib/tinia/index.rb

Instance Method Summary collapse

Instance Method Details

#cloud_search_add_document(doc) ⇒ Object

class method to add documents



58
59
60
# File 'lib/tinia/index.rb', line 58

def cloud_search_add_document(doc)
  self.cloud_search_batcher_command(:add_document, doc)
end

#cloud_search_batch_documents(&block) ⇒ Object

perform all add/delete operations within a buffered DocumentBatcher



69
70
71
72
73
74
75
76
77
78
# File 'lib/tinia/index.rb', line 69

def cloud_search_batch_documents(&block)
  begin
    self.in_cloud_search_batch_documents = true
    yield
    # final flush for any left over documents
    self.cloud_search_document_batcher.flush
  ensure
    self.in_cloud_search_batch_documents = false
  end
end

#cloud_search_delete_document(doc) ⇒ Object

class method to add documents



63
64
65
# File 'lib/tinia/index.rb', line 63

def cloud_search_delete_document(doc)
  self.cloud_search_batcher_command(:delete_document, doc)
end

#cloud_search_document_batcherObject

new instance of AWSCloudSearch::DocumentBatcher



90
91
92
93
94
# File 'lib/tinia/index.rb', line 90

def cloud_search_document_batcher
  @cloud_search_document_batcher ||= begin
    self.cloud_search_connection.new_batcher
  end
end

#cloud_search_reindex(*args) ⇒ Object

reindex the entire collection



81
82
83
84
85
86
87
# File 'lib/tinia/index.rb', line 81

def cloud_search_reindex(*args)
  self.cloud_search_batch_documents do
    self.find_each(*args) do |record|
      record.add_to_cloud_search
    end
  end
end