Module: Esse
- Extended by:
- Forwardable
- Includes:
- Logging
- Defined in:
- lib/esse/index/mappings.rb,
lib/esse.rb,
lib/esse/cli.rb,
lib/esse/core.rb,
lib/esse/index.rb,
lib/esse/config.rb,
lib/esse/errors.rb,
lib/esse/events.rb,
lib/esse/cluster.rb,
lib/esse/logging.rb,
lib/esse/plugins.rb,
lib/esse/version.rb,
lib/esse/cli/base.rb,
lib/esse/document.rb,
lib/esse/cli/index.rb,
lib/esse/transport.rb,
lib/esse/collection.rb,
lib/esse/events/bus.rb,
lib/esse/index/base.rb,
lib/esse/index/type.rb,
lib/esse/repository.rb,
lib/esse/import/bulk.rb,
lib/esse/cli/generate.rb,
lib/esse/events/event.rb,
lib/esse/index/search.rb,
lib/esse/search/query.rb,
lib/esse/hash_document.rb,
lib/esse/index/actions.rb,
lib/esse/index/aliases.rb,
lib/esse/index/indices.rb,
lib/esse/index/plugins.rb,
lib/esse/index_mapping.rb,
lib/esse/index_setting.rb,
lib/esse/null_document.rb,
lib/esse/cli/index/open.rb,
lib/esse/cluster_engine.rb,
lib/esse/index/settings.rb,
lib/esse/cli/index/close.rb,
lib/esse/cli/index/reset.rb,
lib/esse/index/documents.rb,
lib/esse/search/response.rb,
lib/esse/template_loader.rb,
lib/esse/cli/index/create.rb,
lib/esse/cli/index/delete.rb,
lib/esse/cli/index/import.rb,
lib/esse/dynamic_template.rb,
lib/esse/events/publisher.rb,
lib/esse/index/attributes.rb,
lib/esse/search/query/dsl.rb,
lib/esse/transport/health.rb,
lib/esse/transport/search.rb,
lib/esse/index/descendants.rb,
lib/esse/index/inheritance.rb,
lib/esse/primitives/output.rb,
lib/esse/transport/aliases.rb,
lib/esse/transport/indices.rb,
lib/esse/cli/event_listener.rb,
lib/esse/deprecations/index.rb,
lib/esse/primitives/hstring.rb,
lib/esse/repository/actions.rb,
lib/esse/import/request_body.rb,
lib/esse/transport/documents.rb,
lib/esse/deprecations/cluster.rb,
lib/esse/lazy_document_header.rb,
lib/esse/repository/documents.rb,
lib/esse/cli/extensions_loader.rb,
lib/esse/primitives/hash_utils.rb,
lib/esse/deprecations/deprecate.rb,
lib/esse/primitives/array_utils.rb,
lib/esse/deprecations/repository.rb,
lib/esse/deprecations/serializer.rb,
lib/esse/document_lazy_attribute.rb,
lib/esse/cli/index/base_operation.rb,
lib/esse/cli/index/update_aliases.rb,
lib/esse/cli/index/update_mapping.rb,
lib/esse/cli/index/update_settings.rb,
lib/esse/index/object_document_mapper.rb,
lib/esse/repository/object_document_mapper.rb,
lib/esse/repository/lazy_document_attributes.rb,
lib/esse/deprecations/index_backend_delegator.rb,
lib/esse/deprecations/repository_backend_delegator.rb
Overview
The es 7.6 deprecate the mapping definition under the type level. That’s why we have option to define mappings under both Type and Index. If the index mapping is defined. All the Type mapping will be ignored. Source: www.elastic.co/guide/en/elasticsearch/reference/7.6/removal-of-types.html
Defined Under Namespace
Modules: ArrayUtils, CLI, Deprecations, Events, HashUtils, Import, Logging, Output, Plugins, Search Classes: Cluster, ClusterEngine, Collection, Config, Document, DocumentLazyAttribute, DynamicTemplate, Error, HashDocument, Hstring, Index, IndexMapping, IndexSetting, LazyDocumentHeader, NullDocument, Repository, Serializer, TemplateLoader, Transport
Constant Summary collapse
- SETTING_ROOT_KEY =
:settings
- MAPPING_ROOT_KEY =
:mappings
- DEFAULT_REPO_NAME =
'default'
- CLI_IGNORE_OPTS =
%i[ require silent ].freeze
- CLI_CONFIG_PATHS =
%w[ Essefile config/esse.rb config/initializers/esse.rb ].freeze
- VERSION =
'0.3.5'
Class Method Summary collapse
- .config {|@config| ... } ⇒ Object (also: configure)
-
.doc_id!(hash, delete: %w[_id],, keep: %w[id])) ⇒ Array([Integer, String, nil], Hash)
Simple helper used to fetch Hash value using Symbol and String keys.
- .document?(object) ⇒ Boolean
- .eager_load_indices! ⇒ Object
-
.synchronize(&block) ⇒ Object
Unless in single threaded mode, protects access to any mutable global data structure in Esse.
-
.timestamp ⇒ Object
Generates an unique timestamp to be used as a index suffix.
Methods included from Logging
Class Method Details
.config {|@config| ... } ⇒ Object Also known as: configure
30 31 32 33 34 |
# File 'lib/esse/config.rb', line 30 def config @config ||= Config.new yield(@config) if block_given? @config end |
.doc_id!(hash, delete: %w[_id],, keep: %w[id])) ⇒ Array([Integer, String, nil], Hash)
Simple helper used to fetch Hash value using Symbol and String keys.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/esse/core.rb', line 54 def self.doc_id!(hash, delete: %w[_id], keep: %w[id]) return unless hash.is_a?(Hash) id = nil modified = nil Array(delete).each do |key| k = key.to_s if hash.key?(key.to_s) k ||= key.to_sym if hash.key?(key.to_sym) next unless k modified ||= hash.dup id = modified.delete(k) break if id end return [id, modified] if id modified ||= hash Array(keep).each do |key| id = modified[key.to_s] || modified[key.to_sym] break if id end [id, modified] end |
.document?(object) ⇒ Boolean
89 90 91 92 93 |
# File 'lib/esse/core.rb', line 89 def self.document?(object) return false unless object !!(object.is_a?(Esse::Document) && object.id) end |
.eager_load_indices! ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/esse/core.rb', line 78 def self.eager_load_indices! return false unless Esse.config.indices_directory.exist? Dir[Esse.config.indices_directory.join('**/*_index.rb')].map { |path| Pathname.new(path) }.each do |path| next unless path.extname == '.rb' require(path..to_s) end true end |
.synchronize(&block) ⇒ Object
Unless in single threaded mode, protects access to any mutable global data structure in Esse. Uses a non-reentrant mutex, so calling code should be careful. In general, this should only be used around the minimal possible code such as Hash#[], Hash#[]=, Hash#delete, Array#<<, and Array#delete.
37 38 39 |
# File 'lib/esse/core.rb', line 37 def self.synchronize(&block) @single_threaded ? yield : @data_mutex.synchronize(&block) end |
.timestamp ⇒ Object
Generates an unique timestamp to be used as a index suffix. Time.now.to_i could also do the job. But I think this format is more readable for humans
44 45 46 |
# File 'lib/esse/core.rb', line 44 def self. Time.now.strftime('%Y%m%d%H%M%S') end |