Module: Elasticsearch::Persistence::Repository
- Defined in:
- lib/elasticsearch/persistence/repository.rb,
lib/elasticsearch/persistence/repository/dsl.rb,
lib/elasticsearch/persistence/repository/find.rb,
lib/elasticsearch/persistence/repository/store.rb,
lib/elasticsearch/persistence/repository/search.rb,
lib/elasticsearch/persistence/repository/serialize.rb,
lib/elasticsearch/persistence/repository/response/results.rb
Overview
The base Repository mixin. This module should be included in classes that represent an Elasticsearch repository.
Defined Under Namespace
Modules: ClassMethods, DSL, Find, Response, Search, Serialize, Store Classes: DocumentNotFound
Constant Summary collapse
- DEFAULT_INDEX_NAME =
The default index name.
'repository'.freeze
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
The repository options.
Class Method Summary collapse
Instance Method Summary collapse
-
#client ⇒ Elasticsearch::Client
Get the client used by the repository.
-
#index_exists?(*args) ⇒ true, false
Determine whether the index with this repository’s index name exists.
-
#index_name ⇒ String, Symbol
Get the index name used by the repository.
-
#initialize(options = {}) ⇒ Object
Initialize a repository instance.
-
#inspect ⇒ String
Get the nicer formatted string for use in inspection.
-
#klass ⇒ Class
Get the class used by the repository when deserializing.
-
#mapping(*args) ⇒ Elasticsearch::Model::Indexing::Mappings
(also: #mappings)
Get the index mapping.
-
#settings(*args) ⇒ Elasticsearch::Model::Indexing::Settings
Get the index settings.
Methods included from Search
Methods included from Find
Methods included from Serialize
Methods included from Store
Instance Attribute Details
#options ⇒ Hash (readonly)
The repository options.
87 88 89 |
# File 'lib/elasticsearch/persistence/repository.rb', line 87 def @options end |
Class Method Details
.included(base) ⇒ Object
38 39 40 |
# File 'lib/elasticsearch/persistence/repository.rb', line 38 def self.included(base) base.send(:extend, ClassMethods) end |
Instance Method Details
#client ⇒ Elasticsearch::Client
Get the client used by the repository.
116 117 118 119 120 |
# File 'lib/elasticsearch/persistence/repository.rb', line 116 def client @client ||= @options[:client] || __get_class_value(:client) || Elasticsearch::Client.new end |
#index_exists?(*args) ⇒ true, false
Determine whether the index with this repository’s index name exists.
203 204 205 |
# File 'lib/elasticsearch/persistence/repository.rb', line 203 def index_exists?(*args) super end |
#index_name ⇒ String, Symbol
Get the index name used by the repository.
130 131 132 133 134 |
# File 'lib/elasticsearch/persistence/repository.rb', line 130 def index_name @index_name ||= @options[:index_name] || __get_class_value(:index_name) || DEFAULT_INDEX_NAME end |
#initialize(options = {}) ⇒ Object
Initialize a repository instance.
104 105 106 |
# File 'lib/elasticsearch/persistence/repository.rb', line 104 def initialize( = {}) @options = end |
#inspect ⇒ String
Get the nicer formatted string for use in inspection.
215 216 217 |
# File 'lib/elasticsearch/persistence/repository.rb', line 215 def inspect "#<#{self.class}:0x#{object_id} index_name=#{index_name} klass=#{klass}>" end |
#klass ⇒ Class
Get the class used by the repository when deserializing.
144 145 146 |
# File 'lib/elasticsearch/persistence/repository.rb', line 144 def klass @klass ||= @options[:klass] || __get_class_value(:klass) end |
#mapping(*args) ⇒ Elasticsearch::Model::Indexing::Mappings Also known as: mappings
If mappings were set when the repository was created, a block passed to this method will not be evaluated.
Get the index mapping. Optionally pass a block to define the mappings.
end
165 166 167 168 169 170 171 |
# File 'lib/elasticsearch/persistence/repository.rb', line 165 def mapping(*args) @memoized_mapping ||= @options[:mapping] || (begin if _mapping = __get_class_value(:mapping) _mapping end end) || (super && @mapping) end |
#settings(*args) ⇒ Elasticsearch::Model::Indexing::Settings
Get the index settings.
191 192 193 |
# File 'lib/elasticsearch/persistence/repository.rb', line 191 def settings(*args) @memoized_settings ||= @options[:settings] || __get_class_value(:settings) || (super && @settings) end |