Class: AgnosticBackend::Cloudsearch::Indexer

Inherits:
Indexer
  • Object
show all
Includes:
Utilities
Defined in:
lib/agnostic_backend/cloudsearch/indexer.rb

Instance Attribute Summary

Attributes inherited from Indexer

#index

Instance Method Summary collapse

Methods included from Utilities

included

Methods inherited from Indexer

#put

Constructor Details

#initialize(index) ⇒ Indexer

Returns a new instance of Indexer.



8
9
10
# File 'lib/agnostic_backend/cloudsearch/indexer.rb', line 8

def initialize(index)
  @index = index
end

Instance Method Details

#delete(*document_ids) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/agnostic_backend/cloudsearch/indexer.rb', line 21

def delete(*document_ids)
  documents = document_ids.map do |document_id|
    {"type" => 'delete',
     "id" => document_id}
  end

  with_exponential_backoff Aws::CloudSearch::Errors::Throttling do
    client.upload_documents(
      documents: convert_to_json(documents),
      content_type:'application/json'

    )
  end
end

#publish(document) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/agnostic_backend/cloudsearch/indexer.rb', line 12

def publish(document)
  with_exponential_backoff Aws::CloudSearch::Errors::Throttling do
    client.upload_documents(
      documents: document,
      content_type:'application/json'
    )
  end
end