class AgnosticBackend::Indexer
Attributes
index[R]
Public Class Methods
new(index)
click to toggle source
# File lib/agnostic_backend/indexer.rb, line 9 def initialize(index) @index = index end
Public Instance Methods
delete(document_id)
click to toggle source
Deletes the specified document from the index @param [document_id] the document id of the indexed document
# File lib/agnostic_backend/indexer.rb, line 38 def delete(document_id) delete_all([document_id]) end
delete_all(document_ids)
click to toggle source
Deletes the specified documents from the index. This is an abstract method which concrete index classes must implement in order to provide its functionality. @param [document_ids] an array of document ids
# File lib/agnostic_backend/indexer.rb, line 46 def delete_all(document_ids) raise NotImplementedError end
generate_document(indexable)
click to toggle source
@param [Indexable] an Indexable
object
# File lib/agnostic_backend/indexer.rb, line 32 def generate_document(indexable) transform(prepare(indexable.generate_document)) end
publish(document)
click to toggle source
# File lib/agnostic_backend/indexer.rb, line 50 def publish(document) publish_all([document]) end
publish_all(documents)
click to toggle source
# File lib/agnostic_backend/indexer.rb, line 54 def publish_all(documents) raise NotImplementedError end
put(indexable)
click to toggle source
Sends the specified document to the remote backend. @param [Indexable] an Indexable
object
# File lib/agnostic_backend/indexer.rb, line 15 def put(indexable) put_all([indexable]) end
put_all(indexables)
click to toggle source
Sends the specified documents to the remote backend using bulk upload (if supported by the backend) @param [Indexable] an Indexable
object
# File lib/agnostic_backend/indexer.rb, line 22 def put_all(indexables) documents = indexables.map do |indexable| generate_document(indexable) end documents.reject!(&:empty?) publish_all(documents) unless documents.empty? end
Private Instance Methods
prepare(document)
click to toggle source
# File lib/agnostic_backend/indexer.rb, line 64 def prepare(document) raise NotImplementedError end
transform(document)
click to toggle source
# File lib/agnostic_backend/indexer.rb, line 60 def transform(document) raise NotImplementedError end