Class: Krikri::SearchIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/krikri/search_index.rb

Overview

Search index base class that gets extended by QA and Production index classes

Direct Known Subclasses

ProdSearchIndex, QASearchIndex

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ SearchIndex

Returns a new instance of SearchIndex.



10
11
12
# File 'lib/krikri/search_index.rb', line 10

def initialize(opts)
  @bulk_update_size = opts.delete(:bulk_update_size) { 10 }
end

Instance Method Details

#add(_) ⇒ Object

Add a single JSON document to the search index. Implemented in a child class.

Parameters:

  • _ (Hash)

    Hash that can be serialized to JSON with #to_json



19
20
21
# File 'lib/krikri/search_index.rb', line 19

def add(_)
  fail NotImplementedError
end

#bulk_add(_) ⇒ Object

Add a number of JSON documents to the search index at once. Implemented in a child class.

Parameters:

  • _ (Array)

    Hashes that can be serialized to JSON with #to_json



28
29
30
# File 'lib/krikri/search_index.rb', line 28

def bulk_add(_)
  fail NotImplementedError
end

#update_from_activity(activity) ⇒ Object

Shim that determines, for a particular type of index, which strategy to use, adding a single document, or adding them in bulk. Intended to be overridden as necessary.

See Also:



39
40
41
# File 'lib/krikri/search_index.rb', line 39

def update_from_activity(activity)
  incremental_update_from_activity(activity)
end