Class: AgnosticBackend::Cloudsearch::Index

Inherits:
Index
  • Object
show all
Defined in:
lib/agnostic_backend/cloudsearch/index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Index

#name

Constructor Details

#initialize(indexable_klass, **options) ⇒ Index

Returns a new instance of Index.



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

def initialize(indexable_klass, **options)
  super(indexable_klass)
  @region = parse_option(options, :region)
  @domain_name = parse_option(options, :domain_name)
  @document_endpoint = parse_option(options, :document_endpoint)
  @search_endpoint = parse_option(options, :search_endpoint)
  @access_key_id = parse_option(options, :access_key_id)
  @secret_access_key = parse_option(options, :secret_access_key)
end

Instance Attribute Details

#access_key_idObject (readonly)

Returns the value of attribute access_key_id.



5
6
7
# File 'lib/agnostic_backend/cloudsearch/index.rb', line 5

def access_key_id
  @access_key_id
end

#document_endpointObject (readonly)

Returns the value of attribute document_endpoint.



5
6
7
# File 'lib/agnostic_backend/cloudsearch/index.rb', line 5

def document_endpoint
  @document_endpoint
end

#domain_nameObject (readonly)

Returns the value of attribute domain_name.



5
6
7
# File 'lib/agnostic_backend/cloudsearch/index.rb', line 5

def domain_name
  @domain_name
end

#regionObject (readonly)

Returns the value of attribute region.



5
6
7
# File 'lib/agnostic_backend/cloudsearch/index.rb', line 5

def region
  @region
end

#search_endpointObject (readonly)

Returns the value of attribute search_endpoint.



5
6
7
# File 'lib/agnostic_backend/cloudsearch/index.rb', line 5

def search_endpoint
  @search_endpoint
end

#secret_access_keyObject (readonly)

Returns the value of attribute secret_access_key.



5
6
7
# File 'lib/agnostic_backend/cloudsearch/index.rb', line 5

def secret_access_key
  @secret_access_key
end

Instance Method Details

#cloudsearch_clientObject



38
39
40
# File 'lib/agnostic_backend/cloudsearch/index.rb', line 38

def cloudsearch_client
  @cloudsearch_client ||= Aws::CloudSearch::Client.new(region: region, access_key_id: access_key_id, secret_access_key: secret_access_key)
end

#cloudsearch_domain_clientObject



42
43
44
# File 'lib/agnostic_backend/cloudsearch/index.rb', line 42

def cloudsearch_domain_client
  @cloudsearch_domain_client ||= Aws::CloudSearchDomain::Client.new(endpoint: search_endpoint, access_key_id: access_key_id, secret_access_key: secret_access_key)
end

#configureObject



34
35
36
# File 'lib/agnostic_backend/cloudsearch/index.rb', line 34

def configure
  define_fields_in_domain(indexer.flatten(schema))
end

#indexerObject



22
23
24
# File 'lib/agnostic_backend/cloudsearch/index.rb', line 22

def indexer
  AgnosticBackend::Cloudsearch::Indexer.new(self)
end

#query_builderObject



26
27
28
# File 'lib/agnostic_backend/cloudsearch/index.rb', line 26

def query_builder
  AgnosticBackend::Queryable::Cloudsearch::QueryBuilder.new(self)
end

#schemaObject



30
31
32
# File 'lib/agnostic_backend/cloudsearch/index.rb', line 30

def schema
  @schema ||= @indexable_klass.schema{|ftype| ftype}
end