diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.put_mapping/10_basic.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.put_mapping/10_basic.yml index f3389898f0f64..67419cd18ad99 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.put_mapping/10_basic.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.put_mapping/10_basic.yml @@ -145,28 +145,6 @@ - is_false: test_index.mappings.properties.foo.meta.bar - match: { test_index.mappings.properties.foo.meta.baz: "quux" } ---- -"disabling synthetic source fails": - - requires: - cluster_features: ["gte_v8.4.0"] - reason: "Added in 8.4.0" - - - do: - indices.create: - index: test_index - body: - settings: - index: - mapping.source.mode: synthetic - - - do: - catch: /Cannot update parameter \[mode\] from \[synthetic\] to \[stored\]/ - indices.put_mapping: - index: test_index - body: - _source: - mode: stored - --- "enabling synthetic source from explicit succeeds": - requires: diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/mget/90_synthetic_source.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/mget/90_synthetic_source.yml index 73642a445dee0..c728252d98201 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/mget/90_synthetic_source.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/mget/90_synthetic_source.yml @@ -197,7 +197,7 @@ force_synthetic_source_ok: body: settings: index: - mapping.source.mode: synthetic + mapping.source.mode: stored mappings: properties: obj: diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.highlight/50_synthetic_source.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.highlight/50_synthetic_source.yml index 9c8c16db8bcdd..024ce48562281 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.highlight/50_synthetic_source.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.highlight/50_synthetic_source.yml @@ -21,6 +21,7 @@ setup: index_options: positions vectors: type: text + store: false term_vector: with_positions_offsets positions: type: text diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/400_synthetic_source.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/400_synthetic_source.yml index 6cfac46706a6d..21338c12415d8 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/400_synthetic_source.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/400_synthetic_source.yml @@ -168,7 +168,7 @@ force_synthetic_source_ok: body: settings: index: - mapping.source.mode: synthetic + mapping.source.mode: stored mappings: properties: obj: diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/20_mapping.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/20_mapping.yml index d702176b7ec3c..4fe4a7d2e2f51 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/20_mapping.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/20_mapping.yml @@ -472,6 +472,8 @@ stored source is supported: time_series: start_time: 2021-04-28T00:00:00Z end_time: 2021-04-29T00:00:00Z + mapping: + source.mode: stored mappings: properties: "@timestamp": @@ -508,6 +510,8 @@ disabled source is not supported: time_series: start_time: 2021-04-28T00:00:00Z end_time: 2021-04-29T00:00:00Z + mapping: + source.mode: disabled mappings: properties: "@timestamp": diff --git a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java index 372e0bbdfecf4..1162734c0dc81 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java @@ -242,7 +242,7 @@ public SourceFieldMapper build() { } private Mode resolveSourceMode() { - // If the `index.mapper.source.mode` exists it takes precedence to determine the source mode for `_source` + // If the `index.mapping.source.mode` exists it takes precedence to determine the source mode for `_source` // otherwise the mode is determined according to `_source.mode`. if (INDEX_MAPPER_SOURCE_MODE_SETTING.exists(settings)) { return INDEX_MAPPER_SOURCE_MODE_SETTING.get(settings); @@ -439,6 +439,10 @@ public static boolean isSynthetic(IndexSettings indexSettings) { return INDEX_MAPPER_SOURCE_MODE_SETTING.get(indexSettings.getSettings()) == SourceFieldMapper.Mode.SYNTHETIC; } + public static boolean isStored(IndexSettings indexSettings) { + return INDEX_MAPPER_SOURCE_MODE_SETTING.get(indexSettings.getSettings()) == Mode.STORED; + } + public boolean isDisabled() { return mode == Mode.DISABLED; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotRepository.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotRepository.java index 698193d5c1c28..579e3fb43b194 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotRepository.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotRepository.java @@ -33,6 +33,7 @@ import org.elasticsearch.index.engine.EngineFactory; import org.elasticsearch.index.engine.ReadOnlyEngine; import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.mapper.SourceFieldMapper; import org.elasticsearch.index.store.Store; import org.elasticsearch.index.translog.TranslogStats; import org.elasticsearch.repositories.FilterRepository; @@ -134,8 +135,9 @@ private static Metadata metadataToSnapshot(Collection indices, Metadata @Override public void snapshotShard(SnapshotShardContext context) { final MapperService mapperService = context.mapperService(); - if (mapperService.documentMapper() != null // if there is no mapping this is null - && mapperService.documentMapper().sourceMapper().isComplete() == false) { + if ((mapperService.documentMapper() != null // if there is no mapping this is null + && mapperService.documentMapper().sourceMapper().isComplete() == false) + || (mapperService.documentMapper() == null && SourceFieldMapper.isStored(mapperService.getIndexSettings()) == false)) { context.onFailure( new IllegalStateException( "Can't snapshot _source only on an index that has incomplete source ie. has _source disabled or filters the source" diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotShardTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotShardTests.java index 54390365c62af..81d194ce84131 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotShardTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotShardTests.java @@ -53,6 +53,7 @@ import org.elasticsearch.index.engine.InternalEngineFactory; import org.elasticsearch.index.fieldvisitor.FieldsVisitor; import org.elasticsearch.index.mapper.SeqNoFieldMapper; +import org.elasticsearch.index.mapper.SourceFieldMapper; import org.elasticsearch.index.mapper.SourceToParse; import org.elasticsearch.index.seqno.RetentionLeaseSyncer; import org.elasticsearch.index.seqno.SeqNoStats; @@ -150,6 +151,55 @@ public void testSourceIncomplete() throws IOException { closeShards(shard); } + public void testSourceIncompleteSyntheticSourceNoDoc() throws IOException { + ShardRouting shardRouting = shardRoutingBuilder( + new ShardId("index", "_na_", 0), + randomAlphaOfLength(10), + true, + ShardRoutingState.INITIALIZING + ).withRecoverySource(RecoverySource.EmptyStoreRecoverySource.INSTANCE).build(); + Settings settings = Settings.builder() + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) + .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) + .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "synthetic") + .build(); + IndexMetadata metadata = IndexMetadata.builder(shardRouting.getIndexName()).settings(settings).primaryTerm(0, primaryTerm).build(); + IndexShard shard = newShard(shardRouting, metadata, null, new InternalEngineFactory()); + recoverShardFromStore(shard); + SnapshotId snapshotId = new SnapshotId("test", "test"); + IndexId indexId = new IndexId(shard.shardId().getIndexName(), shard.shardId().getIndex().getUUID()); + SourceOnlySnapshotRepository repository = new SourceOnlySnapshotRepository(createRepository()); + repository.start(); + try (Engine.IndexCommitRef snapshotRef = shard.acquireLastIndexCommit(true)) { + IndexShardSnapshotStatus indexShardSnapshotStatus = IndexShardSnapshotStatus.newInitializing(new ShardGeneration(-1L)); + final PlainActionFuture future = new PlainActionFuture<>(); + runAsSnapshot( + shard.getThreadPool(), + () -> repository.snapshotShard( + new SnapshotShardContext( + shard.store(), + shard.mapperService(), + snapshotId, + indexId, + new SnapshotIndexCommit(snapshotRef), + null, + indexShardSnapshotStatus, + IndexVersion.current(), + randomMillisUpToYear9999(), + future + ) + ) + ); + IllegalStateException illegalStateException = expectThrows(IllegalStateException.class, future::actionGet); + assertEquals( + "Can't snapshot _source only on an index that has incomplete source ie. has _source disabled or filters the source", + illegalStateException.getMessage() + ); + } + closeShards(shard); + } + public void testIncrementalSnapshot() throws IOException { IndexShard shard = newStartedShard(); for (int i = 0; i < 10; i++) { diff --git a/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/40_source_mode_setting.yml b/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/40_source_mode_setting.yml index 61b9a39be8ac9..f44358095de15 100644 --- a/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/40_source_mode_setting.yml +++ b/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/40_source_mode_setting.yml @@ -1,5 +1,5 @@ --- -create an index with disabled source mode and standard index mode without setting: +create an index with disabled source mode and standard index mode: - do: indices.create: index: test_disabled_standard @@ -10,13 +10,14 @@ create an index with disabled source mode and standard index mode without settin mapping.source.mode: disabled - do: - indices.get_mapping: + indices.get_settings: index: test_disabled_standard - - match: { test_disabled_standard.mappings._source.mode: disabled } + - match: { test_disabled_standard.settings.index.mode: standard } + - match: { test_disabled_standard.settings.index.mapping.source.mode: disabled } --- -create an index with stored source mode and standard index mode without setting: +create an index with stored source mode and standard index mode: - do: indices.create: index: test_stored_standard @@ -27,13 +28,14 @@ create an index with stored source mode and standard index mode without setting: mapping.source.mode: stored - do: - indices.get_mapping: + indices.get_settings: index: test_stored_standard - - match: { test_stored_standard.mappings._source.mode: stored } + - match: { test_stored_standard.settings.index.mode: standard } + - match: { test_stored_standard.settings.index.mapping.source.mode: stored } --- -create an index with synthetic source mode and standard index mode without setting: +create an index with synthetic source mode and standard index mode: - do: indices.create: index: test_synthetic_standard @@ -44,13 +46,14 @@ create an index with synthetic source mode and standard index mode without setti mapping.source.mode: synthetic - do: - indices.get_mapping: + indices.get_settings: index: test_synthetic_standard - - match: { test_synthetic_standard.mappings._source.mode: synthetic } + - match: { test_synthetic_standard.settings.index.mode: standard } + - match: { test_synthetic_standard.settings.index.mapping.source.mode: synthetic } --- -create an index with disabled source mode and logsdb index mode without setting: +create an index with disabled source mode and logsdb index mode: - do: catch: bad_request indices.create: @@ -65,7 +68,7 @@ create an index with disabled source mode and logsdb index mode without setting: - match: { error.reason: "Failed to parse mapping: _source can not be disabled in index using [logsdb] index mode" } --- -create an index with stored source mode and logsdb index mode without setting: +create an index with stored source mode and logsdb index mode: - do: indices.create: index: test_stored_logsdb @@ -81,13 +84,14 @@ create an index with stored source mode and logsdb index mode without setting: - match: { test_stored_logsdb.settings.index.mode: logsdb } - do: - indices.get_mapping: + indices.get_settings: index: test_stored_logsdb - - match: { test_stored_logsdb.mappings._source.mode: stored } + - match: { test_stored_logsdb.settings.index.mode: logsdb } + - match: { test_stored_logsdb.settings.index.mapping.source.mode: stored } --- -create an index with synthetic source mode and logsdb index mode without setting: +create an index with synthetic source mode and logsdb index mode: - do: indices.create: index: test_synthetic_logsdb @@ -98,13 +102,14 @@ create an index with synthetic source mode and logsdb index mode without setting mapping.source.mode: synthetic - do: - indices.get_mapping: + indices.get_settings: index: test_synthetic_logsdb - - match: { test_synthetic_logsdb.mappings._source.mode: synthetic } + - match: { test_synthetic_logsdb.settings.index.mode: logsdb } + - match: { test_synthetic_logsdb.settings.index.mapping.source.mode: synthetic } --- -create an index with disabled source mode and time series index mode without setting: +create an index with disabled source mode and time series index mode: - do: catch: bad_request indices.create: @@ -128,7 +133,7 @@ create an index with disabled source mode and time series index mode without set - match: { error.reason: "Failed to parse mapping: _source can not be disabled in index using [time_series] index mode" } --- -create an index with stored source mode and time series index mode without setting: +create an index with stored source mode and time series index mode: - do: indices.create: index: test_stored_time_series @@ -136,11 +141,11 @@ create an index with stored source mode and time series index mode without setti settings: index: mode: time_series + mapping.source.mode: stored routing_path: [ keyword ] time_series: start_time: 2021-04-28T00:00:00Z end_time: 2021-04-29T00:00:00Z - mapping.source.mode: stored mappings: properties: keyword: @@ -153,14 +158,15 @@ create an index with stored source mode and time series index mode without setti - match: { test_stored_time_series.settings.index.mode: time_series } - do: - indices.get_mapping: + indices.get_settings: index: test_stored_time_series - - match: { test_stored_time_series.mappings._source.mode: stored } + - match: { test_stored_time_series.settings.index.mode: time_series } + - match: { test_stored_time_series.settings.index.mapping.source.mode: stored } --- -create an index with synthetic source mode and time series index mode without setting: +create an index with synthetic source mode and time series index mode: - do: indices.create: index: test_synthetic_time_series @@ -168,6 +174,7 @@ create an index with synthetic source mode and time series index mode without se settings: index: mode: time_series + mapping.source.mode: synthetic routing_path: [ keyword ] time_series: start_time: 2021-04-28T00:00:00Z @@ -184,10 +191,11 @@ create an index with synthetic source mode and time series index mode without se - match: { test_synthetic_time_series.settings.index.mode: time_series } - do: - indices.get_mapping: + indices.get_settings: index: test_synthetic_time_series - - match: { test_synthetic_time_series.mappings._source.mode: synthetic } + - match: { test_synthetic_time_series.settings.index.mode: time_series } + - match: { test_synthetic_time_series.settings.index.mapping.source.mode: synthetic } --- create an index with stored source mode: @@ -200,10 +208,11 @@ create an index with stored source mode: mapping.source.mode: stored - do: - indices.get_mapping: + indices.get_settings: index: test_stored_default - - match: { test_stored_default.mappings._source.mode: stored } + - match: { test_stored_default.settings.index.mode: null } + - match: { test_stored_default.settings.index.mapping.source.mode: stored } --- create an index with disabled source mode: @@ -216,10 +225,11 @@ create an index with disabled source mode: mapping.source.mode: disabled - do: - indices.get_mapping: + indices.get_settings: index: test_disabled_default - - match: { test_disabled_default.mappings._source.mode: disabled } + - match: { test_disabled_default.settings.index.mode: null } + - match: { test_disabled_default.settings.index.mapping.source.mode: disabled } --- create an index with synthetic source mode: @@ -232,10 +242,11 @@ create an index with synthetic source mode: mapping.source.mode: synthetic - do: - indices.get_mapping: + indices.get_settings: index: test_synthetic_default - - match: { test_synthetic_default.mappings._source.mode: synthetic } + - match: { test_synthetic_default.settings.index.mode: null } + - match: { test_synthetic_default.settings.index.mapping.source.mode: synthetic } --- create an index with unspecified source mode: @@ -244,10 +255,11 @@ create an index with unspecified source mode: index: test_unset_default - do: - indices.get_mapping: + indices.get_settings: index: test_unset_default - - match: { test_unset_default.mappings._source.mode: null } + - match: { test_unset_default.settings.index.mode: null } + - match: { test_unset_default.settings.index.mapping.source.mode: null } --- override unspecified to stored source mode: @@ -308,157 +320,12 @@ create an index with standard index mode: mode: standard mapping.source.mode: stored - - do: - indices.get_mapping: - index: test_standard_index_mode - - - match: { test_standard_index_mode.mappings._source.mode: stored } - ---- -create an index with time_series index mode and synthetic source: - - do: - indices.create: - index: test_time_series_index_mode_synthetic - body: - settings: - index: - mode: time_series - mapping.source.mode: synthetic - routing_path: [ keyword ] - time_series: - start_time: 2021-04-28T00:00:00Z - end_time: 2021-04-29T00:00:00Z - mappings: - properties: - keyword: - type: keyword - time_series_dimension: true - - - do: - indices.get_settings: - index: "test_time_series_index_mode_synthetic" - - match: { test_time_series_index_mode_synthetic.settings.index.mode: time_series } - - - - do: - indices.get_mapping: - index: test_time_series_index_mode_synthetic - - - match: { test_time_series_index_mode_synthetic.mappings._source.mode: synthetic } - ---- -create an index with logsdb index mode and synthetic source: - - do: - indices.create: - index: test_logsdb_index_mode_synthetic - body: - settings: - index: - mode: logsdb - mapping.source.mode: synthetic - - do: indices.get_settings: - index: "test_logsdb_index_mode_synthetic" - - match: { test_logsdb_index_mode_synthetic.settings.index.mode: logsdb } - - - do: - indices.get_mapping: - index: test_logsdb_index_mode_synthetic - - - match: { test_logsdb_index_mode_synthetic.mappings._source.mode: synthetic } - ---- -create an index with time_series index mode and stored source: - - do: - indices.create: - index: test_time_series_index_mode_undefined - body: - settings: - index: - mode: time_series - mapping.source.mode: stored - routing_path: [ keyword ] - time_series: - start_time: 2021-04-28T00:00:00Z - end_time: 2021-04-29T00:00:00Z - mappings: - properties: - keyword: - type: keyword - time_series_dimension: true - - - do: - indices.get_settings: - index: "test_time_series_index_mode_undefined" - - match: { test_time_series_index_mode_undefined.settings.index.mode: time_series } - - - do: - indices.get_mapping: - index: test_time_series_index_mode_undefined - - - match: { test_time_series_index_mode_undefined.mappings._source.mode: stored } - ---- -create an index with logsdb index mode and stored source: - - do: - indices.create: - index: test_logsdb_index_mode_undefined - body: - settings: - index: - mode: logsdb - mapping.source.mode: stored - - - do: - indices.get_settings: - index: "test_logsdb_index_mode_undefined" - - match: { test_logsdb_index_mode_undefined.settings.index.mode: logsdb } - - - do: - indices.get_mapping: - index: test_logsdb_index_mode_undefined - - - match: { test_logsdb_index_mode_undefined.mappings._source.mode: stored } - ---- -create an index with time_series index mode and disabled source: - - do: - catch: bad_request - indices.create: - index: test_time_series_index_mode - body: - settings: - index: - mode: time_series - mapping.source.mode: disabled - routing_path: [ keyword ] - time_series: - start_time: 2021-04-28T00:00:00Z - end_time: 2021-04-29T00:00:00Z - mappings: - properties: - keyword: - type: keyword - time_series_dimension: true - - - match: { error.type: "mapper_parsing_exception" } - - match: { error.reason: "Failed to parse mapping: _source can not be disabled in index using [time_series] index mode" } - ---- -create an index with logsdb index mode and disabled source: - - do: - catch: bad_request - indices.create: - index: test_logsdb_index_mode - body: - settings: - index: - mode: logsdb - mapping.source.mode: disabled + index: test_standard_index_mode - - match: { error.type: "mapper_parsing_exception" } - - match: { error.reason: "Failed to parse mapping: _source can not be disabled in index using [logsdb] index mode" } + - match: { test_standard_index_mode.settings.index.mode: standard } + - match: { test_standard_index_mode.settings.index.mapping.source.mode: stored } --- modify final setting after index creation: @@ -477,239 +344,3 @@ modify final setting after index creation: body: index: mapping.source.mode: synthetic - ---- -modify source mapping from stored to disabled after index creation: - - do: - indices.create: - index: test_modify_source_mode_stored_disabled - body: - settings: - index: - mapping.source.mode: stored - - - do: - indices.put_mapping: - index: test_modify_source_mode_stored_disabled - body: - _source: - mode: disabled - - is_true: acknowledged - - - do: - indices.get_mapping: - index: test_modify_source_mode_stored_disabled - - match: { test_modify_source_mode_stored_disabled.mappings._source.mode: stored } - ---- -modify source mapping from stored to synthetic after index creation: - - do: - indices.create: - index: test_modify_source_mode_stored_synthetic - body: - settings: - index: - mapping.source.mode: stored - - - do: - indices.put_mapping: - index: test_modify_source_mode_stored_synthetic - body: - _source: - mode: synthetic - - is_true: acknowledged - - - do: - indices.get_mapping: - index: test_modify_source_mode_stored_synthetic - - match: { test_modify_source_mode_stored_synthetic.mappings._source.mode: stored } - ---- -modify source mapping from disabled to stored after index creation: - - do: - indices.create: - index: test_modify_source_mode_disabled_stored - body: - settings: - index: - mapping.source.mode: disabled - - - do: - indices.put_mapping: - index: test_modify_source_mode_disabled_stored - body: - _source: - mode: stored - - is_true: acknowledged - - - do: - indices.get_mapping: - index: test_modify_source_mode_disabled_stored - - match: { test_modify_source_mode_disabled_stored.mappings._source.mode: disabled } - ---- -modify source mapping from disabled to synthetic after index creation: - - do: - indices.create: - index: test_modify_source_mode_disabled_synthetic - body: - settings: - index: - mapping.source.mode: disabled - - - do: - indices.put_mapping: - index: test_modify_source_mode_disabled_synthetic - body: - _source: - mode: synthetic - - is_true: acknowledged - - - do: - indices.get_mapping: - index: test_modify_source_mode_disabled_synthetic - - match: { test_modify_source_mode_disabled_synthetic.mappings._source.mode: disabled } - ---- -modify source mapping from synthetic to stored after index creation: - - do: - indices.create: - index: test_modify_source_mode_synthetic_stored - body: - settings: - index: - mapping.source.mode: synthetic - - - do: - indices.put_mapping: - index: test_modify_source_mode_synthetic_stored - body: - _source: - mode: stored - - is_true: acknowledged - - - do: - indices.get_mapping: - index: test_modify_source_mode_synthetic_stored - - match: { test_modify_source_mode_synthetic_stored.mappings._source.mode: synthetic } - ---- -modify source mapping from synthetic to disabled after index creation: - - do: - indices.create: - index: test_modify_source_mode_synthetic_disabled - body: - settings: - index: - mapping.source.mode: synthetic - - - do: - indices.put_mapping: - index: test_modify_source_mode_synthetic_disabled - body: - _source: - mode: disabled - - is_true: acknowledged - - - do: - indices.get_mapping: - index: test_modify_source_mode_synthetic_disabled - - match: { test_modify_source_mode_synthetic_disabled.mappings._source.mode: synthetic } - ---- -modify logsdb index source mode to disabled after index creation: - - do: - indices.create: - index: test_modify_logsdb_disabled_after_creation - body: - settings: - index: - mode: logsdb - - - do: - catch: bad_request - indices.put_mapping: - index: test_modify_logsdb_disabled_after_creation - body: - _source: - mode: disabled - - match: { error.type: "mapper_parsing_exception" } - - match: { error.reason: "Failed to parse mapping: _source can not be disabled in index using [logsdb] index mode" } - ---- -modify logsdb index source mode to stored after index creation: - - do: - indices.create: - index: test_modify_logsdb_stored_after_creation - body: - settings: - index: - mode: logsdb - - - do: - catch: bad_request - indices.put_mapping: - index: test_modify_logsdb_stored_after_creation - body: - _source: - mode: stored - - match: { error.type: "illegal_argument_exception" } - - match: { error.reason: "Mapper for [_source] conflicts with existing mapper:\n\tCannot update parameter [mode] from [synthetic] to [stored]" } - ---- -modify time_series index source mode to disabled after index creation: - - do: - indices.create: - index: test_modify_time_series_disabled_after_creation - body: - settings: - index: - mode: time_series - routing_path: [ keyword ] - time_series: - start_time: 2021-04-28T00:00:00Z - end_time: 2021-04-29T00:00:00Z - mappings: - properties: - keyword: - type: keyword - time_series_dimension: true - - - do: - catch: bad_request - indices.put_mapping: - index: test_modify_time_series_disabled_after_creation - body: - _source: - mode: disabled - - match: { error.type: "mapper_parsing_exception" } - - match: { error.reason: "Failed to parse mapping: _source can not be disabled in index using [time_series] index mode" } - ---- -modify time_series index source mode to stored after index creation: - - do: - indices.create: - index: test_modify_time_series_stored_after_creation - body: - settings: - index: - mode: time_series - routing_path: [ keyword ] - time_series: - start_time: 2021-04-28T00:00:00Z - end_time: 2021-04-29T00:00:00Z - mappings: - properties: - keyword: - type: keyword - time_series_dimension: true - - - do: - catch: bad_request - indices.put_mapping: - index: test_modify_time_series_stored_after_creation - body: - _source: - mode: stored - - match: { error.type: "illegal_argument_exception" } - - match: { error.reason: "Mapper for [_source] conflicts with existing mapper:\n\tCannot update parameter [mode] from [synthetic] to [stored]" }