Class: AgnosticBackend::Elasticsearch::Index

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

Instance Attribute Summary collapse

Attributes inherited from Index

#options

Instance Method Summary collapse

Methods inherited from Index

#initialize, #name, #parse_option, #primary?

Constructor Details

This class inherits a constructor from AgnosticBackend::Index

Instance Attribute Details

#enable_allObject (readonly)

Returns the value of attribute enable_all.



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

def enable_all
  @enable_all
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



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

def endpoint
  @endpoint
end

#index_nameObject (readonly)

Returns the value of attribute index_name.



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

def index_name
  @index_name
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#clientObject



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

def client
  @client ||= AgnosticBackend::Elasticsearch::Client.new(endpoint: endpoint)
end

#configureObject



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

def configure
  body = mappings(indexer.flatten(schema))
  client.send_request(:put, path: "#{index_name}/_mapping/#{type}", body: body)
end

#createObject



31
32
33
# File 'lib/agnostic_backend/elasticsearch/index.rb', line 31

def create
  client.send_request(:put, path: index_name)
end

#destroy!Object



35
36
37
# File 'lib/agnostic_backend/elasticsearch/index.rb', line 35

def destroy!
  client.send_request(:delete, path: index_name)
end

#exists?Boolean

Returns:

  • (Boolean)


39
40
41
42
# File 'lib/agnostic_backend/elasticsearch/index.rb', line 39

def exists?
  response = client.send_request(:head, path: index_name)
  response.success?
end

#indexerObject



10
11
12
# File 'lib/agnostic_backend/elasticsearch/index.rb', line 10

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

#query_builderObject



14
15
16
# File 'lib/agnostic_backend/elasticsearch/index.rb', line 14

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

#schemaObject



18
19
20
# File 'lib/agnostic_backend/elasticsearch/index.rb', line 18

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