Class: ActiveRecord::ConnectionAdapters::ElasticsearchAdapter

Constant Summary collapse

ADAPTER_NAME =
"Elasticsearch"
BASE_STRUCTURE =

defines the Elasticsearch 'base' structure, which is always included but cannot be resolved through mappings ...

[
  { 'name' => '_id', 'type' => 'keyword', 'virtual' => true, 'enabled' => true, 'meta' => { 'primary_key' => 'true' } },
  { 'name' => '_index', 'type' => 'keyword', 'virtual' => true },
  { 'name' => '_score', 'type' => 'float', 'virtual' => true },
  { 'name' => '_type', 'type' => 'keyword', 'virtual' => true },
  { 'name' => '_ignored', 'type' => 'boolean', 'virtual' => true }
].freeze
TYPE_MAP =

reinitialize the constant with new types

ActiveRecord::Type::HashLookupTypeMap.new.tap { |m| initialize_type_map(m) }
NATIVE_DATABASE_TYPES =

define native types - which will be used for schema-dumping

{
  primary_key: { name: 'long' },
  string:      { name: 'keyword' },
  blob:        { name: 'binary' },
  datetime:    { name: 'date' },
  bigint:      { name: 'long' },
  json:        { name: 'object' }
}.merge(
  TYPE_MAP.keys.map { |key| [key.to_sym, { name: key }] }.to_h
)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ElasticsearchAdapter

Returns a new instance of ElasticsearchAdapter.



148
149
150
151
152
153
154
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 148

def initialize(*args)
  super(*args)

  # prepared statements are not supported by Elasticsearch.
  # documentation for mysql prepares statements @ https://dev.mysql.com/doc/refman/8.0/en/sql-prepared-statements.html
  @prepared_statements = false
end

Class Method Details

.base_structure_keysObject



62
63
64
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 62

def base_structure_keys
  @base_structure_keys ||= BASE_STRUCTURE.map { |struct| struct['name'] }.freeze
end

.new_client(config) ⇒ Object



66
67
68
69
70
71
72
73
74
75
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 66

def new_client(config)
  # IMPORTANT: remove +adapter+ from config - otherwise we mess up with Faraday::AdapterRegistry
  client = ::Elasticsearch::Client.new(config.except(:adapter))
  client.ping unless config[:ping] == false
  client
rescue ::Elastic::Transport::Transport::Errors::Unauthorized
  raise ActiveRecord::DatabaseConnectionError.username_error(config[:username])
rescue ::Elastic::Transport::Transport::ServerError => error
  raise ::ActiveRecord::ConnectionNotEstablished, error.message
end

Instance Method Details

#access_id_fielddata?Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

returns true if the cluster option 'id_field_data' is enabled or not configured. This is required to check if a general sorting on the +_id+-field is possible or not.

Returns:

  • (Boolean)

#add_alias(table_name, name, **options, &block) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

-- alias ---------------------------------------------------------------------------------------------------

#add_mapping(table_name, name, type, **options, &block) ⇒ Object Also known as: add_column Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

-- mapping -------------------------------------------------------------------------------------------------

#add_setting(table_name, name, value, **options, &block) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

-- setting -------------------------------------------------------------------------------------------------

#alias_exists?(table_name, alias_name) ⇒ Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

Checks to see if a alias +alias_name+ within a table +table_name+ exists on the database.

alias_exists?(:developers, 'my-alias')

Parameters:

  • table_name (String)
  • alias_name (String, Symbol)

Returns:

  • (Boolean)

#api(namespace, action, arguments = {}, name = 'API', async: false) ⇒ Elasticsearch::API::Response, Object

calls the +elasticsearch-api+ endpoints by provided namespace and action. if a block was provided it'll yield the response.body and returns the blocks result. otherwise it will return the response itself...

Parameters:

  • namespace (Symbol)
    • the API namespace (e.g. indices, nodes, sql, ...)
  • action (Symbol)
    • the API action to call in tha namespace
  • arguments (Hash) (defaults to: {})
    • action arguments
  • name (String (frozen)) (defaults to: 'API')
    • the logging name
  • async (Boolean) (defaults to: false)
    • send async (default: false) - currently not supported

Returns:

  • (Elasticsearch::API::Response, Object)

Raises:

  • (::StandardError)


220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 220

def api(namespace, action, arguments = {}, name = 'API', async: false)
  raise ::StandardError, 'ASYNC api calls are not supported' if async

  # resolve the API target
  target = namespace == :core ? @connection : @connection.__send__(namespace)

  log("#{namespace}.#{action}", arguments, name, async: async) do
    response = ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
      target.__send__(action, arguments)
    end

    if response.is_a?(::Elasticsearch::API::Response)
      # reverse information for the LogSubscriber - shows the 'query-time' in the logs
      # this works, since we use a referenced hash ...
      arguments[:_qt] = response['took']

      # raise timeouts
      raise(ActiveRecord::StatementTimeout, "Elasticsearch api request failed due a timeout") if response['timed_out']
    end

    response
  end
end

#assume_migrated_upto_version(version) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

#block_table(table_name, block_name = :write) ⇒ Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

blocks access to the provided table (index) and +block+ name.

Parameters:

  • table_name (String)
  • block_name (Symbol) (defaults to: :write)

    The block to add (one of :read, :write, :read_only or :metadata)

Returns:

  • (Boolean)

    acknowledged status

#change_alias(table_name, name, **options, &block) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

#change_mapping(table_name, name, type, **options, &block) ⇒ Object Also known as: change_column Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

#change_mapping_attributes(table_name, name, **options, &block) ⇒ Object Also known as: change_mapping_attribute Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

#change_mapping_meta(table_name, name, **options) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

#change_meta(table_name, name, value, **options) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

#change_setting(table_name, name, value, **options, &block) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

#change_table(table_name, **options) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

A block for changing mappings, settings & aliases in +table+.

# change_table() yields a ChangeTableDefinition instance change_table(:suppliers) do |t| t.mapping :name, :string # Other column alterations here end

#clone_table(table_name, target_name, **options, &block) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

clones an entire table to the provided +target_name+. During cloning, the table will be automatically 'write'-blocked.

Parameters:

  • table_name (String)
  • target_name (String)
  • options (Hash)
  • block (Proc)

#clone_table_definition(name, target, **options) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

#close_table(table_name) ⇒ Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

Closes an index.

Parameters:

  • table_name (String)

Returns:

  • (Boolean)

    acknowledged status

#close_tables(*table_names) ⇒ Array Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

Closes indices by provided names.

Parameters:

  • table_names (Array)

Returns:

  • (Array)

    acknowledged status for each provided table

#cluster_infoHash{Symbol->Unknown Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

Returns basic information about the cluster.

Returns:

  • (Hash{Symbol->Unknown)

    ]

#cluster_settingsHash Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

returns a hash of current set, none-default settings in flat

Returns:

  • (Hash)

#column_definitions(table_name) ⇒ Array<Hash> Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

Returns the list of a table's column names, data types, and default values.

Parameters:

  • table_name (String)

Returns:

  • (Array<Hash>)

See Also:

  • SchemaStatements#columns
  • AbstractMysqlAdapter#column_definitions

#create_schema_dumper(options) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

overwrite original methods to provide a elasticsearch version

#create_table(table_name, force: false, copy_from: nil, if_not_exists: false, **options) ⇒ Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

creates a new table (index). [:force] Set to +true+ to drop an existing table Defaults to false. [:copy_from] Set to an existing index, to copy it's schema. [:if_not_exists] Set to +true+ to skip creation if table already exists. Defaults to false.

Parameters:

  • table_name (String)
  • force (Boolean) (defaults to: false)
    • force a drop on the existing table (default: false)
  • copy_from (nil, String) (defaults to: nil)
    • copy schema from existing table
  • options (Hash)

Returns:

  • (Boolean)

    acknowledged status

#create_table_definition(name, **options) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

overwrite original methods to provide a elasticsearch version

#data_source_exists?(name) ⇒ Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

Checks to see if the data source +name+ exists on the database.

data_source_exists?(:ebooks)

Parameters:

  • name (String, Symbol)

Returns:

  • (Boolean)

See Also:

  • SchemaStatements#data_source_exists?

#data_sourcesArray<String> Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

Returns the relation names usable to back Active Record models. For Elasticsearch this means all indices - which also includes system +dot+ '.' indices.

Returns:

  • (Array<String>)

See Also:

  • SchemaStatements#data_sources

#delete_alias(table_name, name, **options, &block) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

#delete_meta(table_name, name, **options) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

#delete_setting(table_name, name, **options, &block) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

#drop_table(table_name, if_exists: false) ⇒ Array Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

drops an index [:if_exists] Set to +true+ to only drop the table if it exists. Defaults to false.

Parameters:

  • table_name (String)
  • if_exists (Boolean) (defaults to: false)

Returns:

  • (Array)

    acknowledged status

#exec_delete(query, name = nil, binds = []) ⇒ Integer Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::DatabaseStatements

Executes delete +query+ statement in the context of this connection using +binds+ as the bind substitutes. +name+ is logged along with the executed +query+ arguments. expects a integer as return.

Returns:

  • (Integer)

#exec_insert(query, name = nil, binds = [], _pk = nil, _sequence_name = nil) ⇒ ElasticsearchRecord::Result Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::DatabaseStatements

Executes insert +query+ statement in the context of this connection using +binds+ as the bind substitutes. +name+ is logged along with the executed +query+ arguments.

#exec_query(query, name = "QUERY", binds = [], prepare: false, async: false) ⇒ ElasticsearchRecord::Result Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::DatabaseStatements

gets called for all queries - a +ElasticsearchRecord::Query+ must be provided.

Parameters:

  • query (ElasticsearchRecord::Query)
  • name (String (frozen)) (defaults to: "QUERY")
  • binds (Array) (defaults to: [])
    • not supported on the top-level and therefore ignored!
  • prepare (Boolean) (defaults to: false)
    • used by the default AbstractAdapter - but not supported and therefore never ignored!
  • async (Boolean) (defaults to: false)

Returns:

#exec_update(query, name = nil, binds = []) ⇒ Integer Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::DatabaseStatements

Executes update +query+ statement in the context of this connection using +binds+ as the bind substitutes. +name+ is logged along with the executed +query+ arguments. expects a integer as return.

Returns:

  • (Integer)

#execute(query, name = nil, async: false) ⇒ ElasticsearchRecord::Result Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::DatabaseStatements

Executes the query object in the context of this connection and returns the raw result from the connection adapter.

Parameters:

Returns:

Raises:

  • (ActiveRecord::StatementInvalid)

#last_inserted_id(result) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::DatabaseStatements

returns the last inserted id from the result. called through +#insert+

#lookup_cast_type_from_column(column) ⇒ ActiveRecord::ConnectionAdapters::Elasticsearch::Type::MulticastValue Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

lookups from building the @columns_hash. since Elasticsearch has the "feature" to provide multicast values on any type, we need to fetch them ... you know, ES can return an integer or an array of integers for any column ...

#mapping_exists?(table_name, mapping_name, type = nil) ⇒ Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

Checks to see if a mapping +mapping_name+ within a table +table_name+ exists on the database.

mapping_exists?(:developers, :status, :integer)

Parameters:

  • table_name (String, Symbol)
  • mapping_name (String, Symbol)

Returns:

  • (Boolean)

#max_result_window(table_name) ⇒ Integer Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

returns the maximum allowed size for queries for the provided +table_name+. The query will raise an ActiveRecord::StatementInvalid if the requested limit is above this value.

Returns:

  • (Integer)

#meta_exists?(table_name, meta_name) ⇒ Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

Checks to see if a meta +meta_name+ within a table +table_name+ exists on the database.

meta_exists?(:developers, 'class')

Parameters:

  • table_name (String)
  • meta_name (String, Symbol)

Returns:

  • (Boolean)

#migrations_pathsObject

overwrite method to provide a Elasticsearch path



171
172
173
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 171

def migrations_paths
  @config[:migrations_paths] || ['db/migrate_elasticsearch']
end

#native_database_typesHash

returns a hash of 'ActiveRecord types' -> 'Elasticsearch types' (defined @ +NATIVE_DATABASE_TYPES+)

Returns:

  • (Hash)


207
208
209
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 207

def native_database_types # :nodoc:
  NATIVE_DATABASE_TYPES
end

#new_column_from_field(_table_name, field) ⇒ ActiveRecord::ConnectionAdapters::Column Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

creates a new column object from provided field Hash

Parameters:

  • _table_name (String)
  • field (Hash)

Returns:

  • (ActiveRecord::ConnectionAdapters::Column)

See Also:

  • SchemaStatements#columns
  • MySQL::SchemaStatements#new_column_from_field

#open_table(table_name) ⇒ Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

Opens a closed index.

Parameters:

  • table_name (String)

Returns:

  • (Boolean)

    acknowledged status

#open_tables(*table_names) ⇒ Array Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

Opens closed indices.

Parameters:

  • table_names (Array)

Returns:

  • (Array)

    acknowledged status for each provided table

#primary_keys(table_name) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

Returns a array of tables primary keys. PLEASE NOTE: Elasticsearch does not have a concept of primary key. The only thing that uniquely identifies a document is the index together with the +_id+. To support this concept we simulate this through the +_meta+ field (from the index).

As a alternative, the primary_key can also be provided through the mappings +meta+ field.

see @ https://www.elastic.co/guide/en/elasticsearch/reference/8.5/mapping-meta-field.html

Parameters:

  • table_name (String)

See Also:

  • AbstractMysqlAdapter#primary_keys

#quoted_falseObject Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::Quoting

#quoted_trueObject Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::Quoting

#schema_creationObject Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

overwrite original methods to provide a elasticsearch version

#schema_migrationObject

:nodoc:



156
157
158
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 156

def schema_migration # :nodoc:
  @schema_migration ||= ElasticsearchRecord::SchemaMigration
end

#select_count(arel, name = "Count", async: false) ⇒ Integer Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::DatabaseStatements

executes a count query for provided arel

Returns:

  • (Integer)

#select_multiple(arels, name = "Multi", async: false) ⇒ ElasticsearchRecord::Result Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::DatabaseStatements

executes a msearch for provided arels

#setting_exists?(table_name, setting_name) ⇒ Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

Checks to see if a setting +setting_name+ within a table +table_name+ exists on the database. The provided +setting_name+ must be flat!

setting_exists?(:developers, 'index.number_of_replicas')

Parameters:

  • table_name (String)
  • setting_name (String, Symbol)

Returns:

  • (Boolean)

#supports_comments?Boolean

Does this adapter support metadata comments on database objects (tables)? PLEASE NOTE: Elasticsearch does only support comments on mappings as 'meta' information. This method only relies to create comments on tables (indices) and is therefore not supported. see @ ActiveRecord::ConnectionAdapters::SchemaStatements#create_table

Returns:

  • (Boolean)


190
191
192
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 190

def supports_comments?
  false
end

#supports_comments_in_create?Boolean

Can comments for tables, columns, and indexes be specified in create/alter table statements? see @ ActiveRecord::ConnectionAdapters::ElasticsearchAdapter#supports_comments?

Returns:

  • (Boolean)


196
197
198
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 196

def supports_comments_in_create?
  false
end

#supports_explain?Boolean

Does this adapter support explain?

Returns:

  • (Boolean)


176
177
178
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 176

def supports_explain?
  false
end

#supports_indexes_in_create?Boolean

Does this adapter support creating indexes in the same statement as creating the table?

Returns:

  • (Boolean)


182
183
184
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 182

def supports_indexes_in_create?
  false
end

#table_aliases(table_name) ⇒ Hash Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

returns a hash of all aliases by provided table_name (index).

Parameters:

  • table_name (String)

Returns:

  • (Hash)

#table_exists?(table_name) ⇒ Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

Checks to see if the table +table_name+ exists on the database.

table_exists?(:developers)

Parameters:

  • table_name (String, Symbol)

Returns:

  • (Boolean)

See Also:

  • SchemaStatements#table_exists?

#table_mappings(table_name) ⇒ Hash Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

returns a hash of all mappings by provided table_name (index)

Parameters:

  • table_name (String)

Returns:

  • (Hash)

#table_metas(table_name) ⇒ Hash Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

returns a hash of all meta data by provided table_name (index). HINT: +_meta+ is resolved from the table mappings

Parameters:

  • table_name (String)

Returns:

  • (Hash)

#table_name_prefixObject

provide a table_name_prefix from the configuration to create & restrict schema creation



161
162
163
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 161

def table_name_prefix
  @config.fetch(:table_name_prefix, '')
end

#table_name_suffixObject

provide a table_name_suffix from the configuration to create & restrict schema creation



166
167
168
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 166

def table_name_suffix
  @config.fetch(:table_name_suffix, '')
end

#table_schema(table_name, features = [:aliases, :mappings, :settings]) ⇒ Hash Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

returns a hash of the full definition of the provided table_name (index). (includes settings, mappings & aliases)

Parameters:

  • table_name (String)
  • features (Array, Symbol) (defaults to: [:aliases, :mappings, :settings])

Returns:

  • (Hash)

#table_settings(table_name, flat_settings = true) ⇒ Hash Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

returns a hash of all settings by provided table_name

Parameters:

  • table_name (String)
  • flat_settings (Boolean) (defaults to: true)

    (default: true)

Returns:

  • (Hash)

#table_state(table_name) ⇒ Hash Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

returns information about number of primaries and replicas, document counts, disk size, ... by provided table_name (index).

Parameters:

  • table_name (String)

Returns:

  • (Hash)

#tablesArray<String> Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

Returns an array of table names defined in the database. For Elasticsearch this means all normal indices (no system +dot+ '.' indices)

Returns:

  • (Array<String>)

See Also:

  • SchemaStatements#tables

#truncate_table(table_name) ⇒ Boolean Also known as: truncate Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

truncates index by provided name. HINT: Elasticsearch does not have a +truncate+ concept:

  • so we have to store the current index' schema
  • drop the index
  • and create it again

Parameters:

  • table_name (String)

Returns:

  • (Boolean)

    acknowledged status

#truncate_tables(*table_names) ⇒ Array Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

truncate indices by provided names.

Parameters:

  • table_names (Array)

Returns:

  • (Array)

    acknowledged status for each provided table

#type_to_sql(type) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

transforms provided schema-type to a sql-type overwrite original methods to provide a elasticsearch version

Parameters:

  • type (String, Symbol)

#unblock_table(table_name, block_name = nil) ⇒ Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::TableStatements

unblocks access to the provided table (index) and +block+ name. provide a nil-value to unblock all blocks, otherwise provide the blocked name.

Parameters:

  • table_name (String)
  • block_name (Symbol) (defaults to: nil)

    The block to add (one of :read, :write, :read_only or :metadata)

Returns:

  • (Boolean)

    acknowledged status

#update_table_definition(name, base = self, **options) ⇒ Object Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::SchemaStatements

overwrite original methods to provide a elasticsearch version

#use_metadata_table?Boolean

disable metadata tables

Returns:

  • (Boolean)


201
202
203
# File 'lib/active_record/connection_adapters/elasticsearch_adapter.rb', line 201

def  # :nodoc:
  false
end

#write_query?(query) ⇒ Boolean Originally defined in module ActiveRecord::ConnectionAdapters::Elasticsearch::DatabaseStatements

detects if a query is a write query. since we don't provide a simple string / hash we can now access the query-object and ask for it :)

Parameters:

Returns:

  • (Boolean)

See Also:

  • DatabaseStatements#write_query?