Class: GOM::Storage::ElasticSearch::Adapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/gom/storage/elastic_search/adapter.rb

Overview

The ElasticSearch storage adapter.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#storage_configurationObject (readonly)

Returns the value of attribute storage_configuration.



6
7
8
# File 'lib/gom/storage/elastic_search/adapter.rb', line 6

def storage_configuration
  @storage_configuration
end

Instance Method Details

#collection(name, options = { }) ⇒ Object

Raises:

  • (ArgumentError)


31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gom/storage/elastic_search/adapter.rb', line 31

def collection(name, options = { })
  view = configuration.views[name.to_sym]
  raise ArgumentError, "the given view #{name} isn't defined!'" unless view

  query_string = build_query view.class_name, options[:query]
  search = Tire.search @index_name do
    query { string query_string }
  end

  GOM::Object::Collection.new GOM::Storage::ElasticSearch::Collection::Fetcher.new(search.results), configuration.name
end

#fetch(id) ⇒ Object



19
20
21
# File 'lib/gom/storage/elastic_search/adapter.rb', line 19

def fetch(id)
  storage_adapter.fetch id
end

#remove(id) ⇒ Object



27
28
29
# File 'lib/gom/storage/elastic_search/adapter.rb', line 27

def remove(id)
  storage_adapter.remove id
end

#setupObject



8
9
10
11
12
13
# File 'lib/gom/storage/elastic_search/adapter.rb', line 8

def setup
  setup_connection
  setup_index
  assign_storage
  setup_river
end

#store(draft) ⇒ Object



23
24
25
# File 'lib/gom/storage/elastic_search/adapter.rb', line 23

def store(draft)
  storage_adapter.store draft
end

#teardownObject



15
16
17
# File 'lib/gom/storage/elastic_search/adapter.rb', line 15

def teardown
  
end