From 02ffd4c5483903d0a91f4196cabd320aebcc71d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Vl=C4=8Dek?= Date: Wed, 16 Mar 2022 18:03:22 +0100 Subject: [PATCH 01/46] Rename reference to project OpenSearch was forked from (#2483) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixing log message and renaming internal variable. Improving internal JavaDoc. Signed-off-by: Lukáš Vlček --- .../OpenSearchClientYamlSuiteTestCase.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java b/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java index ca2659e9523e6..f30b1bfdd1e6b 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java @@ -143,10 +143,15 @@ public void initAndResetContext() throws Exception { validateSpec(restSpec); final List hosts = getClusterHosts(); Tuple versionVersionTuple = readVersionsFromCatNodes(adminClient()); - final Version esVersion = versionVersionTuple.v1(); + final Version minVersion = versionVersionTuple.v1(); final Version masterVersion = versionVersionTuple.v2(); - logger.info("initializing client, minimum es version [{}], master version, [{}], hosts {}", esVersion, masterVersion, hosts); - clientYamlTestClient = initClientYamlTestClient(restSpec, client(), hosts, esVersion, masterVersion); + logger.info( + "initializing client, minimum OpenSearch version [{}], master version, [{}], hosts {}", + minVersion, + masterVersion, + hosts + ); + clientYamlTestClient = initClientYamlTestClient(restSpec, client(), hosts, minVersion, masterVersion); restTestExecutionContext = new ClientYamlTestExecutionContext(clientYamlTestClient, randomizeContentType()); adminExecutionContext = new ClientYamlTestExecutionContext(clientYamlTestClient, false); final String[] denylist = resolvePathsProperty(REST_TESTS_BLACKLIST, null); @@ -321,6 +326,13 @@ private static void validateSpec(ClientYamlSuiteRestSpec restSpec) { } } + /** + * Detect minimal node version and master node version of cluster using REST Client. + * + * @param restClient REST client used to discover cluster nodes + * @return {@link Tuple} of [minimal node version, master node version] + * @throws IOException When _cat API output parsing fails + */ private Tuple readVersionsFromCatNodes(RestClient restClient) throws IOException { // we simply go to the _cat/nodes API and parse all versions in the cluster final Request request = new Request("GET", "/_cat/nodes"); From f52f6f5052d8c610c38b8d6800821ea65fd61413 Mon Sep 17 00:00:00 2001 From: John Mazanec Date: Wed, 16 Mar 2022 13:28:24 -0400 Subject: [PATCH 02/46] Add default for EnginePlugin.getEngineFactory (#2419) Adds default implementation for getEngineFactory in EnginePlugin. The default just returns Optional.empty(), allowing plugin developers to implement this plugin without implementing this method. Signed-off-by: John Mazanec --- .../java/org/opensearch/plugins/EnginePlugin.java | 4 +++- .../index/engine/EngineConfigFactoryTests.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/plugins/EnginePlugin.java b/server/src/main/java/org/opensearch/plugins/EnginePlugin.java index 4c3a07d7b98d9..31844dbdaec2b 100644 --- a/server/src/main/java/org/opensearch/plugins/EnginePlugin.java +++ b/server/src/main/java/org/opensearch/plugins/EnginePlugin.java @@ -56,7 +56,9 @@ public interface EnginePlugin { * * @return an optional engine factory */ - Optional getEngineFactory(IndexSettings indexSettings); + default Optional getEngineFactory(IndexSettings indexSettings) { + return Optional.empty(); + } /** * EXPERT: diff --git a/server/src/test/java/org/opensearch/index/engine/EngineConfigFactoryTests.java b/server/src/test/java/org/opensearch/index/engine/EngineConfigFactoryTests.java index a6bc87d53c004..8030619500278 100644 --- a/server/src/test/java/org/opensearch/index/engine/EngineConfigFactoryTests.java +++ b/server/src/test/java/org/opensearch/index/engine/EngineConfigFactoryTests.java @@ -146,6 +146,21 @@ public void testCreateCodecServiceFromFactory() { assertNotNull(config.getCodec()); } + public void testGetEngineFactory() { + final EngineFactory engineFactory = config -> null; + EnginePlugin enginePluginThatImplementsGetEngineFactory = new EnginePlugin() { + @Override + public Optional getEngineFactory(IndexSettings indexSettings) { + return Optional.of(engineFactory); + } + }; + assertEquals(engineFactory, enginePluginThatImplementsGetEngineFactory.getEngineFactory(null).orElse(null)); + + EnginePlugin enginePluginThatDoesNotImplementsGetEngineFactory = new EnginePlugin() { + }; + assertFalse(enginePluginThatDoesNotImplementsGetEngineFactory.getEngineFactory(null).isPresent()); + } + private static class FooEnginePlugin extends Plugin implements EnginePlugin { @Override public Optional getEngineFactory(final IndexSettings indexSettings) { From bd21043d6536406a5b246f57d5c317fc51fd1ba3 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Wed, 16 Mar 2022 12:30:48 -0500 Subject: [PATCH 03/46] [Unmute] IndexPrimaryRelocationIT (#2488) Unmutes IndexPrimaryRelocationIT.testPrimaryRelocationWhileIndexing which was fixed by LuceneChangesSnapshot using accurate ops history. Signed-off-by: Nicholas Walter Knize --- .../opensearch/indices/recovery/IndexPrimaryRelocationIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java index 3f174dd0fdd6a..7fd2466647272 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java @@ -56,7 +56,6 @@ public class IndexPrimaryRelocationIT extends OpenSearchIntegTestCase { private static final int RELOCATION_COUNT = 15; - @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/2063") public void testPrimaryRelocationWhileIndexing() throws Exception { internalCluster().ensureAtLeastNumDataNodes(randomIntBetween(2, 3)); client().admin() From 05a58192433f6e007ade61b4b4f21d0f068d50e0 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Wed, 16 Mar 2022 14:47:25 -0500 Subject: [PATCH 04/46] [Upgrade] Lucene 9.1.0-snapshot-ea989fe8f30 (#2487) * [Upgrade] Lucene 9.1.0-snapshot-ea989fe8f30 Upgrades from Lucene 9.0.0 to 9.1.0-snapshot-ea989fe8f30 in preparation for 9.1.0 GA. Signed-off-by: Nicholas Walter Knize * Add spanishplural token filter Signed-off-by: Nicholas Walter Knize * fix KNOWN_TOKENIZERS Signed-off-by: Nicholas Walter Knize --- .../gradle/plugin/PluginBuildPlugin.groovy | 2 +- .../TestingConventionsPrecommitPlugin.java | 2 +- .../forbidden/opensearch-test-signatures.txt | 4 +- buildSrc/version.properties | 2 +- .../client/IndicesRequestConvertersTests.java | 2 +- .../settings/KeyStoreCommandTestCase.java | 2 +- .../plugins/InstallPluginCommandTests.java | 2 +- .../plugins/ListPluginsCommandTests.java | 2 +- .../plugins/RemovePluginCommandTests.java | 2 +- .../core/internal/io/IOUtilsTests.java | 4 +- .../stats/MatrixStatsAggregatorTests.java | 2 +- ...ncatenateGraphTokenFilterFactoryTests.java | 4 +- .../FlattenGraphTokenFilterFactoryTests.java | 4 +- .../common/NGramTokenizerFactoryTests.java | 2 +- .../RemoveDuplicatesFilterFactoryTests.java | 4 +- .../common/SynonymsAnalysisTests.java | 2 +- .../common/UniqueTokenFilterTests.java | 2 +- .../WhitespaceTokenizerFactoryTests.java | 2 +- .../lucene-expressions-9.0.0.jar.sha1 | 1 - ...ssions-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../mapper/TokenCountFieldMapperTests.java | 6 +- .../join/query/HasChildQueryBuilder.java | 2 +- .../ChildrenToParentAggregatorTests.java | 2 +- .../ParentToChildrenAggregatorTests.java | 2 +- ...rcolatorMatchedSlotSubFetchPhaseTests.java | 2 +- .../reindex/AsyncBulkByScrollActionTests.java | 2 +- .../ClientScrollableHitSourceTests.java | 2 +- .../index/reindex/RoundTripTests.java | 2 +- .../UpdateByQueryWhileModifyingTests.java | 2 +- .../netty4/Netty4ClientYamlTestSuiteIT.java | 2 +- .../lucene-analysis-icu-9.0.0.jar.sha1 | 1 - ...is-icu-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../index/analysis/IcuAnalyzerTests.java | 2 +- .../analysis/IcuTokenizerFactoryTests.java | 2 +- .../IndexableBinaryStringToolsTests.java | 4 +- .../lucene-analysis-kuromoji-9.0.0.jar.sha1 | 1 - ...romoji-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../index/analysis/KuromojiAnalysisTests.java | 2 +- .../lucene-analysis-nori-9.0.0.jar.sha1 | 1 - ...s-nori-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../lucene-analysis-phonetic-9.0.0.jar.sha1 | 1 - ...onetic-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../analysis/SimplePhoneticAnalysisTests.java | 2 +- .../lucene-analysis-smartcn-9.0.0.jar.sha1 | 1 - ...martcn-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../lucene-analysis-stempel-9.0.0.jar.sha1 | 1 - ...tempel-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../analysis/AnalysisPolishFactoryTests.java | 4 +- .../lucene-analysis-morfologik-9.0.0.jar.sha1 | 1 - ...ologik-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../analysis/UkrainianAnalyzerProvider.java | 2 +- .../ingest/attachment/TikaDocTests.java | 4 +- .../AnnotatedTextHighlighterTests.java | 2 +- .../repositories/hdfs/TestingFs.java | 2 +- .../cli/EvilEnvironmentAwareCommandTests.java | 2 +- .../settings/EvilKeyStoreWrapperTests.java | 2 +- .../MixedClusterClientYamlTestSuiteIT.java | 3 +- .../java/org/opensearch/search/CCSDuelIT.java | 2 +- .../MultiClusterSearchYamlTestSuiteIT.java | 2 +- .../bootstrap/SpawnerNoBootstrapTests.java | 2 +- .../UpgradeClusterClientYamlTestSuiteIT.java | 2 +- ...okeTestMultiNodeClientYamlTestSuiteIT.java | 3 +- qa/wildfly/build.gradle | 2 +- .../org/opensearch/wildfly/WildflyIT.java | 4 +- .../test/rest/ClientYamlTestSuiteIT.java | 2 +- server/build.gradle | 2 +- .../lucene-analysis-common-9.0.0.jar.sha1 | 1 - ...common-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../lucene-backward-codecs-9.0.0.jar.sha1 | 1 - ...codecs-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + server/licenses/lucene-core-9.0.0.jar.sha1 | 1 - ...e-core-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../licenses/lucene-grouping-9.0.0.jar.sha1 | 1 - ...ouping-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../lucene-highlighter-9.0.0.jar.sha1 | 1 - ...ighter-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + server/licenses/lucene-join-9.0.0.jar.sha1 | 1 - ...e-join-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + server/licenses/lucene-memory-9.0.0.jar.sha1 | 1 - ...memory-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + server/licenses/lucene-misc-9.0.0.jar.sha1 | 1 - ...e-misc-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + server/licenses/lucene-queries-9.0.0.jar.sha1 | 1 - ...ueries-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../lucene-queryparser-9.0.0.jar.sha1 | 1 - ...parser-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + server/licenses/lucene-sandbox-9.0.0.jar.sha1 | 1 - ...andbox-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../lucene-spatial-extras-9.0.0.jar.sha1 | 1 - ...extras-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../licenses/lucene-spatial3d-9.0.0.jar.sha1 | 1 - ...tial3d-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + server/licenses/lucene-suggest-9.0.0.jar.sha1 | 1 - ...uggest-9.1.0-snapshot-ea989fe8f30.jar.sha1 | 1 + .../RecoveryWithUnsupportedIndicesIT.java | 4 +- .../cluster/allocation/ClusterRerouteIT.java | 2 +- .../decider/DiskThresholdDeciderIT.java | 6 +- .../discovery/DiskDisruptionIT.java | 2 +- .../index/engine/MaxDocsLimitIT.java | 6 +- .../indices/stats/IndexStatsIT.java | 2 +- .../org/opensearch/recovery/RelocationIT.java | 2 +- .../recovery/TruncatedRecoveryIT.java | 4 +- .../search/StressSearchServiceReaperIT.java | 2 +- .../basic/SearchWithRandomExceptionsIT.java | 2 +- .../basic/SearchWithRandomIOExceptionsIT.java | 2 +- .../highlight/HighlighterSearchIT.java | 4 +- .../search/functionscore/QueryRescorerIT.java | 2 +- .../ProfilerSingleNodeNetworkTest.java | 2 +- .../search/profile/query/QueryProfilerIT.java | 2 +- .../search/query/SearchQueryIT.java | 4 +- .../opensearch/search/sort/FieldSortIT.java | 2 +- .../suggest/CompletionSuggestSearchIT.java | 2 +- .../ContextCompletionSuggestSearchIT.java | 2 +- .../versioning/SimpleVersioningIT.java | 2 +- .../search/grouping/CollapseTopFieldDocs.java | 2 +- .../src/main/java/org/opensearch/Version.java | 2 +- .../search/BottomSortValuesCollector.java | 2 +- .../org/opensearch/common/lucene/Lucene.java | 4 +- .../lucene/search/MultiPhrasePrefixQuery.java | 2 +- .../common/lucene/search/Queries.java | 62 ++++++++++++ .../opensearch/index/codec/CodecService.java | 8 +- .../PerFieldMappingPostingFormatCodec.java | 4 +- .../index/engine/TranslogLeafReader.java | 2 +- .../BytesRefFieldComparatorSource.java | 2 +- .../DoubleValuesComparatorSource.java | 4 +- .../FloatValuesComparatorSource.java | 4 +- .../LongValuesComparatorSource.java | 4 +- .../queries/SearchAfterSortedDocQuery.java | 2 +- .../bucket/composite/CompositeAggregator.java | 4 +- .../internal/ExitableDirectoryReader.java | 98 ++++++++++++++++--- .../search/sort/GeoDistanceSortBuilder.java | 4 +- .../indices/TransportAnalyzeActionTests.java | 4 +- .../action/bulk/BulkShardRequestTests.java | 2 +- .../BottomSortValuesCollectorTests.java | 2 +- .../action/search/DfsQueryPhaseTests.java | 2 +- .../action/search/FetchSearchPhaseTests.java | 2 +- .../termvectors/GetTermVectorsTests.java | 2 +- .../BalanceUnbalancedClusterTests.java | 2 +- .../java/org/opensearch/common/UUIDTests.java | 2 +- .../blobstore/fs/FsBlobContainerTests.java | 6 +- .../common/compress/DeflateCompressTests.java | 4 +- .../DeflateCompressedXContentTests.java | 2 +- .../common/geo/GeoWKTShapeParserTests.java | 2 +- .../common/io/FileSystemUtilsTests.java | 2 +- .../opensearch/common/lucene/LuceneTests.java | 6 +- .../common/lucene/ShardCoreKeyMapTests.java | 2 +- .../search/function/MinScoreScorerTests.java | 4 +- .../morelikethis/XMoreLikeThisTests.java | 6 +- .../common/util/BytesRefHashTests.java | 2 +- .../opensearch/env/NodeEnvironmentTests.java | 2 +- .../GatewayMetaStatePersistedStateTests.java | 2 +- .../IncrementalClusterStateWriterTests.java | 2 +- .../gateway/MetadataStateFormatTests.java | 4 +- .../opensearch/index/IndexModuleTests.java | 2 +- .../java/org/opensearch/index/IndexTests.java | 2 +- .../index/analysis/AnalysisRegistryTests.java | 2 +- .../index/analysis/CustomNormalizerTests.java | 4 +- .../opensearch/index/codec/CodecTests.java | 14 +-- .../engine/CompletionStatsCacheTests.java | 4 +- .../index/engine/InternalEngineTests.java | 11 +-- .../index/engine/LiveVersionMapTests.java | 4 +- .../index/engine/ReadOnlyEngineTests.java | 2 +- .../RecoverySourcePruneMergePolicyTests.java | 2 +- .../index/engine/VersionValueTests.java | 2 +- .../AbstractStringFieldDataTestCase.java | 2 +- .../plain/HalfFloatFielddataTests.java | 2 +- .../mapper/DocumentFieldMapperTests.java | 2 +- .../index/mapper/KeywordFieldMapperTests.java | 6 +- .../index/mapper/NumberFieldTypeTests.java | 2 +- .../index/mapper/TextFieldMapperTests.java | 6 +- .../org/opensearch/index/mapper/UidTests.java | 2 +- .../index/query/IntervalBuilderTests.java | 4 +- .../MatchBoolPrefixQueryBuilderTests.java | 2 +- .../index/query/MatchQueryBuilderTests.java | 4 +- .../index/query/QueryShardContextTests.java | 2 +- .../query/QueryStringQueryBuilderTests.java | 2 +- .../query/SimpleQueryStringBuilderTests.java | 4 +- .../query/SpanMultiTermQueryBuilderTests.java | 2 +- .../FunctionScoreEquivalenceTests.java | 4 +- .../functionscore/FunctionScoreTests.java | 2 +- .../reindex/BulkByScrollResponseTests.java | 2 +- .../reindex/BulkByScrollTaskStatusTests.java | 4 +- .../reindex/DeleteByQueryRequestTests.java | 2 +- .../reindex/UpdateByQueryRequestTests.java | 2 +- .../index/search/MultiMatchQueryTests.java | 2 +- .../search/nested/NestedSortingTests.java | 2 +- .../index/shard/IndexReaderWrapperTests.java | 2 +- .../index/shard/NewPathForShardTests.java | 2 +- .../RemoveCorruptedShardDataCommandTests.java | 2 +- .../index/shard/ShardSplittingQueryTests.java | 2 +- .../index/shard/ShardUtilsTests.java | 2 +- .../similarity/ScriptedSimilarityTests.java | 2 +- .../store/ByteSizeCachingDirectoryTests.java | 2 +- .../opensearch/index/store/StoreTests.java | 6 +- .../index/translog/TestTranslog.java | 2 +- .../index/translog/TranslogTests.java | 10 +- .../indices/analysis/AnalysisModuleTests.java | 4 +- .../recovery/RecoverySourceHandlerTests.java | 4 +- .../DeDuplicatingTokenFilterTests.java | 2 +- .../TruncateTokenFilterTests.java | 2 +- .../CollapsingTopDocsCollectorTests.java | 4 +- .../index/ShuffleForcedMergePolicyTests.java | 2 +- .../similarity/LegacyBM25SimilarityTests.java | 2 +- ...ndomBinaryDocValuesRangeQueryTestCase.java | 2 +- .../BinaryDocValuesRangeQueryTests.java | 2 +- .../lucene/queries/BlendedTermQueryTests.java | 4 +- ...rRandomBinaryDocValuesRangeQueryTests.java | 2 +- ...gRandomBinaryDocValuesRangeQueryTests.java | 2 +- .../lucene/queries/MinDocQueryTests.java | 4 +- .../SearchAfterSortedDocQueryTests.java | 4 +- .../queries/SpanMatchNoDocsQueryTests.java | 4 +- .../CustomUnifiedHighlighterTests.java | 2 +- .../monitor/fs/FsHealthServiceTests.java | 4 +- .../java/org/opensearch/node/NodeTests.java | 2 +- .../plugins/PluginsServiceTests.java | 2 +- .../BlobStoreRepositoryRestoreTests.java | 2 +- .../repositories/fs/FsRepositoryTests.java | 4 +- .../search/DefaultSearchContextTests.java | 2 +- .../search/SearchCancellationTests.java | 4 +- .../opensearch/search/SearchHitsTests.java | 2 +- .../MultiBucketCollectorTests.java | 2 +- .../BestBucketsDeferringCollectorTests.java | 2 +- .../bucket/BucketsAggregatorTests.java | 2 +- .../bucket/GlobalAggregatorTests.java | 2 +- .../composite/CompositeAggregatorTests.java | 6 +- .../CompositeValuesCollectorQueueTests.java | 2 +- .../bucket/filter/FilterAggregatorTests.java | 2 +- .../bucket/filter/FiltersAggregatorTests.java | 2 +- .../geogrid/GeoGridAggregatorTestCase.java | 2 +- .../AutoDateHistogramAggregatorTests.java | 2 +- .../DateHistogramAggregatorTestCase.java | 2 +- .../DateHistogramAggregatorTests.java | 2 +- .../DateRangeHistogramAggregatorTests.java | 2 +- .../histogram/InternalHistogramTests.java | 2 +- .../InternalVariableWidthHistogramTests.java | 2 +- .../NumericHistogramAggregatorTests.java | 2 +- .../RangeHistogramAggregatorTests.java | 2 +- ...VariableWidthHistogramAggregatorTests.java | 2 +- .../missing/MissingAggregatorTests.java | 2 +- .../bucket/nested/NestedAggregatorTests.java | 2 +- .../nested/ReverseNestedAggregatorTests.java | 2 +- .../range/BinaryRangeAggregatorTests.java | 2 +- .../range/DateRangeAggregatorTests.java | 2 +- .../bucket/range/IpRangeAggregatorTests.java | 2 +- .../bucket/range/RangeAggregatorTests.java | 2 +- .../BestDocsDeferringCollectorTests.java | 2 +- .../sampler/DiversifiedSamplerTests.java | 2 +- .../terms/BinaryTermsAggregatorTests.java | 2 +- .../terms/KeywordTermsAggregatorTests.java | 2 +- .../terms/NumericTermsAggregatorTests.java | 2 +- .../terms/RareTermsAggregatorTests.java | 2 +- .../SignificantTermsAggregatorTests.java | 2 +- .../bucket/terms/TermsAggregatorTests.java | 2 +- .../metrics/AvgAggregatorTests.java | 2 +- .../metrics/CardinalityAggregatorTests.java | 2 +- .../metrics/ExtendedStatsAggregatorTests.java | 2 +- .../metrics/GeoBoundsAggregatorTests.java | 2 +- .../metrics/GeoCentroidAggregatorTests.java | 2 +- .../HDRPercentileRanksAggregatorTests.java | 2 +- .../HDRPercentilesAggregatorTests.java | 2 +- .../metrics/InternalTopHitsTests.java | 2 +- .../metrics/MaxAggregatorTests.java | 2 +- ...edianAbsoluteDeviationAggregatorTests.java | 2 +- .../metrics/MinAggregatorTests.java | 2 +- .../ScriptedMetricAggregatorTests.java | 2 +- .../metrics/StatsAggregatorTests.java | 2 +- .../metrics/SumAggregatorTests.java | 2 +- ...TDigestPercentileRanksAggregatorTests.java | 2 +- .../TDigestPercentilesAggregatorTests.java | 2 +- .../metrics/TopHitsAggregatorTests.java | 2 +- .../metrics/ValueCountAggregatorTests.java | 2 +- .../metrics/WeightedAvgAggregatorTests.java | 2 +- .../pipeline/AvgBucketAggregatorTests.java | 2 +- .../pipeline/BucketScriptAggregatorTests.java | 2 +- .../CumulativeSumAggregatorTests.java | 2 +- .../pipeline/DerivativeAggregatorTests.java | 2 +- .../pipeline/MovFnAggrgatorTests.java | 2 +- .../support/MissingValuesTests.java | 2 +- .../search/collapse/CollapseBuilderTests.java | 2 +- .../highlight/PlainHighlighterTests.java | 4 +- .../search/geo/GeoShapeQueryTests.java | 2 +- .../profile/query/QueryProfilerTests.java | 6 +- .../profile/query/RandomQueryGenerator.java | 2 +- .../search/query/QueryPhaseTests.java | 7 +- .../searchafter/SearchAfterBuilderTests.java | 2 +- .../slice/DocValuesSliceQueryTests.java | 4 +- .../search/slice/SliceBuilderTests.java | 2 +- .../search/slice/TermsSliceQueryTests.java | 4 +- .../search/sort/FieldSortBuilderTests.java | 4 +- .../opensearch/watcher/FileWatcherTests.java | 2 +- .../bootstrap/BootstrapForTesting.java | 2 +- .../cluster/DataStreamTestHelper.java | 2 +- .../CoordinationStateTestCluster.java | 2 +- .../cluster/routing/TestShardRouting.java | 2 +- .../service/FakeThreadPoolMasterService.java | 2 +- .../common/io/PathUtilsForTesting.java | 2 +- .../opensearch/common/util/MockBigArrays.java | 2 +- .../common/util/MockPageCacheRecycler.java | 2 +- .../org/opensearch/geo/GeometryTestUtils.java | 2 +- .../org/opensearch/index/MapperTestUtils.java | 2 +- .../index/MockEngineFactoryPlugin.java | 2 +- .../index/mapper/MapperServiceTestCase.java | 2 +- .../OpenSearchBaseDirectoryTestCase.java | 6 +- .../analysis/AnalysisFactoryTestCase.java | 8 +- ...chMockAPIBasedRepositoryIntegTestCase.java | 2 +- .../aggregations/AggregatorTestCase.java | 10 +- .../org/opensearch/test/CorruptionUtils.java | 2 +- .../opensearch/test/FieldMaskingReader.java | 2 +- .../opensearch/test/InternalTestCluster.java | 4 +- .../opensearch/test/MockKeywordPlugin.java | 2 +- .../test/OpenSearchIntegTestCase.java | 2 +- .../opensearch/test/OpenSearchTestCase.java | 10 +- .../test/OpenSearchTokenStreamTestCase.java | 6 +- .../test/client/RandomizingClient.java | 2 +- .../test/engine/MockEngineSupport.java | 4 +- .../test/hamcrest/OpenSearchAssertions.java | 4 +- .../OpenSearchClientYamlSuiteTestCase.java | 2 +- .../test/store/MockFSDirectoryFactory.java | 8 +- .../test/transport/MockTransport.java | 2 +- .../test/test/InternalTestClusterTests.java | 2 +- 320 files changed, 555 insertions(+), 417 deletions(-) delete mode 100644 modules/lang-expression/licenses/lucene-expressions-9.0.0.jar.sha1 create mode 100644 modules/lang-expression/licenses/lucene-expressions-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 plugins/analysis-icu/licenses/lucene-analysis-icu-9.0.0.jar.sha1 create mode 100644 plugins/analysis-icu/licenses/lucene-analysis-icu-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 plugins/analysis-kuromoji/licenses/lucene-analysis-kuromoji-9.0.0.jar.sha1 create mode 100644 plugins/analysis-kuromoji/licenses/lucene-analysis-kuromoji-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 plugins/analysis-nori/licenses/lucene-analysis-nori-9.0.0.jar.sha1 create mode 100644 plugins/analysis-nori/licenses/lucene-analysis-nori-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 plugins/analysis-phonetic/licenses/lucene-analysis-phonetic-9.0.0.jar.sha1 create mode 100644 plugins/analysis-phonetic/licenses/lucene-analysis-phonetic-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 plugins/analysis-smartcn/licenses/lucene-analysis-smartcn-9.0.0.jar.sha1 create mode 100644 plugins/analysis-smartcn/licenses/lucene-analysis-smartcn-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 plugins/analysis-stempel/licenses/lucene-analysis-stempel-9.0.0.jar.sha1 create mode 100644 plugins/analysis-stempel/licenses/lucene-analysis-stempel-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 plugins/analysis-ukrainian/licenses/lucene-analysis-morfologik-9.0.0.jar.sha1 create mode 100644 plugins/analysis-ukrainian/licenses/lucene-analysis-morfologik-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-analysis-common-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-analysis-common-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-backward-codecs-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-backward-codecs-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-core-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-core-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-grouping-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-grouping-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-highlighter-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-highlighter-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-join-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-join-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-memory-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-memory-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-misc-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-misc-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-queries-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-queries-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-queryparser-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-queryparser-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-sandbox-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-sandbox-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-spatial-extras-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-spatial-extras-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-spatial3d-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-spatial3d-9.1.0-snapshot-ea989fe8f30.jar.sha1 delete mode 100644 server/licenses/lucene-suggest-9.0.0.jar.sha1 create mode 100644 server/licenses/lucene-suggest-9.1.0-snapshot-ea989fe8f30.jar.sha1 diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy index 427e3f2740a89..31677965ab0d3 100644 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy @@ -123,7 +123,7 @@ class PluginBuildPlugin implements Plugin { naming.clear() naming { Tests { - baseClass 'org.apache.lucene.util.LuceneTestCase' + baseClass 'org.apache.lucene.tests.util.LuceneTestCase' } IT { baseClass 'org.opensearch.test.OpenSearchIntegTestCase' diff --git a/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionsPrecommitPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionsPrecommitPlugin.java index 4c965d6a0fe90..08376e76c9c20 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionsPrecommitPlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/precommit/TestingConventionsPrecommitPlugin.java @@ -43,7 +43,7 @@ public TaskProvider createTask(Project project) { .register("testingConventions", TestingConventionsTasks.class); testingConventions.configure(t -> { TestingConventionRule testsRule = t.getNaming().maybeCreate("Tests"); - testsRule.baseClass("org.apache.lucene.util.LuceneTestCase"); + testsRule.baseClass("org.apache.lucene.tests.util.LuceneTestCase"); TestingConventionRule itRule = t.getNaming().maybeCreate("IT"); itRule.baseClass("org.opensearch.test.OpenSearchIntegTestCase"); itRule.baseClass("org.opensearch.test.rest.OpenSearchRestTestCase"); diff --git a/buildSrc/src/main/resources/forbidden/opensearch-test-signatures.txt b/buildSrc/src/main/resources/forbidden/opensearch-test-signatures.txt index 766e13878cc25..aeb5e25decf62 100644 --- a/buildSrc/src/main/resources/forbidden/opensearch-test-signatures.txt +++ b/buildSrc/src/main/resources/forbidden/opensearch-test-signatures.txt @@ -19,9 +19,9 @@ com.carrotsearch.randomizedtesting.annotations.Seed @ Don't commit hardcoded see com.carrotsearch.randomizedtesting.annotations.Repeat @ Don't commit hardcoded repeats org.apache.lucene.codecs.Codec#setDefault(org.apache.lucene.codecs.Codec) @ Use the SuppressCodecs("*") annotation instead -org.apache.lucene.util.LuceneTestCase$Slow @ Don't write slow tests +org.apache.lucene.tests.util.LuceneTestCase$Slow @ Don't write slow tests org.junit.Ignore @ Use AwaitsFix instead -org.apache.lucene.util.LuceneTestCase$Nightly @ We don't run nightly tests at this point! +org.apache.lucene.tests.util.LuceneTestCase$Nightly @ We don't run nightly tests at this point! com.carrotsearch.randomizedtesting.annotations.Nightly @ We don't run nightly tests at this point! org.junit.Test @defaultMessage Just name your test method testFooBar diff --git a/buildSrc/version.properties b/buildSrc/version.properties index 7682a982e8186..5202b60cbdc20 100644 --- a/buildSrc/version.properties +++ b/buildSrc/version.properties @@ -1,5 +1,5 @@ opensearch = 2.0.0 -lucene = 9.0.0 +lucene = 9.1.0-snapshot-ea989fe8f30 bundled_jdk_vendor = adoptium bundled_jdk = 17.0.2+8 diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/IndicesRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/IndicesRequestConvertersTests.java index 7276cbb44b030..f853378e789fa 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/IndicesRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/IndicesRequestConvertersTests.java @@ -37,7 +37,7 @@ import org.apache.http.client.methods.HttpHead; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.admin.indices.alias.Alias; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; diff --git a/distribution/tools/keystore-cli/src/test/java/org/opensearch/common/settings/KeyStoreCommandTestCase.java b/distribution/tools/keystore-cli/src/test/java/org/opensearch/common/settings/KeyStoreCommandTestCase.java index b88eae3005c87..aa31e07368fc2 100644 --- a/distribution/tools/keystore-cli/src/test/java/org/opensearch/common/settings/KeyStoreCommandTestCase.java +++ b/distribution/tools/keystore-cli/src/test/java/org/opensearch/common/settings/KeyStoreCommandTestCase.java @@ -43,7 +43,7 @@ import com.google.common.jimfs.Configuration; import com.google.common.jimfs.Jimfs; import org.opensearch.core.internal.io.IOUtils; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.cli.CommandTestCase; import org.opensearch.common.io.PathUtilsForTesting; import org.opensearch.env.Environment; diff --git a/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/InstallPluginCommandTests.java b/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/InstallPluginCommandTests.java index e0e5cbc54276e..c1b4568759f4d 100644 --- a/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/InstallPluginCommandTests.java +++ b/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/InstallPluginCommandTests.java @@ -35,7 +35,7 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import com.google.common.jimfs.Configuration; import com.google.common.jimfs.Jimfs; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.bouncycastle.bcpg.ArmoredOutputStream; import org.bouncycastle.bcpg.BCPGOutputStream; import org.bouncycastle.bcpg.HashAlgorithmTags; diff --git a/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/ListPluginsCommandTests.java b/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/ListPluginsCommandTests.java index 46a439fcbc8ac..376e470159731 100644 --- a/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/ListPluginsCommandTests.java +++ b/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/ListPluginsCommandTests.java @@ -40,7 +40,7 @@ import java.util.Map; import java.util.stream.Collectors; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.cli.ExitCodes; diff --git a/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/RemovePluginCommandTests.java b/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/RemovePluginCommandTests.java index bae64dfcfc42a..8f9aa27be7e84 100644 --- a/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/RemovePluginCommandTests.java +++ b/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/RemovePluginCommandTests.java @@ -32,7 +32,7 @@ package org.opensearch.plugins; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.Version; import org.opensearch.cli.ExitCodes; import org.opensearch.cli.MockTerminal; diff --git a/libs/core/src/test/java/org/opensearch/core/internal/io/IOUtilsTests.java b/libs/core/src/test/java/org/opensearch/core/internal/io/IOUtilsTests.java index 85632ae406a1b..f1c8642b73044 100644 --- a/libs/core/src/test/java/org/opensearch/core/internal/io/IOUtilsTests.java +++ b/libs/core/src/test/java/org/opensearch/core/internal/io/IOUtilsTests.java @@ -30,8 +30,8 @@ package org.opensearch.core.internal.io; -import org.apache.lucene.mockfile.FilterFileSystemProvider; -import org.apache.lucene.mockfile.FilterPath; +import org.apache.lucene.tests.mockfile.FilterFileSystemProvider; +import org.apache.lucene.tests.mockfile.FilterPath; import org.apache.lucene.util.Constants; import org.opensearch.common.CheckedConsumer; import org.opensearch.common.io.PathUtils; diff --git a/modules/aggs-matrix-stats/src/test/java/org/opensearch/search/aggregations/matrix/stats/MatrixStatsAggregatorTests.java b/modules/aggs-matrix-stats/src/test/java/org/opensearch/search/aggregations/matrix/stats/MatrixStatsAggregatorTests.java index c07956d9d8f5c..da3228829816b 100644 --- a/modules/aggs-matrix-stats/src/test/java/org/opensearch/search/aggregations/matrix/stats/MatrixStatsAggregatorTests.java +++ b/modules/aggs-matrix-stats/src/test/java/org/opensearch/search/aggregations/matrix/stats/MatrixStatsAggregatorTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.document.StringField; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/ConcatenateGraphTokenFilterFactoryTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/ConcatenateGraphTokenFilterFactoryTests.java index ef4146b65872d..509010e209088 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/ConcatenateGraphTokenFilterFactoryTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/ConcatenateGraphTokenFilterFactoryTests.java @@ -8,8 +8,8 @@ package org.opensearch.analysis.common; -import org.apache.lucene.analysis.CannedTokenStream; -import org.apache.lucene.analysis.Token; +import org.apache.lucene.tests.analysis.CannedTokenStream; +import org.apache.lucene.tests.analysis.Token; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/FlattenGraphTokenFilterFactoryTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/FlattenGraphTokenFilterFactoryTests.java index 8fbcc9ea4ed49..7d9555923e4ef 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/FlattenGraphTokenFilterFactoryTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/FlattenGraphTokenFilterFactoryTests.java @@ -32,8 +32,8 @@ package org.opensearch.analysis.common; -import org.apache.lucene.analysis.CannedTokenStream; -import org.apache.lucene.analysis.Token; +import org.apache.lucene.tests.analysis.CannedTokenStream; +import org.apache.lucene.tests.analysis.Token; import org.apache.lucene.analysis.TokenStream; import org.opensearch.common.settings.Settings; import org.opensearch.index.Index; diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/NGramTokenizerFactoryTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/NGramTokenizerFactoryTests.java index c23b2c6082e19..49ccc742a355c 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/NGramTokenizerFactoryTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/NGramTokenizerFactoryTests.java @@ -32,7 +32,7 @@ package org.opensearch.analysis.common; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter; diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/RemoveDuplicatesFilterFactoryTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/RemoveDuplicatesFilterFactoryTests.java index cb22835c364db..9de6f2a5eb2fd 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/RemoveDuplicatesFilterFactoryTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/RemoveDuplicatesFilterFactoryTests.java @@ -32,8 +32,8 @@ package org.opensearch.analysis.common; -import org.apache.lucene.analysis.CannedTokenStream; -import org.apache.lucene.analysis.Token; +import org.apache.lucene.tests.analysis.CannedTokenStream; +import org.apache.lucene.tests.analysis.Token; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; import org.opensearch.index.analysis.AnalysisTestsHelper; diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/SynonymsAnalysisTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/SynonymsAnalysisTests.java index 81d59ef3349d5..8094e24b9adc8 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/SynonymsAnalysisTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/SynonymsAnalysisTests.java @@ -33,7 +33,7 @@ package org.opensearch.analysis.common; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; +import org.apache.lucene.tests.analysis.BaseTokenStreamTestCase; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.core.KeywordTokenizer; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/UniqueTokenFilterTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/UniqueTokenFilterTests.java index 0ab9919ad4813..a321fd4a5879c 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/UniqueTokenFilterTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/UniqueTokenFilterTests.java @@ -33,7 +33,7 @@ package org.opensearch.analysis.common; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/WhitespaceTokenizerFactoryTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/WhitespaceTokenizerFactoryTests.java index d98e358621d2e..c0034c0e8ef20 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/WhitespaceTokenizerFactoryTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/WhitespaceTokenizerFactoryTests.java @@ -47,7 +47,7 @@ import java.io.Reader; import java.io.StringReader; -import static org.apache.lucene.analysis.BaseTokenStreamTestCase.assertTokenStreamContents; +import static org.apache.lucene.tests.analysis.BaseTokenStreamTestCase.assertTokenStreamContents; public class WhitespaceTokenizerFactoryTests extends OpenSearchTestCase { diff --git a/modules/lang-expression/licenses/lucene-expressions-9.0.0.jar.sha1 b/modules/lang-expression/licenses/lucene-expressions-9.0.0.jar.sha1 deleted file mode 100644 index 21edcc44b664e..0000000000000 --- a/modules/lang-expression/licenses/lucene-expressions-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -0a3d818d6f6fb113831ed34553b24763fbda1e84 \ No newline at end of file diff --git a/modules/lang-expression/licenses/lucene-expressions-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/modules/lang-expression/licenses/lucene-expressions-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..fb85ff4827c36 --- /dev/null +++ b/modules/lang-expression/licenses/lucene-expressions-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +c7317bb4e72b820a516e0c8a90beac5acc82c2e2 \ No newline at end of file diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/TokenCountFieldMapperTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/TokenCountFieldMapperTests.java index c3850b151dde8..e9d3767373b95 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/TokenCountFieldMapperTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/TokenCountFieldMapperTests.java @@ -33,9 +33,9 @@ package org.opensearch.index.mapper; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.CannedTokenStream; -import org.apache.lucene.analysis.MockTokenizer; -import org.apache.lucene.analysis.Token; +import org.apache.lucene.tests.analysis.CannedTokenStream; +import org.apache.lucene.tests.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.Token; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.core.KeywordAnalyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; diff --git a/modules/parent-join/src/main/java/org/opensearch/join/query/HasChildQueryBuilder.java b/modules/parent-join/src/main/java/org/opensearch/join/query/HasChildQueryBuilder.java index be957146da21d..b25c1fd45e56e 100644 --- a/modules/parent-join/src/main/java/org/opensearch/join/query/HasChildQueryBuilder.java +++ b/modules/parent-join/src/main/java/org/opensearch/join/query/HasChildQueryBuilder.java @@ -443,7 +443,7 @@ public Query rewrite(IndexReader reader) throws IOException { // blow up since for this query to work we have to have a DirectoryReader otherwise // we can't load global ordinals - for this to work we simply check if the reader has no leaves // and rewrite to match nothing - return new MatchNoDocsQuery(); + return Queries.newMatchNoDocsQueryWithoutRewrite("unable to load global ordinals with an empty directory reader"); } throw new IllegalStateException( "can't load global ordinals for reader of type: " + reader.getClass() + " must be a DirectoryReader" diff --git a/modules/parent-join/src/test/java/org/opensearch/join/aggregations/ChildrenToParentAggregatorTests.java b/modules/parent-join/src/test/java/org/opensearch/join/aggregations/ChildrenToParentAggregatorTests.java index ad57770eefd65..0d134592fa678 100644 --- a/modules/parent-join/src/test/java/org/opensearch/join/aggregations/ChildrenToParentAggregatorTests.java +++ b/modules/parent-join/src/test/java/org/opensearch/join/aggregations/ChildrenToParentAggregatorTests.java @@ -38,7 +38,7 @@ import org.apache.lucene.document.StringField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/modules/parent-join/src/test/java/org/opensearch/join/aggregations/ParentToChildrenAggregatorTests.java b/modules/parent-join/src/test/java/org/opensearch/join/aggregations/ParentToChildrenAggregatorTests.java index 4373a74b17215..2ed06ee0c0ea9 100644 --- a/modules/parent-join/src/test/java/org/opensearch/join/aggregations/ParentToChildrenAggregatorTests.java +++ b/modules/parent-join/src/test/java/org/opensearch/join/aggregations/ParentToChildrenAggregatorTests.java @@ -39,7 +39,7 @@ import org.apache.lucene.document.StringField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorMatchedSlotSubFetchPhaseTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorMatchedSlotSubFetchPhaseTests.java index 7eb9f95aa89af..efa5a7a3d5095 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorMatchedSlotSubFetchPhaseTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorMatchedSlotSubFetchPhaseTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.index.memory.MemoryIndex; import org.apache.lucene.search.MatchAllDocsQuery; diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/AsyncBulkByScrollActionTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/AsyncBulkByScrollActionTests.java index 9c2e44f580628..145aaaf24fbee 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/AsyncBulkByScrollActionTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/AsyncBulkByScrollActionTests.java @@ -121,7 +121,7 @@ import static java.util.Collections.singleton; import static java.util.Collections.singletonList; import static java.util.Collections.synchronizedSet; -import static org.apache.lucene.util.TestUtil.randomSimpleString; +import static org.apache.lucene.tests.util.TestUtil.randomSimpleString; import static org.opensearch.action.bulk.BackoffPolicy.constantBackoff; import static org.opensearch.common.unit.TimeValue.timeValueMillis; import static org.opensearch.common.unit.TimeValue.timeValueSeconds; diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/ClientScrollableHitSourceTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/ClientScrollableHitSourceTests.java index 8af217e5140e1..9333e5bd3dcc9 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/ClientScrollableHitSourceTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/ClientScrollableHitSourceTests.java @@ -69,7 +69,7 @@ import java.util.stream.IntStream; import static java.util.Collections.emptyMap; -import static org.apache.lucene.util.TestUtil.randomSimpleString; +import static org.apache.lucene.tests.util.TestUtil.randomSimpleString; import static org.opensearch.common.unit.TimeValue.timeValueSeconds; import static org.hamcrest.Matchers.instanceOf; diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java index 204f4ea49a22a..6239946852cf8 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java @@ -50,7 +50,7 @@ import java.util.HashMap; import java.util.Map; -import static org.apache.lucene.util.TestUtil.randomSimpleString; +import static org.apache.lucene.tests.util.TestUtil.randomSimpleString; import static org.opensearch.common.unit.TimeValue.parseTimeValue; /** diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryWhileModifyingTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryWhileModifyingTests.java index 3c2e302cb85e7..f203625dcfc44 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryWhileModifyingTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryWhileModifyingTests.java @@ -40,7 +40,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import static org.apache.lucene.util.TestUtil.randomSimpleString; +import static org.apache.lucene.tests.util.TestUtil.randomSimpleString; import static org.opensearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.hamcrest.Matchers.either; import static org.hamcrest.Matchers.equalTo; diff --git a/modules/transport-netty4/src/yamlRestTest/java/org/opensearch/http/netty4/Netty4ClientYamlTestSuiteIT.java b/modules/transport-netty4/src/yamlRestTest/java/org/opensearch/http/netty4/Netty4ClientYamlTestSuiteIT.java index 4cdd836a602db..45693078174a8 100644 --- a/modules/transport-netty4/src/yamlRestTest/java/org/opensearch/http/netty4/Netty4ClientYamlTestSuiteIT.java +++ b/modules/transport-netty4/src/yamlRestTest/java/org/opensearch/http/netty4/Netty4ClientYamlTestSuiteIT.java @@ -36,7 +36,7 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; -import org.apache.lucene.util.TimeUnits; +import org.apache.lucene.tests.util.TimeUnits; import org.opensearch.test.rest.yaml.ClientYamlTestCandidate; import org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase; import org.junit.BeforeClass; diff --git a/plugins/analysis-icu/licenses/lucene-analysis-icu-9.0.0.jar.sha1 b/plugins/analysis-icu/licenses/lucene-analysis-icu-9.0.0.jar.sha1 deleted file mode 100644 index a0df1a4b7cb2e..0000000000000 --- a/plugins/analysis-icu/licenses/lucene-analysis-icu-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -a23a2c1c9baad61b6fb5380f072e41534c275875 \ No newline at end of file diff --git a/plugins/analysis-icu/licenses/lucene-analysis-icu-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/plugins/analysis-icu/licenses/lucene-analysis-icu-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..2f0a6ad50e337 --- /dev/null +++ b/plugins/analysis-icu/licenses/lucene-analysis-icu-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +77930f802430648980eded22ca6ed47fedaeaba4 \ No newline at end of file diff --git a/plugins/analysis-icu/src/test/java/org/opensearch/index/analysis/IcuAnalyzerTests.java b/plugins/analysis-icu/src/test/java/org/opensearch/index/analysis/IcuAnalyzerTests.java index 40d503b1b3756..e490248fc8122 100644 --- a/plugins/analysis-icu/src/test/java/org/opensearch/index/analysis/IcuAnalyzerTests.java +++ b/plugins/analysis-icu/src/test/java/org/opensearch/index/analysis/IcuAnalyzerTests.java @@ -33,7 +33,7 @@ package org.opensearch.index.analysis; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; +import org.apache.lucene.tests.analysis.BaseTokenStreamTestCase; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; diff --git a/plugins/analysis-icu/src/test/java/org/opensearch/index/analysis/IcuTokenizerFactoryTests.java b/plugins/analysis-icu/src/test/java/org/opensearch/index/analysis/IcuTokenizerFactoryTests.java index 3ce9bc918bad1..115171aec184f 100644 --- a/plugins/analysis-icu/src/test/java/org/opensearch/index/analysis/IcuTokenizerFactoryTests.java +++ b/plugins/analysis-icu/src/test/java/org/opensearch/index/analysis/IcuTokenizerFactoryTests.java @@ -48,7 +48,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import static org.apache.lucene.analysis.BaseTokenStreamTestCase.assertTokenStreamContents; +import static org.apache.lucene.tests.analysis.BaseTokenStreamTestCase.assertTokenStreamContents; public class IcuTokenizerFactoryTests extends OpenSearchTestCase { diff --git a/plugins/analysis-icu/src/test/java/org/opensearch/index/analysis/IndexableBinaryStringToolsTests.java b/plugins/analysis-icu/src/test/java/org/opensearch/index/analysis/IndexableBinaryStringToolsTests.java index a39dc76c36619..63e21b2f7903b 100644 --- a/plugins/analysis-icu/src/test/java/org/opensearch/index/analysis/IndexableBinaryStringToolsTests.java +++ b/plugins/analysis-icu/src/test/java/org/opensearch/index/analysis/IndexableBinaryStringToolsTests.java @@ -35,8 +35,8 @@ import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope; import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; import org.apache.lucene.util.ArrayUtil; -import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.TimeUnits; +import org.apache.lucene.tests.util.LuceneTestCase; +import org.apache.lucene.tests.util.TimeUnits; import org.opensearch.test.junit.listeners.ReproduceInfoPrinter; import org.junit.BeforeClass; diff --git a/plugins/analysis-kuromoji/licenses/lucene-analysis-kuromoji-9.0.0.jar.sha1 b/plugins/analysis-kuromoji/licenses/lucene-analysis-kuromoji-9.0.0.jar.sha1 deleted file mode 100644 index 7eb72638fd6d2..0000000000000 --- a/plugins/analysis-kuromoji/licenses/lucene-analysis-kuromoji-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -55f00abe01e51181d687c6bbceca8544f319b97d \ No newline at end of file diff --git a/plugins/analysis-kuromoji/licenses/lucene-analysis-kuromoji-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/plugins/analysis-kuromoji/licenses/lucene-analysis-kuromoji-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..a0d112dd733ab --- /dev/null +++ b/plugins/analysis-kuromoji/licenses/lucene-analysis-kuromoji-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +c66f568fa9138c6ab6f3abf1efbfab3c7b5991d4 \ No newline at end of file diff --git a/plugins/analysis-kuromoji/src/test/java/org/opensearch/index/analysis/KuromojiAnalysisTests.java b/plugins/analysis-kuromoji/src/test/java/org/opensearch/index/analysis/KuromojiAnalysisTests.java index 591cbbec555a6..e17658d83a085 100644 --- a/plugins/analysis-kuromoji/src/test/java/org/opensearch/index/analysis/KuromojiAnalysisTests.java +++ b/plugins/analysis-kuromoji/src/test/java/org/opensearch/index/analysis/KuromojiAnalysisTests.java @@ -53,7 +53,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import static org.apache.lucene.analysis.BaseTokenStreamTestCase.assertTokenStreamContents; +import static org.apache.lucene.tests.analysis.BaseTokenStreamTestCase.assertTokenStreamContents; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; diff --git a/plugins/analysis-nori/licenses/lucene-analysis-nori-9.0.0.jar.sha1 b/plugins/analysis-nori/licenses/lucene-analysis-nori-9.0.0.jar.sha1 deleted file mode 100644 index 4d787ad04791f..0000000000000 --- a/plugins/analysis-nori/licenses/lucene-analysis-nori-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -c5258e674ad9c189338b026710869c2955d8e11d \ No newline at end of file diff --git a/plugins/analysis-nori/licenses/lucene-analysis-nori-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/plugins/analysis-nori/licenses/lucene-analysis-nori-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..a3f939bfe9e05 --- /dev/null +++ b/plugins/analysis-nori/licenses/lucene-analysis-nori-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +e8c47600ea859b999a5f5647341b0350b03dafcd \ No newline at end of file diff --git a/plugins/analysis-phonetic/licenses/lucene-analysis-phonetic-9.0.0.jar.sha1 b/plugins/analysis-phonetic/licenses/lucene-analysis-phonetic-9.0.0.jar.sha1 deleted file mode 100644 index 8d915a28087e6..0000000000000 --- a/plugins/analysis-phonetic/licenses/lucene-analysis-phonetic-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -437960fac10a9f8327fbd87be4e408eb140988b3 \ No newline at end of file diff --git a/plugins/analysis-phonetic/licenses/lucene-analysis-phonetic-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/plugins/analysis-phonetic/licenses/lucene-analysis-phonetic-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..e2006546433fd --- /dev/null +++ b/plugins/analysis-phonetic/licenses/lucene-analysis-phonetic-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +6f0f5c71052beee26e4ce99e1147ce406234f417 \ No newline at end of file diff --git a/plugins/analysis-phonetic/src/test/java/org/opensearch/index/analysis/SimplePhoneticAnalysisTests.java b/plugins/analysis-phonetic/src/test/java/org/opensearch/index/analysis/SimplePhoneticAnalysisTests.java index 73e6b814afaf5..69d9fe9762c32 100644 --- a/plugins/analysis-phonetic/src/test/java/org/opensearch/index/analysis/SimplePhoneticAnalysisTests.java +++ b/plugins/analysis-phonetic/src/test/java/org/opensearch/index/analysis/SimplePhoneticAnalysisTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.analysis; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; +import org.apache.lucene.tests.analysis.BaseTokenStreamTestCase; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; import org.apache.lucene.analysis.phonetic.DaitchMokotoffSoundexFilter; diff --git a/plugins/analysis-smartcn/licenses/lucene-analysis-smartcn-9.0.0.jar.sha1 b/plugins/analysis-smartcn/licenses/lucene-analysis-smartcn-9.0.0.jar.sha1 deleted file mode 100644 index d57bf6b3ab80d..0000000000000 --- a/plugins/analysis-smartcn/licenses/lucene-analysis-smartcn-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fe96c0b4609be5f7450773c2d7f099c51f4b1f7a \ No newline at end of file diff --git a/plugins/analysis-smartcn/licenses/lucene-analysis-smartcn-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/plugins/analysis-smartcn/licenses/lucene-analysis-smartcn-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..e675c5774f5a4 --- /dev/null +++ b/plugins/analysis-smartcn/licenses/lucene-analysis-smartcn-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +32aad8b8491df3c9862e7fe75e98bccdb6a25bda \ No newline at end of file diff --git a/plugins/analysis-stempel/licenses/lucene-analysis-stempel-9.0.0.jar.sha1 b/plugins/analysis-stempel/licenses/lucene-analysis-stempel-9.0.0.jar.sha1 deleted file mode 100644 index ade92c37c5865..0000000000000 --- a/plugins/analysis-stempel/licenses/lucene-analysis-stempel-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -b92e86dd451d225e68ee4abac5b00bf883b6ea00 \ No newline at end of file diff --git a/plugins/analysis-stempel/licenses/lucene-analysis-stempel-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/plugins/analysis-stempel/licenses/lucene-analysis-stempel-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..053f5c97d65dc --- /dev/null +++ b/plugins/analysis-stempel/licenses/lucene-analysis-stempel-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +ef546cfaaf727d93c4e86ddc7f77b525af135623 \ No newline at end of file diff --git a/plugins/analysis-stempel/src/test/java/org/opensearch/index/analysis/AnalysisPolishFactoryTests.java b/plugins/analysis-stempel/src/test/java/org/opensearch/index/analysis/AnalysisPolishFactoryTests.java index fb9c9d0ac3d0a..da6699fc1e95e 100644 --- a/plugins/analysis-stempel/src/test/java/org/opensearch/index/analysis/AnalysisPolishFactoryTests.java +++ b/plugins/analysis-stempel/src/test/java/org/opensearch/index/analysis/AnalysisPolishFactoryTests.java @@ -33,8 +33,8 @@ package org.opensearch.index.analysis; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.BaseTokenStreamTestCase; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.analysis.Tokenizer; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/plugins/analysis-ukrainian/licenses/lucene-analysis-morfologik-9.0.0.jar.sha1 b/plugins/analysis-ukrainian/licenses/lucene-analysis-morfologik-9.0.0.jar.sha1 deleted file mode 100644 index 433ce1f0552c8..0000000000000 --- a/plugins/analysis-ukrainian/licenses/lucene-analysis-morfologik-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -048fddf601c6de7dd296f6da3f394544618f7cea \ No newline at end of file diff --git a/plugins/analysis-ukrainian/licenses/lucene-analysis-morfologik-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/plugins/analysis-ukrainian/licenses/lucene-analysis-morfologik-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..e5a2a0b0b4ab3 --- /dev/null +++ b/plugins/analysis-ukrainian/licenses/lucene-analysis-morfologik-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +21c3511469f67019804e41a8d83ffc5c36de6479 \ No newline at end of file diff --git a/plugins/analysis-ukrainian/src/main/java/org/opensearch/index/analysis/UkrainianAnalyzerProvider.java b/plugins/analysis-ukrainian/src/main/java/org/opensearch/index/analysis/UkrainianAnalyzerProvider.java index 9beced7d465a6..e752807c49f07 100644 --- a/plugins/analysis-ukrainian/src/main/java/org/opensearch/index/analysis/UkrainianAnalyzerProvider.java +++ b/plugins/analysis-ukrainian/src/main/java/org/opensearch/index/analysis/UkrainianAnalyzerProvider.java @@ -45,7 +45,7 @@ public class UkrainianAnalyzerProvider extends AbstractIndexAnalyzerProvider parameters() throws Exception { return OpenSearchClientYamlSuiteTestCase.createParameters(); } } - diff --git a/qa/wildfly/build.gradle b/qa/wildfly/build.gradle index 8f6afefe97e5c..7cb08a9de6f08 100644 --- a/qa/wildfly/build.gradle +++ b/qa/wildfly/build.gradle @@ -102,7 +102,7 @@ testingConventions { // We only have one "special" integration test here to connect to wildfly naming { IT { - baseClass 'org.apache.lucene.util.LuceneTestCase' + baseClass 'org.apache.lucene.tests.util.LuceneTestCase' } } } diff --git a/qa/wildfly/src/test/java/org/opensearch/wildfly/WildflyIT.java b/qa/wildfly/src/test/java/org/opensearch/wildfly/WildflyIT.java index 1c448362bbead..7961ca69c2d29 100644 --- a/qa/wildfly/src/test/java/org/opensearch/wildfly/WildflyIT.java +++ b/qa/wildfly/src/test/java/org/opensearch/wildfly/WildflyIT.java @@ -42,8 +42,8 @@ import org.apache.http.util.EntityUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.TestRuleLimitSysouts; +import org.apache.lucene.tests.util.LuceneTestCase; +import org.apache.lucene.tests.util.TestRuleLimitSysouts; import org.opensearch.cluster.ClusterModule; import org.opensearch.common.xcontent.DeprecationHandler; import org.opensearch.common.xcontent.NamedXContentRegistry; diff --git a/rest-api-spec/src/yamlRestTest/java/org/opensearch/test/rest/ClientYamlTestSuiteIT.java b/rest-api-spec/src/yamlRestTest/java/org/opensearch/test/rest/ClientYamlTestSuiteIT.java index 86b4567c3ad4d..9a1973e9d5aeb 100644 --- a/rest-api-spec/src/yamlRestTest/java/org/opensearch/test/rest/ClientYamlTestSuiteIT.java +++ b/rest-api-spec/src/yamlRestTest/java/org/opensearch/test/rest/ClientYamlTestSuiteIT.java @@ -35,7 +35,7 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; -import org.apache.lucene.util.TimeUnits; +import org.apache.lucene.tests.util.TimeUnits; import org.opensearch.test.rest.yaml.ClientYamlTestCandidate; import org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase; diff --git a/server/build.gradle b/server/build.gradle index dcf4d43c60192..45ec2300008f2 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -182,7 +182,7 @@ tasks.named("testingConventions").configure { naming.clear() naming { Tests { - baseClass "org.apache.lucene.util.LuceneTestCase" + baseClass "org.apache.lucene.tests.util.LuceneTestCase" } IT { baseClass "org.opensearch.test.OpenSearchIntegTestCase" diff --git a/server/licenses/lucene-analysis-common-9.0.0.jar.sha1 b/server/licenses/lucene-analysis-common-9.0.0.jar.sha1 deleted file mode 100644 index 2ed9dbcbe22f6..0000000000000 --- a/server/licenses/lucene-analysis-common-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -f78890829c3d6f15de48fdbc2c77ef4c0e3f005c \ No newline at end of file diff --git a/server/licenses/lucene-analysis-common-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-analysis-common-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..6ef0f1eafc345 --- /dev/null +++ b/server/licenses/lucene-analysis-common-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +bafd720282a371efe7b0e7238f9dee7e2ad3a586 \ No newline at end of file diff --git a/server/licenses/lucene-backward-codecs-9.0.0.jar.sha1 b/server/licenses/lucene-backward-codecs-9.0.0.jar.sha1 deleted file mode 100644 index acf5a2b543199..0000000000000 --- a/server/licenses/lucene-backward-codecs-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -9fb48d0244799e18299449ee62459caab0728490 \ No newline at end of file diff --git a/server/licenses/lucene-backward-codecs-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-backward-codecs-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..017333945a866 --- /dev/null +++ b/server/licenses/lucene-backward-codecs-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +597fe288a252a14c0876451c97afee2b4529f85a \ No newline at end of file diff --git a/server/licenses/lucene-core-9.0.0.jar.sha1 b/server/licenses/lucene-core-9.0.0.jar.sha1 deleted file mode 100644 index c874382fc8355..0000000000000 --- a/server/licenses/lucene-core-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -be679fd274f264e4e8b02bc032d2788cd4076ab4 \ No newline at end of file diff --git a/server/licenses/lucene-core-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-core-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..a2ba0f0ffa43c --- /dev/null +++ b/server/licenses/lucene-core-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +80cd2fff33ced89924771c7079d42bf82f1266f6 \ No newline at end of file diff --git a/server/licenses/lucene-grouping-9.0.0.jar.sha1 b/server/licenses/lucene-grouping-9.0.0.jar.sha1 deleted file mode 100644 index 18a81b5fa97ff..0000000000000 --- a/server/licenses/lucene-grouping-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -27ebe235d427b4e392fabab9b6bfa09524ca7f8b \ No newline at end of file diff --git a/server/licenses/lucene-grouping-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-grouping-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..ac0c1be0f952b --- /dev/null +++ b/server/licenses/lucene-grouping-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +7059f47668a2942c60ad03b1d58eca8dcb010e4e \ No newline at end of file diff --git a/server/licenses/lucene-highlighter-9.0.0.jar.sha1 b/server/licenses/lucene-highlighter-9.0.0.jar.sha1 deleted file mode 100644 index 5503495c2f86c..0000000000000 --- a/server/licenses/lucene-highlighter-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -a3cb395c2e8c672e6eec951b2b02371a4a883f73 \ No newline at end of file diff --git a/server/licenses/lucene-highlighter-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-highlighter-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..fa08ed63f7c44 --- /dev/null +++ b/server/licenses/lucene-highlighter-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +3c841ca23eb08a939fa49ba4af249c3b6d849c42 \ No newline at end of file diff --git a/server/licenses/lucene-join-9.0.0.jar.sha1 b/server/licenses/lucene-join-9.0.0.jar.sha1 deleted file mode 100644 index dcbaa17875435..0000000000000 --- a/server/licenses/lucene-join-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -94a855b5d09a6601289aeaeba0f11d5539552590 \ No newline at end of file diff --git a/server/licenses/lucene-join-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-join-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..2a3e2a9107a60 --- /dev/null +++ b/server/licenses/lucene-join-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +4984e041ae68f5939c01e41b2c9648ae2c021340 \ No newline at end of file diff --git a/server/licenses/lucene-memory-9.0.0.jar.sha1 b/server/licenses/lucene-memory-9.0.0.jar.sha1 deleted file mode 100644 index 157597ce9878f..0000000000000 --- a/server/licenses/lucene-memory-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -2371c95031422bc1f501d43ffcc7311baed4b35b \ No newline at end of file diff --git a/server/licenses/lucene-memory-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-memory-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..eefd08d222ef8 --- /dev/null +++ b/server/licenses/lucene-memory-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +fead9467ce65469579168eb0f47e014fdb3c63d9 \ No newline at end of file diff --git a/server/licenses/lucene-misc-9.0.0.jar.sha1 b/server/licenses/lucene-misc-9.0.0.jar.sha1 deleted file mode 100644 index ef031d34305a2..0000000000000 --- a/server/licenses/lucene-misc-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -25c6170f4fa2f707908dfb92fbafc76727f901e0 \ No newline at end of file diff --git a/server/licenses/lucene-misc-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-misc-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..226f97cf6f3bc --- /dev/null +++ b/server/licenses/lucene-misc-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +d98ab1966b8ca53b70fe071281bcea27d602ec30 \ No newline at end of file diff --git a/server/licenses/lucene-queries-9.0.0.jar.sha1 b/server/licenses/lucene-queries-9.0.0.jar.sha1 deleted file mode 100644 index 4b43c9e6b709a..0000000000000 --- a/server/licenses/lucene-queries-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -87b4c7833d30895baf7091f9cb0db878e970b604 \ No newline at end of file diff --git a/server/licenses/lucene-queries-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-queries-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..c151e6b76e21a --- /dev/null +++ b/server/licenses/lucene-queries-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +895e27127ae55031e35e152da8be941bd55f7f6a \ No newline at end of file diff --git a/server/licenses/lucene-queryparser-9.0.0.jar.sha1 b/server/licenses/lucene-queryparser-9.0.0.jar.sha1 deleted file mode 100644 index 62a4650a168c7..0000000000000 --- a/server/licenses/lucene-queryparser-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -bf13395ad2033bca3182fcbc83204e8ae1951945 \ No newline at end of file diff --git a/server/licenses/lucene-queryparser-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-queryparser-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..b73b7152aed05 --- /dev/null +++ b/server/licenses/lucene-queryparser-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +1433392237ea01ef35f4e2ffc52f496b0669624c \ No newline at end of file diff --git a/server/licenses/lucene-sandbox-9.0.0.jar.sha1 b/server/licenses/lucene-sandbox-9.0.0.jar.sha1 deleted file mode 100644 index 4396efda1a83b..0000000000000 --- a/server/licenses/lucene-sandbox-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -3c153a1dc1da3f98083cc932c9476df4b77b0ca5 \ No newline at end of file diff --git a/server/licenses/lucene-sandbox-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-sandbox-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..d441dd2f8cb31 --- /dev/null +++ b/server/licenses/lucene-sandbox-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +b0688963ca8288f5a3e47ca6e4b38bc2fde780e7 \ No newline at end of file diff --git a/server/licenses/lucene-spatial-extras-9.0.0.jar.sha1 b/server/licenses/lucene-spatial-extras-9.0.0.jar.sha1 deleted file mode 100644 index a742934def499..0000000000000 --- a/server/licenses/lucene-spatial-extras-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -91535ef6512c45c7e2b113b04cab7738ee774893 \ No newline at end of file diff --git a/server/licenses/lucene-spatial-extras-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-spatial-extras-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..5ffa78a6e7d87 --- /dev/null +++ b/server/licenses/lucene-spatial-extras-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +206e8918a726710c8a6fb927e59adf26c6ad5bed \ No newline at end of file diff --git a/server/licenses/lucene-spatial3d-9.0.0.jar.sha1 b/server/licenses/lucene-spatial3d-9.0.0.jar.sha1 deleted file mode 100644 index 0722795c260ad..0000000000000 --- a/server/licenses/lucene-spatial3d-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -6b4ee47f218ed3d123c1b07671677a2e4f3c133b \ No newline at end of file diff --git a/server/licenses/lucene-spatial3d-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-spatial3d-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..8c4bb08303c34 --- /dev/null +++ b/server/licenses/lucene-spatial3d-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +3d1e26c37b45bdf2ef598d16468220ab33983a8f \ No newline at end of file diff --git a/server/licenses/lucene-suggest-9.0.0.jar.sha1 b/server/licenses/lucene-suggest-9.0.0.jar.sha1 deleted file mode 100644 index 7eb41e758379e..0000000000000 --- a/server/licenses/lucene-suggest-9.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -a7d0e7279737114c039f5214082da948732096a6 \ No newline at end of file diff --git a/server/licenses/lucene-suggest-9.1.0-snapshot-ea989fe8f30.jar.sha1 b/server/licenses/lucene-suggest-9.1.0-snapshot-ea989fe8f30.jar.sha1 new file mode 100644 index 0000000000000..3c8d9b87da0e5 --- /dev/null +++ b/server/licenses/lucene-suggest-9.1.0-snapshot-ea989fe8f30.jar.sha1 @@ -0,0 +1 @@ +69ab05339614766c732fef7c037cc5b676bd40dc \ No newline at end of file diff --git a/server/src/internalClusterTest/java/org/opensearch/bwcompat/RecoveryWithUnsupportedIndicesIT.java b/server/src/internalClusterTest/java/org/opensearch/bwcompat/RecoveryWithUnsupportedIndicesIT.java index 01eedd3be5078..047584c1f13cb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/bwcompat/RecoveryWithUnsupportedIndicesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/bwcompat/RecoveryWithUnsupportedIndicesIT.java @@ -39,8 +39,8 @@ import java.util.ArrayList; import java.util.List; -import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.LuceneTestCase; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.ExceptionsHelper; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/allocation/ClusterRerouteIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/allocation/ClusterRerouteIT.java index cdf853c2ad9ae..ee2a8784fa0ed 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/allocation/ClusterRerouteIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/allocation/ClusterRerouteIT.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.cluster.reroute.ClusterRerouteResponse; import org.opensearch.action.admin.cluster.reroute.TransportClusterRerouteAction; diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java index 96f059695e719..eb3e61d83a948 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java @@ -32,9 +32,9 @@ package org.opensearch.cluster.routing.allocation.decider; -import org.apache.lucene.mockfile.FilterFileStore; -import org.apache.lucene.mockfile.FilterFileSystemProvider; -import org.apache.lucene.mockfile.FilterPath; +import org.apache.lucene.tests.mockfile.FilterFileStore; +import org.apache.lucene.tests.mockfile.FilterFileSystemProvider; +import org.apache.lucene.tests.mockfile.FilterPath; import org.apache.lucene.util.Constants; import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/DiskDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/DiskDisruptionIT.java index cd35670279bc6..ef00150b7c814 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/DiskDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/DiskDisruptionIT.java @@ -32,7 +32,7 @@ package org.opensearch.discovery; import com.carrotsearch.randomizedtesting.RandomizedTest; -import org.apache.lucene.mockfile.FilterFileSystemProvider; +import org.apache.lucene.tests.mockfile.FilterFileSystemProvider; import org.opensearch.action.admin.indices.stats.ShardStats; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.io.PathUtils; diff --git a/server/src/internalClusterTest/java/org/opensearch/index/engine/MaxDocsLimitIT.java b/server/src/internalClusterTest/java/org/opensearch/index/engine/MaxDocsLimitIT.java index da3b30030581f..b548d4061475c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/engine/MaxDocsLimitIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/engine/MaxDocsLimitIT.java @@ -32,8 +32,6 @@ package org.opensearch.index.engine; -import org.apache.lucene.index.IndexWriterMaxDocsChanger; - import org.opensearch.action.index.IndexResponse; import org.opensearch.action.search.SearchResponse; import org.opensearch.cluster.metadata.IndexMetadata; @@ -94,12 +92,12 @@ protected Collection> nodePlugins() { @Before public void setMaxDocs() { maxDocs.set(randomIntBetween(10, 100)); // Do not set this too low as we can fail to write the cluster state - IndexWriterMaxDocsChanger.setMaxDocs(maxDocs.get()); + setIndexWriterMaxDocs(maxDocs.get()); } @After public void restoreMaxDocs() { - IndexWriterMaxDocsChanger.restoreMaxDocs(); + restoreIndexWriterMaxDocs(); } public void testMaxDocsLimit() throws Exception { diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java index c503dd9f83273..a24f55be3f010 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java @@ -32,7 +32,7 @@ package org.opensearch.indices.stats; -import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; +import org.apache.lucene.tests.util.LuceneTestCase.SuppressCodecs; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse; import org.opensearch.action.admin.indices.create.CreateIndexRequest; diff --git a/server/src/internalClusterTest/java/org/opensearch/recovery/RelocationIT.java b/server/src/internalClusterTest/java/org/opensearch/recovery/RelocationIT.java index d17761f62eb53..06475f1e7ac9d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/recovery/RelocationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/recovery/RelocationIT.java @@ -34,7 +34,7 @@ import com.carrotsearch.hppc.cursors.ObjectCursor; import org.apache.lucene.index.IndexFileNames; -import org.apache.lucene.util.English; +import org.apache.lucene.tests.util.English; import org.opensearch.action.ActionFuture; import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; import org.opensearch.action.admin.cluster.reroute.ClusterRerouteResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java b/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java index 45fb1a8fc58c0..71da9168c6205 100644 --- a/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java @@ -32,8 +32,8 @@ package org.opensearch.recovery; -import org.apache.lucene.util.English; -import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; +import org.apache.lucene.tests.util.English; +import org.apache.lucene.tests.util.LuceneTestCase.SuppressCodecs; import org.opensearch.action.admin.cluster.node.stats.NodeStats; import org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse; import org.opensearch.action.index.IndexRequestBuilder; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/StressSearchServiceReaperIT.java b/server/src/internalClusterTest/java/org/opensearch/search/StressSearchServiceReaperIT.java index 96f3f710e4b7d..42e515cca9b6b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/StressSearchServiceReaperIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/StressSearchServiceReaperIT.java @@ -31,7 +31,7 @@ package org.opensearch.search; -import org.apache.lucene.util.English; +import org.apache.lucene.tests.util.English; import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.SearchResponse; import org.opensearch.common.settings.Settings; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWithRandomExceptionsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWithRandomExceptionsIT.java index 9efb07fc7e581..0b55ea9119d89 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWithRandomExceptionsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWithRandomExceptionsIT.java @@ -35,7 +35,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.FilterDirectoryReader; import org.apache.lucene.index.LeafReader; -import org.apache.lucene.util.English; +import org.apache.lucene.tests.util.English; import org.opensearch.OpenSearchException; import org.opensearch.action.DocWriteResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWithRandomIOExceptionsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWithRandomIOExceptionsIT.java index 094ab8a19c88b..b0adc00f37fee 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWithRandomIOExceptionsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWithRandomIOExceptionsIT.java @@ -32,7 +32,7 @@ package org.opensearch.search.basic; -import org.apache.lucene.util.English; +import org.apache.lucene.tests.util.English; import org.opensearch.OpenSearchException; import org.opensearch.action.DocWriteResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java index d1b3895ff40e1..27513b575d6f0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java @@ -33,8 +33,8 @@ import com.carrotsearch.randomizedtesting.generators.RandomPicks; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.MockAnalyzer; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockAnalyzer; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenFilter; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/QueryRescorerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/QueryRescorerIT.java index a21363e58949b..e216e92c63bad 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/QueryRescorerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/QueryRescorerIT.java @@ -33,7 +33,7 @@ package org.opensearch.search.functionscore; import org.apache.lucene.search.Explanation; -import org.apache.lucene.util.English; +import org.apache.lucene.tests.util.English; import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.SearchRequestBuilder; import org.opensearch.action.search.SearchResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/profile/ProfilerSingleNodeNetworkTest.java b/server/src/internalClusterTest/java/org/opensearch/search/profile/ProfilerSingleNodeNetworkTest.java index 24885c1f853ef..12d68c9c38ca1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/profile/ProfilerSingleNodeNetworkTest.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/profile/ProfilerSingleNodeNetworkTest.java @@ -7,7 +7,7 @@ package org.opensearch.search.profile; -import org.apache.lucene.util.English; +import org.apache.lucene.tests.util.English; import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.SearchResponse; import org.opensearch.action.search.SearchType; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/profile/query/QueryProfilerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/profile/query/QueryProfilerIT.java index 65d3ee2779de8..a74f359f2542e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/profile/query/QueryProfilerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/profile/query/QueryProfilerIT.java @@ -32,7 +32,7 @@ package org.opensearch.search.profile.query; -import org.apache.lucene.util.English; +import org.apache.lucene.tests.util.English; import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.*; import org.opensearch.common.settings.Settings; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java index c9bb746973226..fb744ccfc4655 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java @@ -32,13 +32,13 @@ package org.opensearch.search.query; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.analysis.pattern.PatternReplaceCharFilter; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.join.ScoreMode; import org.apache.lucene.util.AttributeSource; -import org.apache.lucene.util.English; +import org.apache.lucene.tests.util.English; import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.SearchPhaseExecutionException; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java index 92dfedeb99a23..38aac2850dc56 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java @@ -33,7 +33,7 @@ package org.opensearch.search.sort; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.apache.lucene.util.UnicodeUtil; import org.opensearch.OpenSearchException; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/suggest/CompletionSuggestSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/suggest/CompletionSuggestSearchIT.java index 099ffbc278f81..e85eff8450ca4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/suggest/CompletionSuggestSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/suggest/CompletionSuggestSearchIT.java @@ -34,7 +34,7 @@ import com.carrotsearch.randomizedtesting.generators.RandomStrings; import org.apache.lucene.analysis.TokenStreamToAutomaton; import org.apache.lucene.search.suggest.document.ContextSuggestField; -import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; +import org.apache.lucene.tests.util.LuceneTestCase.SuppressCodecs; import org.opensearch.action.admin.indices.forcemerge.ForceMergeResponse; import org.opensearch.action.admin.indices.segments.IndexShardSegments; import org.opensearch.action.admin.indices.segments.ShardSegments; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/suggest/ContextCompletionSuggestSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/suggest/ContextCompletionSuggestSearchIT.java index c9b14993d6e49..acc4350d149cd 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/suggest/ContextCompletionSuggestSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/suggest/ContextCompletionSuggestSearchIT.java @@ -32,7 +32,7 @@ package org.opensearch.search.suggest; import com.carrotsearch.randomizedtesting.generators.RandomStrings; -import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; +import org.apache.lucene.tests.util.LuceneTestCase.SuppressCodecs; import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.index.IndexResponse; diff --git a/server/src/internalClusterTest/java/org/opensearch/versioning/SimpleVersioningIT.java b/server/src/internalClusterTest/java/org/opensearch/versioning/SimpleVersioningIT.java index 629b20edbb44d..5898bba9762ad 100644 --- a/server/src/internalClusterTest/java/org/opensearch/versioning/SimpleVersioningIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/versioning/SimpleVersioningIT.java @@ -31,7 +31,7 @@ package org.opensearch.versioning; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.action.ActionResponse; import org.opensearch.action.DocWriteRequest; import org.opensearch.action.DocWriteResponse; diff --git a/server/src/main/java/org/apache/lucene/search/grouping/CollapseTopFieldDocs.java b/server/src/main/java/org/apache/lucene/search/grouping/CollapseTopFieldDocs.java index eee710892312a..fe26c313d72b2 100644 --- a/server/src/main/java/org/apache/lucene/search/grouping/CollapseTopFieldDocs.java +++ b/server/src/main/java/org/apache/lucene/search/grouping/CollapseTopFieldDocs.java @@ -144,7 +144,7 @@ private static class MergeSortQueue extends PriorityQueue { reverseMul = new int[sortFields.length]; for (int compIDX = 0; compIDX < sortFields.length; compIDX++) { final SortField sortField = sortFields[compIDX]; - comparators[compIDX] = sortField.getComparator(1, compIDX); + comparators[compIDX] = sortField.getComparator(1, false); reverseMul[compIDX] = sortField.getReverse() ? -1 : 1; } } diff --git a/server/src/main/java/org/opensearch/Version.java b/server/src/main/java/org/opensearch/Version.java index e8a06af50f525..860bb2c5ada69 100644 --- a/server/src/main/java/org/opensearch/Version.java +++ b/server/src/main/java/org/opensearch/Version.java @@ -80,7 +80,7 @@ public class Version implements Comparable, ToXContentFragment { public static final Version V_1_2_5 = new Version(1020599, org.apache.lucene.util.Version.LUCENE_8_10_1); public static final Version V_1_3_0 = new Version(1030099, org.apache.lucene.util.Version.LUCENE_8_10_1); public static final Version V_1_4_0 = new Version(1040099, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_2_0_0 = new Version(2000099, org.apache.lucene.util.Version.LUCENE_9_0_0); + public static final Version V_2_0_0 = new Version(2000099, org.apache.lucene.util.Version.LUCENE_9_1_0); public static final Version CURRENT = V_2_0_0; public static Version readVersion(StreamInput in) throws IOException { diff --git a/server/src/main/java/org/opensearch/action/search/BottomSortValuesCollector.java b/server/src/main/java/org/opensearch/action/search/BottomSortValuesCollector.java index 0ee2bba73f009..64f50d2f37cdb 100644 --- a/server/src/main/java/org/opensearch/action/search/BottomSortValuesCollector.java +++ b/server/src/main/java/org/opensearch/action/search/BottomSortValuesCollector.java @@ -57,7 +57,7 @@ class BottomSortValuesCollector { this.reverseMuls = new int[sortFields.length]; this.sortFields = sortFields; for (int i = 0; i < sortFields.length; i++) { - comparators[i] = sortFields[i].getComparator(1, i); + comparators[i] = sortFields[i].getComparator(1, false); reverseMuls[i] = sortFields[i].getReverse() ? -1 : 1; } } diff --git a/server/src/main/java/org/opensearch/common/lucene/Lucene.java b/server/src/main/java/org/opensearch/common/lucene/Lucene.java index 6e17aab92f24b..4cbc7a6668dee 100644 --- a/server/src/main/java/org/opensearch/common/lucene/Lucene.java +++ b/server/src/main/java/org/opensearch/common/lucene/Lucene.java @@ -120,7 +120,7 @@ import java.util.Map; public class Lucene { - public static final String LATEST_CODEC = "Lucene90"; + public static final String LATEST_CODEC = "Lucene91"; public static final String SOFT_DELETES_FIELD = "__soft_deletes"; @@ -1118,7 +1118,7 @@ public VectorValues getVectorValues(String field) throws IOException { } @Override - public TopDocs searchNearestVectors(String field, float[] target, int k, Bits acceptDocs) throws IOException { + public TopDocs searchNearestVectors(String field, float[] target, int k, Bits acceptDocs, int visitedLimit) throws IOException { return null; } }; diff --git a/server/src/main/java/org/opensearch/common/lucene/search/MultiPhrasePrefixQuery.java b/server/src/main/java/org/opensearch/common/lucene/search/MultiPhrasePrefixQuery.java index 711ff9860a5ce..982779333e7da 100644 --- a/server/src/main/java/org/opensearch/common/lucene/search/MultiPhrasePrefixQuery.java +++ b/server/src/main/java/org/opensearch/common/lucene/search/MultiPhrasePrefixQuery.java @@ -186,7 +186,7 @@ public Query rewrite(IndexReader reader) throws IOException { // which rewrites query with an empty reader. return new BooleanQuery.Builder().add(query.build(), BooleanClause.Occur.MUST) .add( - Queries.newMatchNoDocsQuery("No terms supplied for " + MultiPhrasePrefixQuery.class.getName()), + Queries.newMatchNoDocsQueryWithoutRewrite("No terms supplied for " + MultiPhrasePrefixQuery.class.getName()), BooleanClause.Occur.MUST ) .build(); diff --git a/server/src/main/java/org/opensearch/common/lucene/search/Queries.java b/server/src/main/java/org/opensearch/common/lucene/search/Queries.java index ef10d1eb0d221..2f500efba9e8e 100644 --- a/server/src/main/java/org/opensearch/common/lucene/search/Queries.java +++ b/server/src/main/java/org/opensearch/common/lucene/search/Queries.java @@ -32,25 +32,34 @@ package org.opensearch.common.lucene.search; +import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.Term; import org.apache.lucene.queries.ExtendedCommonTermsQuery; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.DocValuesFieldExistsQuery; +import org.apache.lucene.search.Explanation; +import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.PrefixQuery; import org.apache.lucene.search.Query; +import org.apache.lucene.search.QueryVisitor; +import org.apache.lucene.search.ScoreMode; +import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Weight; import org.apache.lucene.util.BytesRef; import org.opensearch.OpenSearchException; import org.opensearch.common.Nullable; import org.opensearch.index.mapper.SeqNoFieldMapper; import org.opensearch.index.mapper.TypeFieldMapper; +import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.regex.Pattern; public class Queries { @@ -200,4 +209,57 @@ public static int calculateMinShouldMatch(int optionalClauseCount, String spec) return result < 0 ? 0 : result; } + + public static Query newMatchNoDocsQueryWithoutRewrite(String reason) { + return new MatchNoDocsWithoutRewriteQuery(reason); + } + + static class MatchNoDocsWithoutRewriteQuery extends Query { + private final String reason; + + public MatchNoDocsWithoutRewriteQuery(String reason) { + this.reason = reason; + } + + @Override + public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { + return new Weight(this) { + @Override + public Explanation explain(LeafReaderContext context, int doc) { + return Explanation.noMatch(reason); + } + + @Override + public Scorer scorer(LeafReaderContext context) { + return null; + } + + @Override + public boolean isCacheable(LeafReaderContext ctx) { + return true; + } + }; + } + + @Override + public String toString(String field) { + return "MatchNoDocsWithoutRewriteQuery(" + reason + ")"; + } + + @Override + public void visit(QueryVisitor visitor) { + // noop + } + + @Override + public boolean equals(Object o) { + return o instanceof MatchNoDocsWithoutRewriteQuery && Objects.equals(this.reason, ((MatchNoDocsWithoutRewriteQuery) o).reason); + } + + @Override + public int hashCode() { + return Objects.hashCode(reason); + } + } + } diff --git a/server/src/main/java/org/opensearch/index/codec/CodecService.java b/server/src/main/java/org/opensearch/index/codec/CodecService.java index d22c7239922bc..e445ad88f497e 100644 --- a/server/src/main/java/org/opensearch/index/codec/CodecService.java +++ b/server/src/main/java/org/opensearch/index/codec/CodecService.java @@ -34,8 +34,8 @@ import org.apache.logging.log4j.Logger; import org.apache.lucene.codecs.Codec; -import org.apache.lucene.codecs.lucene90.Lucene90Codec; -import org.apache.lucene.codecs.lucene90.Lucene90Codec.Mode; +import org.apache.lucene.codecs.lucene91.Lucene91Codec; +import org.apache.lucene.codecs.lucene91.Lucene91Codec.Mode; import org.opensearch.common.Nullable; import org.opensearch.common.collect.MapBuilder; import org.opensearch.index.mapper.MapperService; @@ -60,8 +60,8 @@ public class CodecService { public CodecService(@Nullable MapperService mapperService, Logger logger) { final MapBuilder codecs = MapBuilder.newMapBuilder(); if (mapperService == null) { - codecs.put(DEFAULT_CODEC, new Lucene90Codec()); - codecs.put(BEST_COMPRESSION_CODEC, new Lucene90Codec(Mode.BEST_COMPRESSION)); + codecs.put(DEFAULT_CODEC, new Lucene91Codec()); + codecs.put(BEST_COMPRESSION_CODEC, new Lucene91Codec(Mode.BEST_COMPRESSION)); } else { codecs.put(DEFAULT_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_SPEED, mapperService, logger)); codecs.put(BEST_COMPRESSION_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_COMPRESSION, mapperService, logger)); diff --git a/server/src/main/java/org/opensearch/index/codec/PerFieldMappingPostingFormatCodec.java b/server/src/main/java/org/opensearch/index/codec/PerFieldMappingPostingFormatCodec.java index 20a8ff7ca9170..fa01390d13419 100644 --- a/server/src/main/java/org/opensearch/index/codec/PerFieldMappingPostingFormatCodec.java +++ b/server/src/main/java/org/opensearch/index/codec/PerFieldMappingPostingFormatCodec.java @@ -36,7 +36,7 @@ import org.apache.lucene.codecs.Codec; import org.apache.lucene.codecs.DocValuesFormat; import org.apache.lucene.codecs.PostingsFormat; -import org.apache.lucene.codecs.lucene90.Lucene90Codec; +import org.apache.lucene.codecs.lucene91.Lucene91Codec; import org.apache.lucene.codecs.lucene90.Lucene90DocValuesFormat; import org.opensearch.common.lucene.Lucene; import org.opensearch.index.mapper.CompletionFieldMapper; @@ -51,7 +51,7 @@ * per index in real time via the mapping API. If no specific postings format is * configured for a specific field the default postings format is used. */ -public class PerFieldMappingPostingFormatCodec extends Lucene90Codec { +public class PerFieldMappingPostingFormatCodec extends Lucene91Codec { private final Logger logger; private final MapperService mapperService; private final DocValuesFormat dvFormat = new Lucene90DocValuesFormat(); diff --git a/server/src/main/java/org/opensearch/index/engine/TranslogLeafReader.java b/server/src/main/java/org/opensearch/index/engine/TranslogLeafReader.java index 07fe3f9230de4..09a670237a8a5 100644 --- a/server/src/main/java/org/opensearch/index/engine/TranslogLeafReader.java +++ b/server/src/main/java/org/opensearch/index/engine/TranslogLeafReader.java @@ -242,7 +242,7 @@ public VectorValues getVectorValues(String field) throws IOException { } @Override - public TopDocs searchNearestVectors(String field, float[] target, int k, Bits acceptDocs) throws IOException { + public TopDocs searchNearestVectors(String field, float[] target, int k, Bits acceptDocs, int visitedLimit) throws IOException { throw new UnsupportedOperationException(); } } diff --git a/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/BytesRefFieldComparatorSource.java b/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/BytesRefFieldComparatorSource.java index 0392018112619..d25443914ebaa 100644 --- a/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/BytesRefFieldComparatorSource.java +++ b/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/BytesRefFieldComparatorSource.java @@ -91,7 +91,7 @@ protected SortedBinaryDocValues getValues(LeafReaderContext context) throws IOEx protected void setScorer(Scorable scorer) {} @Override - public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) { + public FieldComparator newComparator(String fieldname, int numHits, boolean enableSkipping, boolean reversed) { assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName()); final boolean sortMissingLast = sortMissingLast(missingValue) ^ reversed; diff --git a/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java b/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java index f80d6961fe9be..135101eae362d 100644 --- a/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java +++ b/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java @@ -96,13 +96,13 @@ private NumericDoubleValues getNumericDocValues(LeafReaderContext context, doubl protected void setScorer(Scorable scorer) {} @Override - public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) { + public FieldComparator newComparator(String fieldname, int numHits, boolean enableSkipping, boolean reversed) { assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName()); final double dMissingValue = (Double) missingObject(missingValue, reversed); // NOTE: it's important to pass null as a missing value in the constructor so that // the comparator doesn't check docsWithField since we replace missing values in select() - return new DoubleComparator(numHits, null, null, reversed, sortPos) { + return new DoubleComparator(numHits, null, null, reversed, false) { @Override public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException { return new DoubleLeafComparator(context) { diff --git a/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/FloatValuesComparatorSource.java b/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/FloatValuesComparatorSource.java index 3f8f573eff27b..f8371e8235070 100644 --- a/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/FloatValuesComparatorSource.java +++ b/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/FloatValuesComparatorSource.java @@ -89,13 +89,13 @@ private NumericDoubleValues getNumericDocValues(LeafReaderContext context, float } @Override - public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) { + public FieldComparator newComparator(String fieldname, int numHits, boolean enableSkipping, boolean reversed) { assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName()); final float fMissingValue = (Float) missingObject(missingValue, reversed); // NOTE: it's important to pass null as a missing value in the constructor so that // the comparator doesn't check docsWithField since we replace missing values in select() - return new FloatComparator(numHits, null, null, reversed, sortPos) { + return new FloatComparator(numHits, null, null, reversed, false) { @Override public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException { return new FloatLeafComparator(context) { diff --git a/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java b/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java index b036ec14d9bd0..3871425f1255f 100644 --- a/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java +++ b/server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java @@ -112,13 +112,13 @@ private NumericDocValues getNumericDocValues(LeafReaderContext context, long mis } @Override - public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) { + public FieldComparator newComparator(String fieldname, int numHits, boolean enableSkipping, boolean reversed) { assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName()); final long lMissingValue = (Long) missingObject(missingValue, reversed); // NOTE: it's important to pass null as a missing value in the constructor so that // the comparator doesn't check docsWithField since we replace missing values in select() - return new LongComparator(numHits, null, null, reversed, sortPos) { + return new LongComparator(numHits, null, null, reversed, false) { @Override public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException { return new LongLeafComparator(context) { diff --git a/server/src/main/java/org/opensearch/lucene/queries/SearchAfterSortedDocQuery.java b/server/src/main/java/org/opensearch/lucene/queries/SearchAfterSortedDocQuery.java index fd4d84fabe9c7..70cc73d2108cc 100644 --- a/server/src/main/java/org/opensearch/lucene/queries/SearchAfterSortedDocQuery.java +++ b/server/src/main/java/org/opensearch/lucene/queries/SearchAfterSortedDocQuery.java @@ -76,7 +76,7 @@ public SearchAfterSortedDocQuery(Sort sort, FieldDoc after) { this.reverseMuls = new int[numFields]; for (int i = 0; i < numFields; i++) { SortField sortField = sort.getSort()[i]; - FieldComparator fieldComparator = sortField.getComparator(1, i); + FieldComparator fieldComparator = sortField.getComparator(1, false); @SuppressWarnings("unchecked") FieldComparator comparator = (FieldComparator) fieldComparator; comparator.setTopValue(after.fields[i]); diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregator.java index 73dc838a36198..6af887201d994 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregator.java @@ -349,8 +349,8 @@ public int hashCode() { } @Override - public FieldComparator getComparator(int numHits, int sortPos) { - return new LongComparator(1, delegate.getField(), (Long) missingValue, delegate.getReverse(), sortPos) { + public FieldComparator getComparator(int numHits, boolean enableSkipping) { + return new LongComparator(1, delegate.getField(), (Long) missingValue, delegate.getReverse(), false) { @Override public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException { return new LongLeafComparator(context) { diff --git a/server/src/main/java/org/opensearch/search/internal/ExitableDirectoryReader.java b/server/src/main/java/org/opensearch/search/internal/ExitableDirectoryReader.java index 2dc926176b1b4..9664fe3cb9085 100644 --- a/server/src/main/java/org/opensearch/search/internal/ExitableDirectoryReader.java +++ b/server/src/main/java/org/opensearch/search/internal/ExitableDirectoryReader.java @@ -196,6 +196,84 @@ public BytesRef next() throws IOException { } } + // delegates to PointValues but adds query cancellation checks + private static class ExitablePointTree implements PointValues.PointTree { + private final PointValues values; + private final PointValues.PointTree pointTree; + private final ExitableIntersectVisitor exitableIntersectVisitor; + private final QueryCancellation queryCancellation; + private int calls; + + private ExitablePointTree(PointValues values, PointValues.PointTree pointTree, QueryCancellation queryCancellation) { + this.values = values; + this.pointTree = pointTree; + this.exitableIntersectVisitor = new ExitableIntersectVisitor(queryCancellation); + this.queryCancellation = queryCancellation; + } + + @Override + public PointValues.PointTree clone() { + queryCancellation.checkCancelled(); + return new ExitablePointTree(values, pointTree.clone(), queryCancellation); + } + + @Override + public boolean moveToChild() throws IOException { + checkAndThrowWithSampling(); + return pointTree.moveToChild(); + } + + @Override + public boolean moveToSibling() throws IOException { + checkAndThrowWithSampling(); + return pointTree.moveToSibling(); + } + + @Override + public boolean moveToParent() throws IOException { + checkAndThrowWithSampling(); + return pointTree.moveToParent(); + } + + @Override + public byte[] getMinPackedValue() { + checkAndThrowWithSampling(); + return pointTree.getMinPackedValue(); + } + + @Override + public byte[] getMaxPackedValue() { + checkAndThrowWithSampling(); + return pointTree.getMaxPackedValue(); + } + + @Override + public long size() { + queryCancellation.checkCancelled(); + return pointTree.size(); + } + + @Override + public void visitDocIDs(PointValues.IntersectVisitor visitor) throws IOException { + queryCancellation.checkCancelled(); + pointTree.visitDocIDs(visitor); + } + + @Override + public void visitDocValues(PointValues.IntersectVisitor visitor) throws IOException { + queryCancellation.checkCancelled(); + exitableIntersectVisitor.setVisitor(visitor); + pointTree.visitDocValues(exitableIntersectVisitor); + } + + // reuse ExitableIntersectVisitor#checkAndThrowWithSampling + private void checkAndThrowWithSampling() { + if ((calls++ & ExitableIntersectVisitor.MAX_CALLS_BEFORE_QUERY_TIMEOUT_CHECK) == 0) { + queryCancellation.checkCancelled(); + } + } + } + /** * Wrapper class for {@link PointValues} that checks for query cancellation or timeout. */ @@ -211,15 +289,8 @@ private ExitablePointValues(PointValues in, QueryCancellation queryCancellation) } @Override - public void intersect(IntersectVisitor visitor) throws IOException { - queryCancellation.checkCancelled(); - in.intersect(new ExitableIntersectVisitor(visitor, queryCancellation)); - } - - @Override - public long estimatePointCount(IntersectVisitor visitor) { - queryCancellation.checkCancelled(); - return in.estimatePointCount(visitor); + public PointTree getPointTree() throws IOException { + return new ExitablePointTree(in, in.getPointTree(), queryCancellation); } @Override @@ -269,12 +340,11 @@ private static class ExitableIntersectVisitor implements PointValues.IntersectVi private static final int MAX_CALLS_BEFORE_QUERY_TIMEOUT_CHECK = (1 << 13) - 1; // 8191 - private final PointValues.IntersectVisitor in; + private PointValues.IntersectVisitor in; private final QueryCancellation queryCancellation; private int calls; - private ExitableIntersectVisitor(PointValues.IntersectVisitor in, QueryCancellation queryCancellation) { - this.in = in; + private ExitableIntersectVisitor(QueryCancellation queryCancellation) { this.queryCancellation = queryCancellation; } @@ -284,6 +354,10 @@ private void checkAndThrowWithSampling() { } } + private void setVisitor(PointValues.IntersectVisitor in) { + this.in = in; + } + @Override public void visit(int docID) throws IOException { checkAndThrowWithSampling(); diff --git a/server/src/main/java/org/opensearch/search/sort/GeoDistanceSortBuilder.java b/server/src/main/java/org/opensearch/search/sort/GeoDistanceSortBuilder.java index 2dd3481cc804f..2ab9703b45980 100644 --- a/server/src/main/java/org/opensearch/search/sort/GeoDistanceSortBuilder.java +++ b/server/src/main/java/org/opensearch/search/sort/GeoDistanceSortBuilder.java @@ -731,8 +731,8 @@ private NumericDoubleValues getNumericDoubleValues(LeafReaderContext context) th } @Override - public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) { - return new DoubleComparator(numHits, null, null, reversed, sortPos) { + public FieldComparator newComparator(String fieldname, int numHits, boolean enableSkipping, boolean reversed) { + return new DoubleComparator(numHits, null, null, reversed, enableSkipping) { @Override public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException { return new DoubleLeafComparator(context) { diff --git a/server/src/test/java/org/opensearch/action/admin/indices/TransportAnalyzeActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/TransportAnalyzeActionTests.java index 726a37a30c893..17cc539a5d561 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/TransportAnalyzeActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/TransportAnalyzeActionTests.java @@ -31,8 +31,8 @@ package org.opensearch.action.admin.indices; -import org.apache.lucene.analysis.MockTokenFilter; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockTokenFilter; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.util.automaton.Automata; import org.apache.lucene.util.automaton.CharacterRunAutomaton; diff --git a/server/src/test/java/org/opensearch/action/bulk/BulkShardRequestTests.java b/server/src/test/java/org/opensearch/action/bulk/BulkShardRequestTests.java index fb41fdf210f64..5aa4553133190 100644 --- a/server/src/test/java/org/opensearch/action/bulk/BulkShardRequestTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/BulkShardRequestTests.java @@ -36,7 +36,7 @@ import org.opensearch.index.shard.ShardId; import org.opensearch.test.OpenSearchTestCase; -import static org.apache.lucene.util.TestUtil.randomSimpleString; +import static org.apache.lucene.tests.util.TestUtil.randomSimpleString; public class BulkShardRequestTests extends OpenSearchTestCase { public void testToString() { diff --git a/server/src/test/java/org/opensearch/action/search/BottomSortValuesCollectorTests.java b/server/src/test/java/org/opensearch/action/search/BottomSortValuesCollectorTests.java index 060f5d2a44b63..67a151646c635 100644 --- a/server/src/test/java/org/opensearch/action/search/BottomSortValuesCollectorTests.java +++ b/server/src/test/java/org/opensearch/action/search/BottomSortValuesCollectorTests.java @@ -257,7 +257,7 @@ private Object[] newDateNanoArray(String... values) { private TopFieldDocs createTopDocs(SortField sortField, int totalHits, Object[] values) { FieldDoc[] fieldDocs = new FieldDoc[values.length]; - FieldComparator cmp = sortField.getComparator(1, 0); + FieldComparator cmp = sortField.getComparator(1, false); for (int i = 0; i < values.length; i++) { fieldDocs[i] = new FieldDoc(i, Float.NaN, new Object[] { values[i] }); } diff --git a/server/src/test/java/org/opensearch/action/search/DfsQueryPhaseTests.java b/server/src/test/java/org/opensearch/action/search/DfsQueryPhaseTests.java index e8c5fddb4bf75..d746e5639fcb1 100644 --- a/server/src/test/java/org/opensearch/action/search/DfsQueryPhaseTests.java +++ b/server/src/test/java/org/opensearch/action/search/DfsQueryPhaseTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.search.TermStatistics; import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.TotalHits; -import org.apache.lucene.store.MockDirectoryWrapper; +import org.apache.lucene.tests.store.MockDirectoryWrapper; import org.opensearch.action.OriginalIndices; import org.opensearch.common.breaker.CircuitBreaker; import org.opensearch.common.breaker.NoopCircuitBreaker; diff --git a/server/src/test/java/org/opensearch/action/search/FetchSearchPhaseTests.java b/server/src/test/java/org/opensearch/action/search/FetchSearchPhaseTests.java index ac68dc78e41df..6c77e5f6efd5d 100644 --- a/server/src/test/java/org/opensearch/action/search/FetchSearchPhaseTests.java +++ b/server/src/test/java/org/opensearch/action/search/FetchSearchPhaseTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.TotalHits; -import org.apache.lucene.store.MockDirectoryWrapper; +import org.apache.lucene.tests.store.MockDirectoryWrapper; import org.opensearch.action.OriginalIndices; import org.opensearch.common.UUIDs; import org.opensearch.common.breaker.CircuitBreaker; diff --git a/server/src/test/java/org/opensearch/action/termvectors/GetTermVectorsTests.java b/server/src/test/java/org/opensearch/action/termvectors/GetTermVectorsTests.java index b7cdb3301384a..5486d110c9329 100644 --- a/server/src/test/java/org/opensearch/action/termvectors/GetTermVectorsTests.java +++ b/server/src/test/java/org/opensearch/action/termvectors/GetTermVectorsTests.java @@ -31,7 +31,7 @@ package org.opensearch.action.termvectors; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenFilter; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.payloads.FloatEncoder; diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/BalanceUnbalancedClusterTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/BalanceUnbalancedClusterTests.java index e08431e5fc4ab..75961491f5cf0 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/BalanceUnbalancedClusterTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/BalanceUnbalancedClusterTests.java @@ -31,7 +31,7 @@ package org.opensearch.cluster.routing.allocation; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.Version; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.OpenSearchAllocationTestCase; diff --git a/server/src/test/java/org/opensearch/common/UUIDTests.java b/server/src/test/java/org/opensearch/common/UUIDTests.java index 4126c3aa30083..a71b68bfe859e 100644 --- a/server/src/test/java/org/opensearch/common/UUIDTests.java +++ b/server/src/test/java/org/opensearch/common/UUIDTests.java @@ -43,7 +43,7 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.SerialMergeScheduler; import org.apache.lucene.store.Directory; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.common.lucene.Lucene; import org.opensearch.common.unit.ByteSizeValue; import org.opensearch.common.unit.TimeValue; diff --git a/server/src/test/java/org/opensearch/common/blobstore/fs/FsBlobContainerTests.java b/server/src/test/java/org/opensearch/common/blobstore/fs/FsBlobContainerTests.java index 85ac19a6e518f..83f5c0445e21d 100644 --- a/server/src/test/java/org/opensearch/common/blobstore/fs/FsBlobContainerTests.java +++ b/server/src/test/java/org/opensearch/common/blobstore/fs/FsBlobContainerTests.java @@ -31,9 +31,9 @@ package org.opensearch.common.blobstore.fs; -import org.apache.lucene.mockfile.FilterFileSystemProvider; -import org.apache.lucene.mockfile.FilterSeekableByteChannel; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.mockfile.FilterFileSystemProvider; +import org.apache.lucene.tests.mockfile.FilterSeekableByteChannel; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.common.blobstore.BlobPath; import org.opensearch.common.io.PathUtils; import org.opensearch.common.io.PathUtilsForTesting; diff --git a/server/src/test/java/org/opensearch/common/compress/DeflateCompressTests.java b/server/src/test/java/org/opensearch/common/compress/DeflateCompressTests.java index a2b2227effb7b..f215817914ee0 100644 --- a/server/src/test/java/org/opensearch/common/compress/DeflateCompressTests.java +++ b/server/src/test/java/org/opensearch/common/compress/DeflateCompressTests.java @@ -32,8 +32,8 @@ package org.opensearch.common.compress; -import org.apache.lucene.util.LineFileDocs; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.LineFileDocs; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.test.OpenSearchTestCase; import java.io.ByteArrayInputStream; diff --git a/server/src/test/java/org/opensearch/common/compress/DeflateCompressedXContentTests.java b/server/src/test/java/org/opensearch/common/compress/DeflateCompressedXContentTests.java index 24ea9e30ecdfb..a14fabc30050d 100644 --- a/server/src/test/java/org/opensearch/common/compress/DeflateCompressedXContentTests.java +++ b/server/src/test/java/org/opensearch/common/compress/DeflateCompressedXContentTests.java @@ -32,7 +32,7 @@ package org.opensearch.common.compress; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/common/geo/GeoWKTShapeParserTests.java b/server/src/test/java/org/opensearch/common/geo/GeoWKTShapeParserTests.java index d8a1bcb97d678..cd05331442be2 100644 --- a/server/src/test/java/org/opensearch/common/geo/GeoWKTShapeParserTests.java +++ b/server/src/test/java/org/opensearch/common/geo/GeoWKTShapeParserTests.java @@ -31,7 +31,7 @@ package org.opensearch.common.geo; -import org.apache.lucene.geo.GeoTestUtil; +import org.apache.lucene.tests.geo.GeoTestUtil; import org.opensearch.OpenSearchException; import org.opensearch.OpenSearchParseException; import org.opensearch.Version; diff --git a/server/src/test/java/org/opensearch/common/io/FileSystemUtilsTests.java b/server/src/test/java/org/opensearch/common/io/FileSystemUtilsTests.java index 406ea1ea56c5b..bb0a1c486a30c 100644 --- a/server/src/test/java/org/opensearch/common/io/FileSystemUtilsTests.java +++ b/server/src/test/java/org/opensearch/common/io/FileSystemUtilsTests.java @@ -33,7 +33,7 @@ package org.opensearch.common.io; import org.apache.lucene.util.Constants; -import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems; +import org.apache.lucene.tests.util.LuceneTestCase.SuppressFileSystems; import org.opensearch.test.OpenSearchTestCase; import org.junit.Before; diff --git a/server/src/test/java/org/opensearch/common/lucene/LuceneTests.java b/server/src/test/java/org/opensearch/common/lucene/LuceneTests.java index 69c431994ba7e..4c179309f16ba 100644 --- a/server/src/test/java/org/opensearch/common/lucene/LuceneTests.java +++ b/server/src/test/java/org/opensearch/common/lucene/LuceneTests.java @@ -31,7 +31,7 @@ package org.opensearch.common.lucene; -import org.apache.lucene.analysis.MockAnalyzer; +import org.apache.lucene.tests.analysis.MockAnalyzer; import org.apache.lucene.analysis.core.KeywordAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -47,7 +47,7 @@ import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.NoDeletionPolicy; import org.apache.lucene.index.NoMergePolicy; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.SegmentInfos; import org.apache.lucene.index.SoftDeletesRetentionMergePolicy; import org.apache.lucene.index.Term; @@ -70,7 +70,7 @@ import org.apache.lucene.search.Weight; import org.apache.lucene.store.Directory; import org.apache.lucene.store.MMapDirectory; -import org.apache.lucene.store.MockDirectoryWrapper; +import org.apache.lucene.tests.store.MockDirectoryWrapper; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; import org.opensearch.common.collect.Tuple; diff --git a/server/src/test/java/org/opensearch/common/lucene/ShardCoreKeyMapTests.java b/server/src/test/java/org/opensearch/common/lucene/ShardCoreKeyMapTests.java index e133e341b475d..8abfb14fe3087 100644 --- a/server/src/test/java/org/opensearch/common/lucene/ShardCoreKeyMapTests.java +++ b/server/src/test/java/org/opensearch/common/lucene/ShardCoreKeyMapTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.Directory; import org.opensearch.common.lucene.index.OpenSearchDirectoryReader; diff --git a/server/src/test/java/org/opensearch/common/lucene/search/function/MinScoreScorerTests.java b/server/src/test/java/org/opensearch/common/lucene/search/function/MinScoreScorerTests.java index 26674189f3cd8..8de2a54a3df37 100644 --- a/server/src/test/java/org/opensearch/common/lucene/search/function/MinScoreScorerTests.java +++ b/server/src/test/java/org/opensearch/common/lucene/search/function/MinScoreScorerTests.java @@ -39,8 +39,8 @@ import org.apache.lucene.search.Scorer; import org.apache.lucene.search.TwoPhaseIterator; import org.apache.lucene.search.Weight; -import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.LuceneTestCase; +import org.apache.lucene.tests.util.TestUtil; import java.io.IOException; import java.util.Arrays; diff --git a/server/src/test/java/org/opensearch/common/lucene/search/morelikethis/XMoreLikeThisTests.java b/server/src/test/java/org/opensearch/common/lucene/search/morelikethis/XMoreLikeThisTests.java index ad60895505214..e6a621037ef6d 100644 --- a/server/src/test/java/org/opensearch/common/lucene/search/morelikethis/XMoreLikeThisTests.java +++ b/server/src/test/java/org/opensearch/common/lucene/search/morelikethis/XMoreLikeThisTests.java @@ -32,12 +32,12 @@ package org.opensearch.common.lucene.search.morelikethis; -import org.apache.lucene.analysis.MockAnalyzer; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockAnalyzer; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.queries.mlt.MoreLikeThis; import org.apache.lucene.search.BooleanClause; diff --git a/server/src/test/java/org/opensearch/common/util/BytesRefHashTests.java b/server/src/test/java/org/opensearch/common/util/BytesRefHashTests.java index 4107d1a24e6fc..1859a7d4a8f9d 100644 --- a/server/src/test/java/org/opensearch/common/util/BytesRefHashTests.java +++ b/server/src/test/java/org/opensearch/common/util/BytesRefHashTests.java @@ -37,7 +37,7 @@ import com.carrotsearch.hppc.cursors.ObjectLongCursor; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRefBuilder; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.common.settings.Settings; import org.opensearch.indices.breaker.NoneCircuitBreakerService; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/env/NodeEnvironmentTests.java b/server/src/test/java/org/opensearch/env/NodeEnvironmentTests.java index 011b5c8ea0e4e..e6f0f2824b7d3 100644 --- a/server/src/test/java/org/opensearch/env/NodeEnvironmentTests.java +++ b/server/src/test/java/org/opensearch/env/NodeEnvironmentTests.java @@ -32,7 +32,7 @@ package org.opensearch.env; import org.apache.lucene.index.SegmentInfos; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.cluster.node.DiscoveryNodeRole; import org.opensearch.common.SuppressForbidden; import org.opensearch.common.io.PathUtils; diff --git a/server/src/test/java/org/opensearch/gateway/GatewayMetaStatePersistedStateTests.java b/server/src/test/java/org/opensearch/gateway/GatewayMetaStatePersistedStateTests.java index 23977877773f0..4ab5d7c44f356 100644 --- a/server/src/test/java/org/opensearch/gateway/GatewayMetaStatePersistedStateTests.java +++ b/server/src/test/java/org/opensearch/gateway/GatewayMetaStatePersistedStateTests.java @@ -33,7 +33,7 @@ package org.opensearch.gateway; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.MockDirectoryWrapper; +import org.apache.lucene.tests.store.MockDirectoryWrapper; import org.opensearch.ExceptionsHelper; import org.opensearch.Version; import org.opensearch.cluster.ClusterName; diff --git a/server/src/test/java/org/opensearch/gateway/IncrementalClusterStateWriterTests.java b/server/src/test/java/org/opensearch/gateway/IncrementalClusterStateWriterTests.java index 31ec7c7f2ffe3..21d5c897c4a7d 100644 --- a/server/src/test/java/org/opensearch/gateway/IncrementalClusterStateWriterTests.java +++ b/server/src/test/java/org/opensearch/gateway/IncrementalClusterStateWriterTests.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.MockDirectoryWrapper; +import org.apache.lucene.tests.store.MockDirectoryWrapper; import org.opensearch.Version; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.ClusterState; diff --git a/server/src/test/java/org/opensearch/gateway/MetadataStateFormatTests.java b/server/src/test/java/org/opensearch/gateway/MetadataStateFormatTests.java index 70e1e8d73ef3a..fe7b1255cf716 100644 --- a/server/src/test/java/org/opensearch/gateway/MetadataStateFormatTests.java +++ b/server/src/test/java/org/opensearch/gateway/MetadataStateFormatTests.java @@ -37,9 +37,9 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; -import org.apache.lucene.store.MockDirectoryWrapper; +import org.apache.lucene.tests.store.MockDirectoryWrapper; import org.apache.lucene.store.NIOFSDirectory; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.cluster.ClusterModule; import org.opensearch.cluster.metadata.Metadata; import org.opensearch.common.xcontent.NamedXContentRegistry; diff --git a/server/src/test/java/org/opensearch/index/IndexModuleTests.java b/server/src/test/java/org/opensearch/index/IndexModuleTests.java index 3be0304381810..daa9186dfd8c0 100644 --- a/server/src/test/java/org/opensearch/index/IndexModuleTests.java +++ b/server/src/test/java/org/opensearch/index/IndexModuleTests.java @@ -33,7 +33,7 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardTokenizer; -import org.apache.lucene.index.AssertingDirectoryReader; +import org.apache.lucene.tests.index.AssertingDirectoryReader; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.FieldInvertState; import org.apache.lucene.index.Term; diff --git a/server/src/test/java/org/opensearch/index/IndexTests.java b/server/src/test/java/org/opensearch/index/IndexTests.java index f611537bb06fe..ed845e27bfb2f 100644 --- a/server/src/test/java/org/opensearch/index/IndexTests.java +++ b/server/src/test/java/org/opensearch/index/IndexTests.java @@ -43,7 +43,7 @@ import java.io.IOException; -import static org.apache.lucene.util.TestUtil.randomSimpleString; +import static org.apache.lucene.tests.util.TestUtil.randomSimpleString; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; diff --git a/server/src/test/java/org/opensearch/index/analysis/AnalysisRegistryTests.java b/server/src/test/java/org/opensearch/index/analysis/AnalysisRegistryTests.java index b3be1995352a0..cbc189be491cd 100644 --- a/server/src/test/java/org/opensearch/index/analysis/AnalysisRegistryTests.java +++ b/server/src/test/java/org/opensearch/index/analysis/AnalysisRegistryTests.java @@ -34,7 +34,7 @@ import com.carrotsearch.randomizedtesting.generators.RandomPicks; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.MockTokenFilter; +import org.apache.lucene.tests.analysis.MockTokenFilter; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.en.EnglishAnalyzer; diff --git a/server/src/test/java/org/opensearch/index/analysis/CustomNormalizerTests.java b/server/src/test/java/org/opensearch/index/analysis/CustomNormalizerTests.java index f9da31fab962b..d610dfab12f46 100644 --- a/server/src/test/java/org/opensearch/index/analysis/CustomNormalizerTests.java +++ b/server/src/test/java/org/opensearch/index/analysis/CustomNormalizerTests.java @@ -32,8 +32,8 @@ package org.opensearch.index.analysis; -import org.apache.lucene.analysis.MockLowerCaseFilter; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockLowerCaseFilter; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.util.BytesRef; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; diff --git a/server/src/test/java/org/opensearch/index/codec/CodecTests.java b/server/src/test/java/org/opensearch/index/codec/CodecTests.java index 66de4d03ebbbf..94b78da402b44 100644 --- a/server/src/test/java/org/opensearch/index/codec/CodecTests.java +++ b/server/src/test/java/org/opensearch/index/codec/CodecTests.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.lucene.codecs.Codec; -import org.apache.lucene.codecs.lucene90.Lucene90Codec; +import org.apache.lucene.codecs.lucene91.Lucene91Codec; import org.apache.lucene.codecs.lucene90.Lucene90StoredFieldsFormat; import org.apache.lucene.document.Document; import org.apache.lucene.index.DirectoryReader; @@ -42,7 +42,7 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.SegmentReader; import org.apache.lucene.store.Directory; -import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; +import org.apache.lucene.tests.util.LuceneTestCase.SuppressCodecs; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; import org.opensearch.index.IndexSettings; @@ -65,21 +65,21 @@ public class CodecTests extends OpenSearchTestCase { public void testResolveDefaultCodecs() throws Exception { CodecService codecService = createCodecService(); assertThat(codecService.codec("default"), instanceOf(PerFieldMappingPostingFormatCodec.class)); - assertThat(codecService.codec("default"), instanceOf(Lucene90Codec.class)); + assertThat(codecService.codec("default"), instanceOf(Lucene91Codec.class)); } public void testDefault() throws Exception { Codec codec = createCodecService().codec("default"); - assertStoredFieldsCompressionEquals(Lucene90Codec.Mode.BEST_SPEED, codec); + assertStoredFieldsCompressionEquals(Lucene91Codec.Mode.BEST_SPEED, codec); } public void testBestCompression() throws Exception { Codec codec = createCodecService().codec("best_compression"); - assertStoredFieldsCompressionEquals(Lucene90Codec.Mode.BEST_COMPRESSION, codec); + assertStoredFieldsCompressionEquals(Lucene91Codec.Mode.BEST_COMPRESSION, codec); } // write some docs with it, inspect .si to see this was the used compression - private void assertStoredFieldsCompressionEquals(Lucene90Codec.Mode expected, Codec actual) throws Exception { + private void assertStoredFieldsCompressionEquals(Lucene91Codec.Mode expected, Codec actual) throws Exception { Directory dir = newDirectory(); IndexWriterConfig iwc = newIndexWriterConfig(null); iwc.setCodec(actual); @@ -91,7 +91,7 @@ private void assertStoredFieldsCompressionEquals(Lucene90Codec.Mode expected, Co SegmentReader sr = (SegmentReader) ir.leaves().get(0).reader(); String v = sr.getSegmentInfo().info.getAttribute(Lucene90StoredFieldsFormat.MODE_KEY); assertNotNull(v); - assertEquals(expected, Lucene90Codec.Mode.valueOf(v)); + assertEquals(expected, Lucene91Codec.Mode.valueOf(v)); ir.close(); dir.close(); } diff --git a/server/src/test/java/org/opensearch/index/engine/CompletionStatsCacheTests.java b/server/src/test/java/org/opensearch/index/engine/CompletionStatsCacheTests.java index 30285b1a3a014..66b066b907100 100644 --- a/server/src/test/java/org/opensearch/index/engine/CompletionStatsCacheTests.java +++ b/server/src/test/java/org/opensearch/index/engine/CompletionStatsCacheTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.engine; import org.apache.lucene.codecs.PostingsFormat; -import org.apache.lucene.codecs.lucene90.Lucene90Codec; +import org.apache.lucene.codecs.lucene91.Lucene91Codec; import org.apache.lucene.document.Document; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexWriter; @@ -70,7 +70,7 @@ public void testExceptionsAreNotCached() { public void testCompletionStatsCache() throws IOException, InterruptedException { final IndexWriterConfig indexWriterConfig = newIndexWriterConfig(); final PostingsFormat postingsFormat = new Completion90PostingsFormat(); - indexWriterConfig.setCodec(new Lucene90Codec() { + indexWriterConfig.setCodec(new Lucene91Codec() { @Override public PostingsFormat getPostingsFormatForField(String field) { return postingsFormat; // all fields are suggest fields diff --git a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java index 5202e04990f95..361013149578e 100644 --- a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java @@ -50,7 +50,6 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.index.IndexWriterMaxDocsChanger; import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReaderContext; @@ -77,7 +76,7 @@ import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.Directory; import org.apache.lucene.store.Lock; -import org.apache.lucene.store.MockDirectoryWrapper; +import org.apache.lucene.tests.store.MockDirectoryWrapper; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.FixedBitSet; @@ -7121,7 +7120,7 @@ public void testProducesStoredFieldsReader() throws Exception { public void testMaxDocsOnPrimary() throws Exception { engine.close(); int maxDocs = randomIntBetween(1, 100); - IndexWriterMaxDocsChanger.setMaxDocs(maxDocs); + setIndexWriterMaxDocs(maxDocs); try { engine = new InternalTestEngine(engine.config(), maxDocs, LocalCheckpointTracker::new); int numDocs = between(maxDocs + 1, maxDocs * 2); @@ -7156,14 +7155,14 @@ public void testMaxDocsOnPrimary() throws Exception { assertFalse(engine.isClosed.get()); } } finally { - IndexWriterMaxDocsChanger.restoreMaxDocs(); + restoreIndexWriterMaxDocs(); } } public void testMaxDocsOnReplica() throws Exception { engine.close(); int maxDocs = randomIntBetween(1, 100); - IndexWriterMaxDocsChanger.setMaxDocs(maxDocs); + setIndexWriterMaxDocs(maxDocs); try { engine = new InternalTestEngine(engine.config(), maxDocs, LocalCheckpointTracker::new); int numDocs = between(maxDocs + 1, maxDocs * 2); @@ -7176,7 +7175,7 @@ public void testMaxDocsOnReplica() throws Exception { assertThat(error.getMessage(), containsString("number of documents in the index cannot exceed " + maxDocs)); assertTrue(engine.isClosed.get()); } finally { - IndexWriterMaxDocsChanger.restoreMaxDocs(); + restoreIndexWriterMaxDocs(); } } } diff --git a/server/src/test/java/org/opensearch/index/engine/LiveVersionMapTests.java b/server/src/test/java/org/opensearch/index/engine/LiveVersionMapTests.java index f9c6c065904d7..b1e033232420b 100644 --- a/server/src/test/java/org/opensearch/index/engine/LiveVersionMapTests.java +++ b/server/src/test/java/org/opensearch/index/engine/LiveVersionMapTests.java @@ -35,8 +35,8 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRefBuilder; import org.apache.lucene.util.Constants; -import org.apache.lucene.util.RamUsageTester; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.RamUsageTester; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.common.lease.Releasable; import org.opensearch.index.translog.Translog; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/index/engine/ReadOnlyEngineTests.java b/server/src/test/java/org/opensearch/index/engine/ReadOnlyEngineTests.java index 95a2db9d74c38..2106c5e1067fb 100644 --- a/server/src/test/java/org/opensearch/index/engine/ReadOnlyEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/ReadOnlyEngineTests.java @@ -33,7 +33,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.Version; import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.lucene.index.OpenSearchDirectoryReader; diff --git a/server/src/test/java/org/opensearch/index/engine/RecoverySourcePruneMergePolicyTests.java b/server/src/test/java/org/opensearch/index/engine/RecoverySourcePruneMergePolicyTests.java index 4587b022f0483..a8279ed908779 100644 --- a/server/src/test/java/org/opensearch/index/engine/RecoverySourcePruneMergePolicyTests.java +++ b/server/src/test/java/org/opensearch/index/engine/RecoverySourcePruneMergePolicyTests.java @@ -56,7 +56,7 @@ import org.apache.lucene.search.TermQuery; import org.apache.lucene.store.Directory; import org.apache.lucene.util.InfoStream; -import org.apache.lucene.util.NullInfoStream; +import org.apache.lucene.tests.util.NullInfoStream; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; diff --git a/server/src/test/java/org/opensearch/index/engine/VersionValueTests.java b/server/src/test/java/org/opensearch/index/engine/VersionValueTests.java index dc6511b9e2632..81e0ff19c0070 100644 --- a/server/src/test/java/org/opensearch/index/engine/VersionValueTests.java +++ b/server/src/test/java/org/opensearch/index/engine/VersionValueTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.engine; -import org.apache.lucene.util.RamUsageTester; +import org.apache.lucene.tests.util.RamUsageTester; import org.opensearch.index.translog.Translog; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/index/fielddata/AbstractStringFieldDataTestCase.java b/server/src/test/java/org/opensearch/index/fielddata/AbstractStringFieldDataTestCase.java index 33813580468aa..763ee59a385a2 100644 --- a/server/src/test/java/org/opensearch/index/fielddata/AbstractStringFieldDataTestCase.java +++ b/server/src/test/java/org/opensearch/index/fielddata/AbstractStringFieldDataTestCase.java @@ -58,7 +58,7 @@ import org.apache.lucene.util.Accountable; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.FixedBitSet; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.apache.lucene.util.UnicodeUtil; import org.opensearch.common.lucene.index.OpenSearchDirectoryReader; import org.opensearch.common.lucene.search.Queries; diff --git a/server/src/test/java/org/opensearch/index/fielddata/plain/HalfFloatFielddataTests.java b/server/src/test/java/org/opensearch/index/fielddata/plain/HalfFloatFielddataTests.java index 60bd5a32f0fbf..be631cc311b2a 100644 --- a/server/src/test/java/org/opensearch/index/fielddata/plain/HalfFloatFielddataTests.java +++ b/server/src/test/java/org/opensearch/index/fielddata/plain/HalfFloatFielddataTests.java @@ -40,7 +40,7 @@ import org.apache.lucene.index.LeafReader; import org.apache.lucene.store.Directory; import org.opensearch.core.internal.io.IOUtils; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.index.fielddata.FieldData; import org.opensearch.index.fielddata.SortedNumericDoubleValues; import org.opensearch.index.mapper.NumberFieldMapper; diff --git a/server/src/test/java/org/opensearch/index/mapper/DocumentFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/DocumentFieldMapperTests.java index 3d2b8c4457c17..c74b5745cd83f 100644 --- a/server/src/test/java/org/opensearch/index/mapper/DocumentFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/DocumentFieldMapperTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.index.analysis.AnalyzerScope; import org.opensearch.index.analysis.NamedAnalyzer; import org.opensearch.index.query.QueryShardContext; diff --git a/server/src/test/java/org/opensearch/index/mapper/KeywordFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/KeywordFieldMapperTests.java index 9c2ca84859d66..7059e908c078f 100644 --- a/server/src/test/java/org/opensearch/index/mapper/KeywordFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/KeywordFieldMapperTests.java @@ -33,8 +33,8 @@ package org.opensearch.index.mapper; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.MockLowerCaseFilter; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockLowerCaseFilter; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.core.LowerCaseFilter; import org.apache.lucene.analysis.core.WhitespaceTokenizer; @@ -69,7 +69,7 @@ import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; -import static org.apache.lucene.analysis.BaseTokenStreamTestCase.assertTokenStreamContents; +import static org.apache.lucene.tests.analysis.BaseTokenStreamTestCase.assertTokenStreamContents; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; diff --git a/server/src/test/java/org/opensearch/index/mapper/NumberFieldTypeTests.java b/server/src/test/java/org/opensearch/index/mapper/NumberFieldTypeTests.java index 57f3f3693257b..3b6d757c81b83 100644 --- a/server/src/test/java/org/opensearch/index/mapper/NumberFieldTypeTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/NumberFieldTypeTests.java @@ -52,7 +52,7 @@ import org.apache.lucene.search.SortField; import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; diff --git a/server/src/test/java/org/opensearch/index/mapper/TextFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/TextFieldMapperTests.java index 2db5f2eea3596..8a5a0e8864d3e 100644 --- a/server/src/test/java/org/opensearch/index/mapper/TextFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/TextFieldMapperTests.java @@ -33,10 +33,10 @@ package org.opensearch.index.mapper; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.CannedTokenStream; -import org.apache.lucene.analysis.MockSynonymAnalyzer; +import org.apache.lucene.tests.analysis.CannedTokenStream; +import org.apache.lucene.tests.analysis.MockSynonymAnalyzer; import org.apache.lucene.analysis.StopFilter; -import org.apache.lucene.analysis.Token; +import org.apache.lucene.tests.analysis.Token; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.core.KeywordAnalyzer; import org.apache.lucene.analysis.core.WhitespaceAnalyzer; diff --git a/server/src/test/java/org/opensearch/index/mapper/UidTests.java b/server/src/test/java/org/opensearch/index/mapper/UidTests.java index 34e7682474f56..a7253d9a6a7c4 100644 --- a/server/src/test/java/org/opensearch/index/mapper/UidTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/UidTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.mapper; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.test.OpenSearchTestCase; import java.util.Arrays; diff --git a/server/src/test/java/org/opensearch/index/query/IntervalBuilderTests.java b/server/src/test/java/org/opensearch/index/query/IntervalBuilderTests.java index 9cb8108818705..b31bcc10a28cc 100644 --- a/server/src/test/java/org/opensearch/index/query/IntervalBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/IntervalBuilderTests.java @@ -33,8 +33,8 @@ package org.opensearch.index.query; import org.apache.lucene.analysis.CachingTokenFilter; -import org.apache.lucene.analysis.CannedTokenStream; -import org.apache.lucene.analysis.Token; +import org.apache.lucene.tests.analysis.CannedTokenStream; +import org.apache.lucene.tests.analysis.Token; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.queries.intervals.Intervals; import org.apache.lucene.queries.intervals.IntervalsSource; diff --git a/server/src/test/java/org/opensearch/index/query/MatchBoolPrefixQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/MatchBoolPrefixQueryBuilderTests.java index 9ae95fd941a59..8a6b09b1ea925 100644 --- a/server/src/test/java/org/opensearch/index/query/MatchBoolPrefixQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/MatchBoolPrefixQueryBuilderTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.query; -import org.apache.lucene.analysis.MockSynonymAnalyzer; +import org.apache.lucene.tests.analysis.MockSynonymAnalyzer; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; diff --git a/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java index 354e932f6b9f9..dac32849e3cef 100644 --- a/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java @@ -33,8 +33,8 @@ package org.opensearch.index.query; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.CannedBinaryTokenStream; -import org.apache.lucene.analysis.MockSynonymAnalyzer; +import org.apache.lucene.tests.analysis.CannedBinaryTokenStream; +import org.apache.lucene.tests.analysis.MockSynonymAnalyzer; import org.apache.lucene.index.Term; import org.apache.lucene.queries.ExtendedCommonTermsQuery; import org.apache.lucene.queries.spans.SpanNearQuery; diff --git a/server/src/test/java/org/opensearch/index/query/QueryShardContextTests.java b/server/src/test/java/org/opensearch/index/query/QueryShardContextTests.java index b803e7b5686dc..2f8ab12a2f3e3 100644 --- a/server/src/test/java/org/opensearch/index/query/QueryShardContextTests.java +++ b/server/src/test/java/org/opensearch/index/query/QueryShardContextTests.java @@ -35,7 +35,7 @@ import org.apache.lucene.document.StringField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.Collector; import org.apache.lucene.search.IndexSearcher; diff --git a/server/src/test/java/org/opensearch/index/query/QueryStringQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/QueryStringQueryBuilderTests.java index d08f2ef170bf2..b091fc2103344 100644 --- a/server/src/test/java/org/opensearch/index/query/QueryStringQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/QueryStringQueryBuilderTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.query; -import org.apache.lucene.analysis.MockSynonymAnalyzer; +import org.apache.lucene.tests.analysis.MockSynonymAnalyzer; import org.apache.lucene.document.LongPoint; import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.Term; diff --git a/server/src/test/java/org/opensearch/index/query/SimpleQueryStringBuilderTests.java b/server/src/test/java/org/opensearch/index/query/SimpleQueryStringBuilderTests.java index b11e0cab76340..1101da8de70fe 100644 --- a/server/src/test/java/org/opensearch/index/query/SimpleQueryStringBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/SimpleQueryStringBuilderTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.query; -import org.apache.lucene.analysis.MockSynonymAnalyzer; +import org.apache.lucene.tests.analysis.MockSynonymAnalyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.index.Term; import org.apache.lucene.queries.spans.SpanNearQuery; @@ -50,7 +50,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.SynonymQuery; import org.apache.lucene.search.TermQuery; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; import org.opensearch.index.search.SimpleQueryStringQueryParser; diff --git a/server/src/test/java/org/opensearch/index/query/SpanMultiTermQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/SpanMultiTermQueryBuilderTests.java index 011d05aef1214..50f51f9ff68d1 100644 --- a/server/src/test/java/org/opensearch/index/query/SpanMultiTermQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/SpanMultiTermQueryBuilderTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.Field; import org.apache.lucene.document.TextField; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.queries.SpanMatchNoDocsQuery; import org.apache.lucene.queries.spans.FieldMaskingSpanQuery; diff --git a/server/src/test/java/org/opensearch/index/query/functionscore/FunctionScoreEquivalenceTests.java b/server/src/test/java/org/opensearch/index/query/functionscore/FunctionScoreEquivalenceTests.java index 3db870941992a..a78cccbbc8083 100644 --- a/server/src/test/java/org/opensearch/index/query/functionscore/FunctionScoreEquivalenceTests.java +++ b/server/src/test/java/org/opensearch/index/query/functionscore/FunctionScoreEquivalenceTests.java @@ -34,8 +34,8 @@ import org.apache.lucene.index.Term; import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; -import org.apache.lucene.search.RandomApproximationQuery; -import org.apache.lucene.search.SearchEquivalenceTestBase; +import org.apache.lucene.tests.search.RandomApproximationQuery; +import org.apache.lucene.tests.search.SearchEquivalenceTestBase; import org.apache.lucene.search.TermQuery; import org.opensearch.bootstrap.BootstrapForTesting; import org.opensearch.common.lucene.search.function.FunctionScoreQuery; diff --git a/server/src/test/java/org/opensearch/index/query/functionscore/FunctionScoreTests.java b/server/src/test/java/org/opensearch/index/query/functionscore/FunctionScoreTests.java index 2bfcec1bf786c..3bcda9f5e762f 100644 --- a/server/src/test/java/org/opensearch/index/query/functionscore/FunctionScoreTests.java +++ b/server/src/test/java/org/opensearch/index/query/functionscore/FunctionScoreTests.java @@ -45,7 +45,7 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; -import org.apache.lucene.search.RandomApproximationQuery; +import org.apache.lucene.tests.search.RandomApproximationQuery; import org.apache.lucene.search.Scorer; import org.apache.lucene.search.SortField; import org.apache.lucene.search.TermQuery; diff --git a/server/src/test/java/org/opensearch/index/reindex/BulkByScrollResponseTests.java b/server/src/test/java/org/opensearch/index/reindex/BulkByScrollResponseTests.java index 6ee3f3c0bced4..f9101ee8a50c1 100644 --- a/server/src/test/java/org/opensearch/index/reindex/BulkByScrollResponseTests.java +++ b/server/src/test/java/org/opensearch/index/reindex/BulkByScrollResponseTests.java @@ -51,7 +51,7 @@ import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; -import static org.apache.lucene.util.TestUtil.randomSimpleString; +import static org.apache.lucene.tests.util.TestUtil.randomSimpleString; import static org.opensearch.common.unit.TimeValue.timeValueMillis; public class BulkByScrollResponseTests extends AbstractXContentTestCase { diff --git a/server/src/test/java/org/opensearch/index/reindex/BulkByScrollTaskStatusTests.java b/server/src/test/java/org/opensearch/index/reindex/BulkByScrollTaskStatusTests.java index 3921417d42cf0..bd8acb8bc18b7 100644 --- a/server/src/test/java/org/opensearch/index/reindex/BulkByScrollTaskStatusTests.java +++ b/server/src/test/java/org/opensearch/index/reindex/BulkByScrollTaskStatusTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.reindex; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.OpenSearchException; import org.opensearch.Version; import org.opensearch.common.Randomness; @@ -55,7 +55,7 @@ import static java.lang.Math.abs; import static java.util.stream.Collectors.toList; -import static org.apache.lucene.util.TestUtil.randomSimpleString; +import static org.apache.lucene.tests.util.TestUtil.randomSimpleString; import static org.hamcrest.Matchers.equalTo; public class BulkByScrollTaskStatusTests extends AbstractXContentTestCase { diff --git a/server/src/test/java/org/opensearch/index/reindex/DeleteByQueryRequestTests.java b/server/src/test/java/org/opensearch/index/reindex/DeleteByQueryRequestTests.java index 3ff4b3ec26231..747ce00134adc 100644 --- a/server/src/test/java/org/opensearch/index/reindex/DeleteByQueryRequestTests.java +++ b/server/src/test/java/org/opensearch/index/reindex/DeleteByQueryRequestTests.java @@ -40,7 +40,7 @@ import java.io.IOException; -import static org.apache.lucene.util.TestUtil.randomSimpleString; +import static org.apache.lucene.tests.util.TestUtil.randomSimpleString; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; diff --git a/server/src/test/java/org/opensearch/index/reindex/UpdateByQueryRequestTests.java b/server/src/test/java/org/opensearch/index/reindex/UpdateByQueryRequestTests.java index 57a1135eaf9be..4cdb94897d4dc 100644 --- a/server/src/test/java/org/opensearch/index/reindex/UpdateByQueryRequestTests.java +++ b/server/src/test/java/org/opensearch/index/reindex/UpdateByQueryRequestTests.java @@ -37,7 +37,7 @@ import java.io.IOException; -import static org.apache.lucene.util.TestUtil.randomSimpleString; +import static org.apache.lucene.tests.util.TestUtil.randomSimpleString; public class UpdateByQueryRequestTests extends AbstractBulkByScrollRequestTestCase { public void testUpdateByQueryRequestImplementsIndicesRequestReplaceable() { diff --git a/server/src/test/java/org/opensearch/index/search/MultiMatchQueryTests.java b/server/src/test/java/org/opensearch/index/search/MultiMatchQueryTests.java index a7f765fee23da..f0a70b55e0fdd 100644 --- a/server/src/test/java/org/opensearch/index/search/MultiMatchQueryTests.java +++ b/server/src/test/java/org/opensearch/index/search/MultiMatchQueryTests.java @@ -32,7 +32,7 @@ package org.opensearch.index.search; -import org.apache.lucene.analysis.MockSynonymAnalyzer; +import org.apache.lucene.tests.analysis.MockSynonymAnalyzer; import org.apache.lucene.index.Term; import org.apache.lucene.queries.BlendedTermQuery; import org.apache.lucene.search.BooleanClause; diff --git a/server/src/test/java/org/opensearch/index/search/nested/NestedSortingTests.java b/server/src/test/java/org/opensearch/index/search/nested/NestedSortingTests.java index ee0b99bdc102c..a8cd6c5411875 100644 --- a/server/src/test/java/org/opensearch/index/search/nested/NestedSortingTests.java +++ b/server/src/test/java/org/opensearch/index/search/nested/NestedSortingTests.java @@ -56,7 +56,7 @@ import org.apache.lucene.search.join.ScoreMode; import org.apache.lucene.search.join.ToParentBlockJoinQuery; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.common.lucene.index.OpenSearchDirectoryReader; import org.opensearch.common.lucene.search.Queries; import org.opensearch.common.settings.Settings; diff --git a/server/src/test/java/org/opensearch/index/shard/IndexReaderWrapperTests.java b/server/src/test/java/org/opensearch/index/shard/IndexReaderWrapperTests.java index f2d8e96d63605..6b58633d5cd2e 100644 --- a/server/src/test/java/org/opensearch/index/shard/IndexReaderWrapperTests.java +++ b/server/src/test/java/org/opensearch/index/shard/IndexReaderWrapperTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.StringField; import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; -import org.apache.lucene.index.FieldFilterLeafReader; +import org.apache.lucene.tests.index.FieldFilterLeafReader; import org.apache.lucene.index.FilterDirectoryReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; diff --git a/server/src/test/java/org/opensearch/index/shard/NewPathForShardTests.java b/server/src/test/java/org/opensearch/index/shard/NewPathForShardTests.java index b3c69d27bc9a5..0d2a27aa0714e 100644 --- a/server/src/test/java/org/opensearch/index/shard/NewPathForShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/NewPathForShardTests.java @@ -31,7 +31,7 @@ package org.opensearch.index.shard; -import org.apache.lucene.mockfile.FilterFileSystemProvider; +import org.apache.lucene.tests.mockfile.FilterFileSystemProvider; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.io.PathUtils; import org.opensearch.common.io.PathUtilsForTesting; diff --git a/server/src/test/java/org/opensearch/index/shard/RemoveCorruptedShardDataCommandTests.java b/server/src/test/java/org/opensearch/index/shard/RemoveCorruptedShardDataCommandTests.java index 1b8809ba04278..9a2a0dd7e070c 100644 --- a/server/src/test/java/org/opensearch/index/shard/RemoveCorruptedShardDataCommandTests.java +++ b/server/src/test/java/org/opensearch/index/shard/RemoveCorruptedShardDataCommandTests.java @@ -33,7 +33,7 @@ import joptsimple.OptionParser; import joptsimple.OptionSet; -import org.apache.lucene.store.BaseDirectoryWrapper; +import org.apache.lucene.tests.store.BaseDirectoryWrapper; import org.opensearch.OpenSearchException; import org.opensearch.Version; import org.opensearch.cli.MockTerminal; diff --git a/server/src/test/java/org/opensearch/index/shard/ShardSplittingQueryTests.java b/server/src/test/java/org/opensearch/index/shard/ShardSplittingQueryTests.java index 4a5fa82a2f36b..b39ff0c9b97b3 100644 --- a/server/src/test/java/org/opensearch/index/shard/ShardSplittingQueryTests.java +++ b/server/src/test/java/org/opensearch/index/shard/ShardSplittingQueryTests.java @@ -38,7 +38,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.SortedNumericDocValues; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.IndexSearcher; diff --git a/server/src/test/java/org/opensearch/index/shard/ShardUtilsTests.java b/server/src/test/java/org/opensearch/index/shard/ShardUtilsTests.java index 7cb42464c1f72..25a385f157b5c 100644 --- a/server/src/test/java/org/opensearch/index/shard/ShardUtilsTests.java +++ b/server/src/test/java/org/opensearch/index/shard/ShardUtilsTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.store.BaseDirectoryWrapper; +import org.apache.lucene.tests.store.BaseDirectoryWrapper; import org.opensearch.common.lucene.index.OpenSearchDirectoryReader; import org.opensearch.core.internal.io.IOUtils; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/index/similarity/ScriptedSimilarityTests.java b/server/src/test/java/org/opensearch/index/similarity/ScriptedSimilarityTests.java index 7f1f4ade53c50..ef935ba64f1ca 100644 --- a/server/src/test/java/org/opensearch/index/similarity/ScriptedSimilarityTests.java +++ b/server/src/test/java/org/opensearch/index/similarity/ScriptedSimilarityTests.java @@ -52,7 +52,7 @@ import org.apache.lucene.search.similarities.BM25Similarity; import org.apache.lucene.store.ByteBuffersDirectory; import org.apache.lucene.store.Directory; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.apache.lucene.util.Version; import org.opensearch.script.SimilarityScript; import org.opensearch.script.SimilarityWeightScript; diff --git a/server/src/test/java/org/opensearch/index/store/ByteSizeCachingDirectoryTests.java b/server/src/test/java/org/opensearch/index/store/ByteSizeCachingDirectoryTests.java index 2bfaa0ee51753..1de7587626712 100644 --- a/server/src/test/java/org/opensearch/index/store/ByteSizeCachingDirectoryTests.java +++ b/server/src/test/java/org/opensearch/index/store/ByteSizeCachingDirectoryTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.store.FilterDirectory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexOutput; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.common.unit.TimeValue; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/index/store/StoreTests.java b/server/src/test/java/org/opensearch/index/store/StoreTests.java index 53ba689fbe011..fdec86e7912fd 100644 --- a/server/src/test/java/org/opensearch/index/store/StoreTests.java +++ b/server/src/test/java/org/opensearch/index/store/StoreTests.java @@ -31,7 +31,7 @@ package org.opensearch.index.store; -import org.apache.lucene.analysis.MockAnalyzer; +import org.apache.lucene.tests.analysis.MockAnalyzer; import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -51,7 +51,7 @@ import org.apache.lucene.index.SegmentInfos; import org.apache.lucene.index.SnapshotDeletionPolicy; import org.apache.lucene.index.Term; -import org.apache.lucene.store.BaseDirectoryWrapper; +import org.apache.lucene.tests.store.BaseDirectoryWrapper; import org.apache.lucene.store.ByteBuffersDirectory; import org.apache.lucene.store.ChecksumIndexInput; import org.apache.lucene.store.Directory; @@ -61,7 +61,7 @@ import org.apache.lucene.store.IndexOutput; import org.apache.lucene.store.NIOFSDirectory; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.apache.lucene.util.Version; import org.opensearch.ExceptionsHelper; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/server/src/test/java/org/opensearch/index/translog/TestTranslog.java b/server/src/test/java/org/opensearch/index/translog/TestTranslog.java index 1bf245dc72a20..4e9d56aeb9573 100644 --- a/server/src/test/java/org/opensearch/index/translog/TestTranslog.java +++ b/server/src/test/java/org/opensearch/index/translog/TestTranslog.java @@ -35,7 +35,7 @@ import com.carrotsearch.randomizedtesting.generators.RandomNumbers; import com.carrotsearch.randomizedtesting.generators.RandomPicks; import org.apache.logging.log4j.Logger; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.common.io.stream.InputStreamStreamInput; import org.opensearch.core.internal.io.IOUtils; diff --git a/server/src/test/java/org/opensearch/index/translog/TranslogTests.java b/server/src/test/java/org/opensearch/index/translog/TranslogTests.java index f1a6ba84e8543..153677e00c22b 100644 --- a/server/src/test/java/org/opensearch/index/translog/TranslogTests.java +++ b/server/src/test/java/org/opensearch/index/translog/TranslogTests.java @@ -41,14 +41,14 @@ import org.apache.lucene.document.TextField; import org.apache.lucene.index.IndexFormatTooOldException; import org.apache.lucene.index.Term; -import org.apache.lucene.mockfile.FilterFileChannel; -import org.apache.lucene.mockfile.FilterFileSystemProvider; +import org.apache.lucene.tests.mockfile.FilterFileChannel; +import org.apache.lucene.tests.mockfile.FilterFileSystemProvider; import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.ByteArrayDataOutput; import org.apache.lucene.store.DataOutput; -import org.apache.lucene.store.MockDirectoryWrapper; -import org.apache.lucene.util.LineFileDocs; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.store.MockDirectoryWrapper; +import org.apache.lucene.tests.util.LineFileDocs; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.Assertions; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/server/src/test/java/org/opensearch/indices/analysis/AnalysisModuleTests.java b/server/src/test/java/org/opensearch/indices/analysis/AnalysisModuleTests.java index bc2ecc2e62fae..efec81e803f1c 100644 --- a/server/src/test/java/org/opensearch/indices/analysis/AnalysisModuleTests.java +++ b/server/src/test/java/org/opensearch/indices/analysis/AnalysisModuleTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.CharFilter; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenFilter; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; @@ -87,7 +87,7 @@ import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; -import static org.apache.lucene.analysis.BaseTokenStreamTestCase.assertTokenStreamContents; +import static org.apache.lucene.tests.analysis.BaseTokenStreamTestCase.assertTokenStreamContents; import static org.hamcrest.Matchers.either; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; diff --git a/server/src/test/java/org/opensearch/indices/recovery/RecoverySourceHandlerTests.java b/server/src/test/java/org/opensearch/indices/recovery/RecoverySourceHandlerTests.java index dbafab49d8655..80326fbf2de6b 100644 --- a/server/src/test/java/org/opensearch/indices/recovery/RecoverySourceHandlerTests.java +++ b/server/src/test/java/org/opensearch/indices/recovery/RecoverySourceHandlerTests.java @@ -40,9 +40,9 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexCommit; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; -import org.apache.lucene.store.BaseDirectoryWrapper; +import org.apache.lucene.tests.store.BaseDirectoryWrapper; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.util.SetOnce; diff --git a/server/src/test/java/org/opensearch/lucene/analysis/miscellaneous/DeDuplicatingTokenFilterTests.java b/server/src/test/java/org/opensearch/lucene/analysis/miscellaneous/DeDuplicatingTokenFilterTests.java index 38f1c23bfa1f3..1bcb17a81efee 100644 --- a/server/src/test/java/org/opensearch/lucene/analysis/miscellaneous/DeDuplicatingTokenFilterTests.java +++ b/server/src/test/java/org/opensearch/lucene/analysis/miscellaneous/DeDuplicatingTokenFilterTests.java @@ -33,7 +33,7 @@ package org.opensearch.lucene.analysis.miscellaneous; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.miscellaneous.DeDuplicatingTokenFilter; diff --git a/server/src/test/java/org/opensearch/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java b/server/src/test/java/org/opensearch/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java index c4601a9053f54..bce9073f85bbe 100644 --- a/server/src/test/java/org/opensearch/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java +++ b/server/src/test/java/org/opensearch/lucene/analysis/miscellaneous/TruncateTokenFilterTests.java @@ -33,7 +33,7 @@ package org.opensearch.lucene.analysis.miscellaneous; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.miscellaneous.TruncateTokenFilter; diff --git a/server/src/test/java/org/opensearch/lucene/grouping/CollapsingTopDocsCollectorTests.java b/server/src/test/java/org/opensearch/lucene/grouping/CollapsingTopDocsCollectorTests.java index 514ff904e6ff3..9a2a44abbb4ef 100644 --- a/server/src/test/java/org/opensearch/lucene/grouping/CollapsingTopDocsCollectorTests.java +++ b/server/src/test/java/org/opensearch/lucene/grouping/CollapsingTopDocsCollectorTests.java @@ -40,8 +40,8 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReaderContext; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; -import org.apache.lucene.search.CheckHits; +import org.apache.lucene.tests.index.RandomIndexWriter; +import org.apache.lucene.tests.search.CheckHits; import org.apache.lucene.search.Collector; import org.apache.lucene.search.FieldDoc; import org.apache.lucene.search.IndexSearcher; diff --git a/server/src/test/java/org/opensearch/lucene/index/ShuffleForcedMergePolicyTests.java b/server/src/test/java/org/opensearch/lucene/index/ShuffleForcedMergePolicyTests.java index fcce7819d6143..e583c12473a30 100644 --- a/server/src/test/java/org/opensearch/lucene/index/ShuffleForcedMergePolicyTests.java +++ b/server/src/test/java/org/opensearch/lucene/index/ShuffleForcedMergePolicyTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.Field; import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.document.StringField; -import org.apache.lucene.index.BaseMergePolicyTestCase; +import org.apache.lucene.tests.index.BaseMergePolicyTestCase; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; diff --git a/server/src/test/java/org/opensearch/lucene/misc/search/similarity/LegacyBM25SimilarityTests.java b/server/src/test/java/org/opensearch/lucene/misc/search/similarity/LegacyBM25SimilarityTests.java index 7f89176c302df..209b0d959c8b0 100644 --- a/server/src/test/java/org/opensearch/lucene/misc/search/similarity/LegacyBM25SimilarityTests.java +++ b/server/src/test/java/org/opensearch/lucene/misc/search/similarity/LegacyBM25SimilarityTests.java @@ -29,7 +29,7 @@ import org.apache.lucene.misc.search.similarity.LegacyBM25Similarity; import org.apache.lucene.search.similarities.BM25Similarity; -import org.apache.lucene.search.similarities.BaseSimilarityTestCase; +import org.apache.lucene.tests.search.similarities.BaseSimilarityTestCase; import org.apache.lucene.search.similarities.Similarity; @Deprecated diff --git a/server/src/test/java/org/opensearch/lucene/queries/BaseRandomBinaryDocValuesRangeQueryTestCase.java b/server/src/test/java/org/opensearch/lucene/queries/BaseRandomBinaryDocValuesRangeQueryTestCase.java index 29a826037770f..4e12c946cf353 100644 --- a/server/src/test/java/org/opensearch/lucene/queries/BaseRandomBinaryDocValuesRangeQueryTestCase.java +++ b/server/src/test/java/org/opensearch/lucene/queries/BaseRandomBinaryDocValuesRangeQueryTestCase.java @@ -33,7 +33,7 @@ import org.apache.lucene.document.BinaryDocValuesField; import org.apache.lucene.document.Field; -import org.apache.lucene.search.BaseRangeFieldQueryTestCase; +import org.apache.lucene.tests.search.BaseRangeFieldQueryTestCase; import org.apache.lucene.search.Query; import org.apache.lucene.util.BytesRef; import org.opensearch.index.mapper.RangeFieldMapper; diff --git a/server/src/test/java/org/opensearch/lucene/queries/BinaryDocValuesRangeQueryTests.java b/server/src/test/java/org/opensearch/lucene/queries/BinaryDocValuesRangeQueryTests.java index 70e3c7ca53995..faf84b53e0b16 100644 --- a/server/src/test/java/org/opensearch/lucene/queries/BinaryDocValuesRangeQueryTests.java +++ b/server/src/test/java/org/opensearch/lucene/queries/BinaryDocValuesRangeQueryTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.document.BinaryDocValuesField; import org.apache.lucene.document.Document; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/lucene/queries/BlendedTermQueryTests.java b/server/src/test/java/org/opensearch/lucene/queries/BlendedTermQueryTests.java index f46a8bbca0d2a..bf9aac344e3df 100644 --- a/server/src/test/java/org/opensearch/lucene/queries/BlendedTermQueryTests.java +++ b/server/src/test/java/org/opensearch/lucene/queries/BlendedTermQueryTests.java @@ -31,7 +31,7 @@ package org.opensearch.lucene.queries; -import org.apache.lucene.analysis.MockAnalyzer; +import org.apache.lucene.tests.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.FieldType; @@ -47,7 +47,7 @@ import org.apache.lucene.search.DisjunctionMaxQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; -import org.apache.lucene.search.QueryUtils; +import org.apache.lucene.tests.search.QueryUtils; import org.apache.lucene.search.QueryVisitor; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TermQuery; diff --git a/server/src/test/java/org/opensearch/lucene/queries/IntegerRandomBinaryDocValuesRangeQueryTests.java b/server/src/test/java/org/opensearch/lucene/queries/IntegerRandomBinaryDocValuesRangeQueryTests.java index e4d3615277455..4428fe979b5f4 100644 --- a/server/src/test/java/org/opensearch/lucene/queries/IntegerRandomBinaryDocValuesRangeQueryTests.java +++ b/server/src/test/java/org/opensearch/lucene/queries/IntegerRandomBinaryDocValuesRangeQueryTests.java @@ -31,7 +31,7 @@ package org.opensearch.lucene.queries; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.index.mapper.RangeType; public class IntegerRandomBinaryDocValuesRangeQueryTests extends BaseRandomBinaryDocValuesRangeQueryTestCase { diff --git a/server/src/test/java/org/opensearch/lucene/queries/LongRandomBinaryDocValuesRangeQueryTests.java b/server/src/test/java/org/opensearch/lucene/queries/LongRandomBinaryDocValuesRangeQueryTests.java index cd8457b828342..6d01e96b48132 100644 --- a/server/src/test/java/org/opensearch/lucene/queries/LongRandomBinaryDocValuesRangeQueryTests.java +++ b/server/src/test/java/org/opensearch/lucene/queries/LongRandomBinaryDocValuesRangeQueryTests.java @@ -31,7 +31,7 @@ package org.opensearch.lucene.queries; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.index.mapper.RangeType; public class LongRandomBinaryDocValuesRangeQueryTests extends BaseRandomBinaryDocValuesRangeQueryTestCase { diff --git a/server/src/test/java/org/opensearch/lucene/queries/MinDocQueryTests.java b/server/src/test/java/org/opensearch/lucene/queries/MinDocQueryTests.java index d5c789ae0aa89..a75a1d5b2fdb7 100644 --- a/server/src/test/java/org/opensearch/lucene/queries/MinDocQueryTests.java +++ b/server/src/test/java/org/opensearch/lucene/queries/MinDocQueryTests.java @@ -35,10 +35,10 @@ import org.apache.lucene.document.Document; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.MultiReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; -import org.apache.lucene.search.QueryUtils; +import org.apache.lucene.tests.search.QueryUtils; import org.apache.lucene.store.Directory; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/lucene/queries/SearchAfterSortedDocQueryTests.java b/server/src/test/java/org/opensearch/lucene/queries/SearchAfterSortedDocQueryTests.java index b4e035443cd82..4920e252e7a6b 100644 --- a/server/src/test/java/org/opensearch/lucene/queries/SearchAfterSortedDocQueryTests.java +++ b/server/src/test/java/org/opensearch/lucene/queries/SearchAfterSortedDocQueryTests.java @@ -38,12 +38,12 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.ReaderUtil; import org.apache.lucene.search.FieldDoc; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; -import org.apache.lucene.search.QueryUtils; +import org.apache.lucene.tests.search.QueryUtils; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.Sort; import org.apache.lucene.search.SortField; diff --git a/server/src/test/java/org/opensearch/lucene/queries/SpanMatchNoDocsQueryTests.java b/server/src/test/java/org/opensearch/lucene/queries/SpanMatchNoDocsQueryTests.java index 110a64e102ed4..bf266af38fc59 100644 --- a/server/src/test/java/org/opensearch/lucene/queries/SpanMatchNoDocsQueryTests.java +++ b/server/src/test/java/org/opensearch/lucene/queries/SpanMatchNoDocsQueryTests.java @@ -33,7 +33,7 @@ package org.opensearch.lucene.queries; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.MockAnalyzer; +import org.apache.lucene.tests.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.DirectoryReader; @@ -47,7 +47,7 @@ import org.apache.lucene.queries.spans.SpanTermQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; -import org.apache.lucene.search.QueryUtils; +import org.apache.lucene.tests.search.QueryUtils; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.store.Directory; import org.opensearch.test.OpenSearchTestCase; diff --git a/server/src/test/java/org/opensearch/lucene/search/uhighlight/CustomUnifiedHighlighterTests.java b/server/src/test/java/org/opensearch/lucene/search/uhighlight/CustomUnifiedHighlighterTests.java index 70a260837271c..5383a153034e9 100644 --- a/server/src/test/java/org/opensearch/lucene/search/uhighlight/CustomUnifiedHighlighterTests.java +++ b/server/src/test/java/org/opensearch/lucene/search/uhighlight/CustomUnifiedHighlighterTests.java @@ -43,7 +43,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.queries.CommonTermsQuery; import org.apache.lucene.search.BooleanClause; diff --git a/server/src/test/java/org/opensearch/monitor/fs/FsHealthServiceTests.java b/server/src/test/java/org/opensearch/monitor/fs/FsHealthServiceTests.java index 7517e24d555db..0246c8a85e97a 100644 --- a/server/src/test/java/org/opensearch/monitor/fs/FsHealthServiceTests.java +++ b/server/src/test/java/org/opensearch/monitor/fs/FsHealthServiceTests.java @@ -34,8 +34,8 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; -import org.apache.lucene.mockfile.FilterFileChannel; -import org.apache.lucene.mockfile.FilterFileSystemProvider; +import org.apache.lucene.tests.mockfile.FilterFileChannel; +import org.apache.lucene.tests.mockfile.FilterFileSystemProvider; import org.opensearch.cluster.coordination.DeterministicTaskQueue; import org.opensearch.common.io.PathUtils; import org.opensearch.common.io.PathUtilsForTesting; diff --git a/server/src/test/java/org/opensearch/node/NodeTests.java b/server/src/test/java/org/opensearch/node/NodeTests.java index a253c618ac659..783fe1abdca17 100644 --- a/server/src/test/java/org/opensearch/node/NodeTests.java +++ b/server/src/test/java/org/opensearch/node/NodeTests.java @@ -31,7 +31,7 @@ package org.opensearch.node; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.apache.lucene.util.SetOnce; import org.opensearch.bootstrap.BootstrapCheck; import org.opensearch.bootstrap.BootstrapContext; diff --git a/server/src/test/java/org/opensearch/plugins/PluginsServiceTests.java b/server/src/test/java/org/opensearch/plugins/PluginsServiceTests.java index bddc61211592e..e022e78e7424b 100644 --- a/server/src/test/java/org/opensearch/plugins/PluginsServiceTests.java +++ b/server/src/test/java/org/opensearch/plugins/PluginsServiceTests.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.lucene.util.Constants; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.bootstrap.JarHell; diff --git a/server/src/test/java/org/opensearch/repositories/blobstore/BlobStoreRepositoryRestoreTests.java b/server/src/test/java/org/opensearch/repositories/blobstore/BlobStoreRepositoryRestoreTests.java index a5224489b5bba..7cbe3d6dbd30a 100644 --- a/server/src/test/java/org/opensearch/repositories/blobstore/BlobStoreRepositoryRestoreTests.java +++ b/server/src/test/java/org/opensearch/repositories/blobstore/BlobStoreRepositoryRestoreTests.java @@ -33,7 +33,7 @@ package org.opensearch.repositories.blobstore; import org.apache.lucene.store.Directory; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.Version; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.metadata.Metadata; diff --git a/server/src/test/java/org/opensearch/repositories/fs/FsRepositoryTests.java b/server/src/test/java/org/opensearch/repositories/fs/FsRepositoryTests.java index f2c6a13b92597..2bfcec6e75ffc 100644 --- a/server/src/test/java/org/opensearch/repositories/fs/FsRepositoryTests.java +++ b/server/src/test/java/org/opensearch/repositories/fs/FsRepositoryTests.java @@ -31,7 +31,7 @@ package org.opensearch.repositories.fs; -import org.apache.lucene.analysis.MockAnalyzer; +import org.apache.lucene.tests.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.SortedDocValuesField; @@ -46,7 +46,7 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.IOSupplier; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.Version; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/server/src/test/java/org/opensearch/search/DefaultSearchContextTests.java b/server/src/test/java/org/opensearch/search/DefaultSearchContextTests.java index 48c4717f664cb..3429e1635b58b 100644 --- a/server/src/test/java/org/opensearch/search/DefaultSearchContextTests.java +++ b/server/src/test/java/org/opensearch/search/DefaultSearchContextTests.java @@ -33,7 +33,7 @@ package org.opensearch.search; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/SearchCancellationTests.java b/server/src/test/java/org/opensearch/search/SearchCancellationTests.java index 3942bdc0247f4..1927558f94094 100644 --- a/server/src/test/java/org/opensearch/search/SearchCancellationTests.java +++ b/server/src/test/java/org/opensearch/search/SearchCancellationTests.java @@ -38,14 +38,14 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.NoMergePolicy; import org.apache.lucene.index.PointValues; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Terms; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.TotalHitCountCollector; import org.apache.lucene.store.Directory; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.apache.lucene.util.automaton.CompiledAutomaton; import org.apache.lucene.util.automaton.RegExp; import org.opensearch.core.internal.io.IOUtils; diff --git a/server/src/test/java/org/opensearch/search/SearchHitsTests.java b/server/src/test/java/org/opensearch/search/SearchHitsTests.java index fc5bfc90a1e34..11df58c4ee7c7 100644 --- a/server/src/test/java/org/opensearch/search/SearchHitsTests.java +++ b/server/src/test/java/org/opensearch/search/SearchHitsTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.search.SortField; import org.apache.lucene.search.TotalHits; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.action.OriginalIndices; import org.opensearch.common.Strings; import org.opensearch.common.bytes.BytesReference; diff --git a/server/src/test/java/org/opensearch/search/aggregations/MultiBucketCollectorTests.java b/server/src/test/java/org/opensearch/search/aggregations/MultiBucketCollectorTests.java index d20c71704c76f..ae1d5c60c231a 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/MultiBucketCollectorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/MultiBucketCollectorTests.java @@ -35,7 +35,7 @@ import org.apache.lucene.document.Document; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.CollectionTerminatedException; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/BestBucketsDeferringCollectorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/BestBucketsDeferringCollectorTests.java index e0d90d96923b8..cc9628a13c060 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/BestBucketsDeferringCollectorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/BestBucketsDeferringCollectorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/BucketsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/BucketsAggregatorTests.java index 0f401a95713b9..55f8d11e2d934 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/BucketsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/BucketsAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.store.Directory; import org.opensearch.common.breaker.CircuitBreaker; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/GlobalAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/GlobalAggregatorTests.java index 3f0dd797f1c77..abcaf06645a20 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/GlobalAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/GlobalAggregatorTests.java @@ -35,7 +35,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregatorTests.java index 07c6e927c2030..88b2323b8adfc 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeAggregatorTests.java @@ -32,7 +32,7 @@ package org.opensearch.search.aggregations.bucket.composite; -import org.apache.lucene.analysis.MockAnalyzer; +import org.apache.lucene.tests.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.DoublePoint; import org.apache.lucene.document.Field; @@ -46,7 +46,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.IndexSearcher; @@ -60,7 +60,7 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.NumericUtils; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.OpenSearchParseException; import org.opensearch.common.geo.GeoPoint; import org.opensearch.common.settings.Settings; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesCollectorQueueTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesCollectorQueueTests.java index 0ad6d30df337f..3dccdf8dab95e 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesCollectorQueueTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesCollectorQueueTests.java @@ -43,7 +43,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.CollectionTerminatedException; import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.MatchAllDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/FilterAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/FilterAggregatorTests.java index 8a32e3655d6e1..4ed95bf7391a6 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/FilterAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/FilterAggregatorTests.java @@ -35,7 +35,7 @@ import org.apache.lucene.document.Field; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/FiltersAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/FiltersAggregatorTests.java index 8412665a1e8f6..8ff2e57d5dbb6 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/FiltersAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/FiltersAggregatorTests.java @@ -35,7 +35,7 @@ import org.apache.lucene.document.Field; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java index 8292377349b79..17fddb8978499 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/geogrid/GeoGridAggregatorTestCase.java @@ -37,7 +37,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexableField; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java index e69feb3744aa2..0f49e02febabe 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java @@ -39,7 +39,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexableField; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTestCase.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTestCase.java index 3524bef8b842c..ff9122aa42326 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTestCase.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTestCase.java @@ -34,7 +34,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.document.SortedSetDocValuesField; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.util.BytesRef; import org.opensearch.common.CheckedBiConsumer; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java index d954c2641c048..597175d89bcfe 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateRangeHistogramAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateRangeHistogramAggregatorTests.java index 413ba02b21272..87f3ed166e5d0 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateRangeHistogramAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateRangeHistogramAggregatorTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.Document; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.queries.BinaryDocValuesRangeQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/InternalHistogramTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/InternalHistogramTests.java index 7211b0366e36a..288b22ccfcc92 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/InternalHistogramTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/InternalHistogramTests.java @@ -32,7 +32,7 @@ package org.opensearch.search.aggregations.bucket.histogram; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.search.DocValueFormat; import org.opensearch.search.aggregations.BucketOrder; import org.opensearch.search.aggregations.InternalAggregations; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/InternalVariableWidthHistogramTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/InternalVariableWidthHistogramTests.java index 5788dbac67e39..72b11c1657fb5 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/InternalVariableWidthHistogramTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/InternalVariableWidthHistogramTests.java @@ -32,7 +32,7 @@ package org.opensearch.search.aggregations.bucket.histogram; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.common.breaker.CircuitBreaker; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.MockBigArrays; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/NumericHistogramAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/NumericHistogramAggregatorTests.java index 4313b9667c411..e7b22a9a57476 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/NumericHistogramAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/NumericHistogramAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.document.SortedSetDocValuesField; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexableField; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/RangeHistogramAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/RangeHistogramAggregatorTests.java index 482f3eb02b7dc..41bd0d77bff00 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/RangeHistogramAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/RangeHistogramAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexableField; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregatorTests.java index af1a112a40924..b1d62f3402bc3 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregatorTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/missing/MissingAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/missing/MissingAggregatorTests.java index 02667bd6ec5ae..e888972b8e447 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/missing/MissingAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/missing/MissingAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexableField; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/nested/NestedAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/nested/NestedAggregatorTests.java index b394063033637..8ab0cc0023346 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/nested/NestedAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/nested/NestedAggregatorTests.java @@ -41,7 +41,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.NoMergePolicy; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/nested/ReverseNestedAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/nested/ReverseNestedAggregatorTests.java index 60486aedd3d0d..cf0e31bc63467 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/nested/ReverseNestedAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/nested/ReverseNestedAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; import org.opensearch.index.mapper.IdFieldMapper; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/range/BinaryRangeAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/range/BinaryRangeAggregatorTests.java index e9270c4ad1556..9c2578a2378cc 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/range/BinaryRangeAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/range/BinaryRangeAggregatorTests.java @@ -37,7 +37,7 @@ import java.util.Set; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.index.fielddata.AbstractSortedSetDocValues; import org.opensearch.index.fielddata.SortedBinaryDocValues; import org.opensearch.search.aggregations.LeafBucketCollector; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/range/DateRangeAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/range/DateRangeAggregatorTests.java index f9e3a6068ebfd..e6d7230aa6cb0 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/range/DateRangeAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/range/DateRangeAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.document.SortedSetDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/range/IpRangeAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/range/IpRangeAggregatorTests.java index deeea6bc1daef..b74f21ef09037 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/range/IpRangeAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/range/IpRangeAggregatorTests.java @@ -35,7 +35,7 @@ import org.apache.lucene.document.InetAddressPoint; import org.apache.lucene.document.SortedSetDocValuesField; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/range/RangeAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/range/RangeAggregatorTests.java index 3825efe3e29c2..f1be4d1ede930 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/range/RangeAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/range/RangeAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.document.SortedSetDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/sampler/BestDocsDeferringCollectorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/sampler/BestDocsDeferringCollectorTests.java index 46a7953d5315a..427d0b89aa688 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/sampler/BestDocsDeferringCollectorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/sampler/BestDocsDeferringCollectorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.ScoreDoc; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/sampler/DiversifiedSamplerTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/sampler/DiversifiedSamplerTests.java index b66694dda229a..bb07b9c4af37e 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/sampler/DiversifiedSamplerTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/sampler/DiversifiedSamplerTests.java @@ -40,7 +40,7 @@ import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/BinaryTermsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/BinaryTermsAggregatorTests.java index ff348c6fca057..7703afa88d93c 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/BinaryTermsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/BinaryTermsAggregatorTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.document.Document; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/KeywordTermsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/KeywordTermsAggregatorTests.java index cf0a1bf090411..05197c7e85844 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/KeywordTermsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/KeywordTermsAggregatorTests.java @@ -35,7 +35,7 @@ import org.apache.lucene.document.SortedSetDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/NumericTermsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/NumericTermsAggregatorTests.java index 4d900c9a18f79..13e41d5a2e543 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/NumericTermsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/NumericTermsAggregatorTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java index e31472ffebcdd..9a9a03e715644 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java @@ -41,7 +41,7 @@ import org.apache.lucene.document.SortedSetDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificantTermsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificantTermsAggregatorTests.java index 2c86adfa20358..883196d290154 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificantTermsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/SignificantTermsAggregatorTests.java @@ -43,7 +43,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/TermsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/TermsAggregatorTests.java index 85816ef51d521..a9e819e7cbaf2 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/TermsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/TermsAggregatorTests.java @@ -44,7 +44,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexableField; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/AvgAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/AvgAggregatorTests.java index 2dab40eb0e17d..99c6ed121011e 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/AvgAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/AvgAggregatorTests.java @@ -39,7 +39,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.MultiReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/CardinalityAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/CardinalityAggregatorTests.java index 252fed3a43f0c..e33851f286613 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/CardinalityAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/CardinalityAggregatorTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.IntPoint; import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.document.SortedNumericDocValuesField; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/ExtendedStatsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/ExtendedStatsAggregatorTests.java index c46f3a4d6b5df..6fab4436182c2 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/ExtendedStatsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/ExtendedStatsAggregatorTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/GeoBoundsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/GeoBoundsAggregatorTests.java index 78b2d047cfa06..6440c62e58e18 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/GeoBoundsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/GeoBoundsAggregatorTests.java @@ -35,7 +35,7 @@ import org.apache.lucene.document.Document; import org.apache.lucene.document.LatLonDocValuesField; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/GeoCentroidAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/GeoCentroidAggregatorTests.java index ee95b373c779a..6883a7ff15953 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/GeoCentroidAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/GeoCentroidAggregatorTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.document.Document; import org.apache.lucene.document.LatLonDocValuesField; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksAggregatorTests.java index 3e1e3bb0da6f3..e459b63aa058b 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksAggregatorTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.MultiReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/HDRPercentilesAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/HDRPercentilesAggregatorTests.java index cff342096704f..bbf7f6cfd9cc2 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/HDRPercentilesAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/HDRPercentilesAggregatorTests.java @@ -39,7 +39,7 @@ import org.apache.lucene.document.SortedSetDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/InternalTopHitsTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/InternalTopHitsTests.java index 07037be28a19f..ec4a0e1e4a675 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/InternalTopHitsTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/InternalTopHitsTests.java @@ -356,7 +356,7 @@ private Comparator sortFieldsComparator(SortField[] sortFields) { FieldComparator[] comparators = new FieldComparator[sortFields.length]; for (int i = 0; i < sortFields.length; i++) { // Values passed to getComparator shouldn't matter - comparators[i] = sortFields[i].getComparator(0, 0); + comparators[i] = sortFields[i].getComparator(0, false); } return (lhs, rhs) -> { FieldDoc l = (FieldDoc) lhs; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/MaxAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/MaxAggregatorTests.java index acff8305938e8..3d5ad3f5c163c 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/MaxAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/MaxAggregatorTests.java @@ -49,7 +49,7 @@ import org.apache.lucene.index.MultiReader; import org.apache.lucene.index.NoMergePolicy; import org.apache.lucene.index.PointValues; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.IndexSearcher; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationAggregatorTests.java index 661438832afec..0cf898090e752 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationAggregatorTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.IndexableField; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/MinAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/MinAggregatorTests.java index 0fa168b0e7371..05b3c5c7e57db 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/MinAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/MinAggregatorTests.java @@ -50,7 +50,7 @@ import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.MultiReader; import org.apache.lucene.index.NoMergePolicy; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.IndexSearcher; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/ScriptedMetricAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/ScriptedMetricAggregatorTests.java index df5dbede848b6..f2a61521eff1f 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/ScriptedMetricAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/ScriptedMetricAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.document.SortedSetDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/StatsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/StatsAggregatorTests.java index 66a6642f499ae..d8d736595164a 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/StatsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/StatsAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.MultiReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/SumAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/SumAggregatorTests.java index 08a257935eb9e..8c0087ca0b87d 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/SumAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/SumAggregatorTests.java @@ -40,7 +40,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.MultiReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.IndexSearcher; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksAggregatorTests.java index e877b9330557f..2bdc8d88bc366 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksAggregatorTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.MultiReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesAggregatorTests.java index 3122b2fee372c..50415dc10df7e 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/TopHitsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/TopHitsAggregatorTests.java index a8f9383c07125..7dc80ab6f4a7b 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/TopHitsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/TopHitsAggregatorTests.java @@ -40,7 +40,7 @@ import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.queryparser.classic.QueryParser; import org.apache.lucene.search.BooleanClause.Occur; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/ValueCountAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/ValueCountAggregatorTests.java index f5b6e289e3584..590c927a44fe0 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/ValueCountAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/ValueCountAggregatorTests.java @@ -41,7 +41,7 @@ import org.apache.lucene.document.SortedDocValuesField; import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.document.SortedSetDocValuesField; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/WeightedAvgAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/WeightedAvgAggregatorTests.java index 2024143416991..844f05f1d2208 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/WeightedAvgAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/WeightedAvgAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.DocValuesFieldExistsQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/pipeline/AvgBucketAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/pipeline/AvgBucketAggregatorTests.java index b9e7cf5e0efbd..a5779d4a289f8 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/pipeline/AvgBucketAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/pipeline/AvgBucketAggregatorTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/aggregations/pipeline/BucketScriptAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/pipeline/BucketScriptAggregatorTests.java index 82b3a368069ab..a1ff2a40d0404 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/pipeline/BucketScriptAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/pipeline/BucketScriptAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.document.SortedSetDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/aggregations/pipeline/CumulativeSumAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/pipeline/CumulativeSumAggregatorTests.java index 6c88ed3165ae0..fdd898b8fbc4c 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/pipeline/CumulativeSumAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/pipeline/CumulativeSumAggregatorTests.java @@ -37,7 +37,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery; diff --git a/server/src/test/java/org/opensearch/search/aggregations/pipeline/DerivativeAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/pipeline/DerivativeAggregatorTests.java index e7418237a735f..88628cd44c721 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/pipeline/DerivativeAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/pipeline/DerivativeAggregatorTests.java @@ -36,7 +36,7 @@ import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/aggregations/pipeline/MovFnAggrgatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/pipeline/MovFnAggrgatorTests.java index 276285d2e494f..d841625272828 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/pipeline/MovFnAggrgatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/pipeline/MovFnAggrgatorTests.java @@ -38,7 +38,7 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; diff --git a/server/src/test/java/org/opensearch/search/aggregations/support/MissingValuesTests.java b/server/src/test/java/org/opensearch/search/aggregations/support/MissingValuesTests.java index 40a60ea4a3ca3..598c1323fc13f 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/support/MissingValuesTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/support/MissingValuesTests.java @@ -38,7 +38,7 @@ import org.apache.lucene.index.SortedNumericDocValues; import org.apache.lucene.index.SortedSetDocValues; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.common.geo.GeoPoint; import org.opensearch.index.fielddata.AbstractSortedNumericDocValues; import org.opensearch.index.fielddata.AbstractSortedSetDocValues; diff --git a/server/src/test/java/org/opensearch/search/collapse/CollapseBuilderTests.java b/server/src/test/java/org/opensearch/search/collapse/CollapseBuilderTests.java index 8a05f4041d0e1..88060b645fb90 100644 --- a/server/src/test/java/org/opensearch/search/collapse/CollapseBuilderTests.java +++ b/server/src/test/java/org/opensearch/search/collapse/CollapseBuilderTests.java @@ -31,7 +31,7 @@ package org.opensearch.search.collapse; -import org.apache.lucene.analysis.MockAnalyzer; +import org.apache.lucene.tests.analysis.MockAnalyzer; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; diff --git a/server/src/test/java/org/opensearch/search/fetch/subphase/highlight/PlainHighlighterTests.java b/server/src/test/java/org/opensearch/search/fetch/subphase/highlight/PlainHighlighterTests.java index 95dca93e9d657..18288aeac13e1 100644 --- a/server/src/test/java/org/opensearch/search/fetch/subphase/highlight/PlainHighlighterTests.java +++ b/server/src/test/java/org/opensearch/search/fetch/subphase/highlight/PlainHighlighterTests.java @@ -32,12 +32,12 @@ package org.opensearch.search.fetch.subphase.highlight; -import org.apache.lucene.analysis.MockAnalyzer; +import org.apache.lucene.tests.analysis.MockAnalyzer; import org.apache.lucene.index.Term; import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.highlight.QueryScorer; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; public class PlainHighlighterTests extends LuceneTestCase { diff --git a/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java b/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java index 1722cb564e231..61458512b84e4 100644 --- a/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java +++ b/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java @@ -33,7 +33,7 @@ package org.opensearch.search.geo; import com.carrotsearch.randomizedtesting.generators.RandomNumbers; -import org.apache.lucene.geo.GeoTestUtil; +import org.apache.lucene.tests.geo.GeoTestUtil; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.search.SearchResponse; import org.opensearch.common.CheckedSupplier; diff --git a/server/src/test/java/org/opensearch/search/profile/query/QueryProfilerTests.java b/server/src/test/java/org/opensearch/search/profile/query/QueryProfilerTests.java index 30bb29dbf2aa8..afaab15e1431e 100644 --- a/server/src/test/java/org/opensearch/search/profile/query/QueryProfilerTests.java +++ b/server/src/test/java/org/opensearch/search/profile/query/QueryProfilerTests.java @@ -41,7 +41,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.Explanation; import org.apache.lucene.search.IndexSearcher; @@ -50,7 +50,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.QueryCachingPolicy; import org.apache.lucene.search.QueryVisitor; -import org.apache.lucene.search.RandomApproximationQuery; +import org.apache.lucene.tests.search.RandomApproximationQuery; import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.Scorer; import org.apache.lucene.search.ScorerSupplier; @@ -59,7 +59,7 @@ import org.apache.lucene.search.TotalHitCountCollector; import org.apache.lucene.search.Weight; import org.apache.lucene.store.Directory; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.core.internal.io.IOUtils; import org.opensearch.search.internal.ContextIndexSearcher; import org.opensearch.search.profile.ProfileResult; diff --git a/server/src/test/java/org/opensearch/search/profile/query/RandomQueryGenerator.java b/server/src/test/java/org/opensearch/search/profile/query/RandomQueryGenerator.java index cd5e6d5b920df..2409333c6bcef 100644 --- a/server/src/test/java/org/opensearch/search/profile/query/RandomQueryGenerator.java +++ b/server/src/test/java/org/opensearch/search/profile/query/RandomQueryGenerator.java @@ -32,7 +32,7 @@ package org.opensearch.search.profile.query; -import org.apache.lucene.util.English; +import org.apache.lucene.tests.util.English; import org.opensearch.common.unit.Fuzziness; import org.opensearch.index.query.BoolQueryBuilder; import org.opensearch.index.query.DisMaxQueryBuilder; diff --git a/server/src/test/java/org/opensearch/search/query/QueryPhaseTests.java b/server/src/test/java/org/opensearch/search/query/QueryPhaseTests.java index 3f7761f3f18a0..b87c11dce5be2 100644 --- a/server/src/test/java/org/opensearch/search/query/QueryPhaseTests.java +++ b/server/src/test/java/org/opensearch/search/query/QueryPhaseTests.java @@ -48,7 +48,7 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.NoMergePolicy; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.opensearch.lucene.queries.MinDocQuery; import org.apache.lucene.queries.spans.SpanNearQuery; @@ -609,7 +609,10 @@ public void testIndexSortScrollOptimization() throws Exception { FieldDoc firstDoc = (FieldDoc) context.queryResult().topDocs().topDocs.scoreDocs[0]; for (int i = 0; i < searchSortAndFormat.sort.getSort().length; i++) { @SuppressWarnings("unchecked") - FieldComparator comparator = (FieldComparator) searchSortAndFormat.sort.getSort()[i].getComparator(1, i); + FieldComparator comparator = (FieldComparator) searchSortAndFormat.sort.getSort()[i].getComparator( + 1, + false + ); int cmp = comparator.compareValues(firstDoc.fields[i], lastDoc.fields[i]); if (cmp == 0) { continue; diff --git a/server/src/test/java/org/opensearch/search/searchafter/SearchAfterBuilderTests.java b/server/src/test/java/org/opensearch/search/searchafter/SearchAfterBuilderTests.java index f3cc07e6d8aa6..6d2817269c838 100644 --- a/server/src/test/java/org/opensearch/search/searchafter/SearchAfterBuilderTests.java +++ b/server/src/test/java/org/opensearch/search/searchafter/SearchAfterBuilderTests.java @@ -278,7 +278,7 @@ public SortField.Type reducedType() { } @Override - public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) { + public FieldComparator newComparator(String fieldname, int numHits, boolean enableSkipping, boolean reversed) { return null; } diff --git a/server/src/test/java/org/opensearch/search/slice/DocValuesSliceQueryTests.java b/server/src/test/java/org/opensearch/search/slice/DocValuesSliceQueryTests.java index 0a730a3fb8d4f..2bf1225aa9b11 100644 --- a/server/src/test/java/org/opensearch/search/slice/DocValuesSliceQueryTests.java +++ b/server/src/test/java/org/opensearch/search/slice/DocValuesSliceQueryTests.java @@ -39,11 +39,11 @@ import org.apache.lucene.document.StringField; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.Collector; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.LeafCollector; -import org.apache.lucene.search.QueryUtils; +import org.apache.lucene.tests.search.QueryUtils; import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreMode; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/slice/SliceBuilderTests.java b/server/src/test/java/org/opensearch/search/slice/SliceBuilderTests.java index 6deae9d8dae33..a7cf4ef6c0a2b 100644 --- a/server/src/test/java/org/opensearch/search/slice/SliceBuilderTests.java +++ b/server/src/test/java/org/opensearch/search/slice/SliceBuilderTests.java @@ -32,7 +32,7 @@ package org.opensearch.search.slice; -import org.apache.lucene.analysis.MockAnalyzer; +import org.apache.lucene.tests.analysis.MockAnalyzer; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.DocValuesType; import org.apache.lucene.index.IndexReader; diff --git a/server/src/test/java/org/opensearch/search/slice/TermsSliceQueryTests.java b/server/src/test/java/org/opensearch/search/slice/TermsSliceQueryTests.java index c9277382a45dc..84a65b3c8a7cb 100644 --- a/server/src/test/java/org/opensearch/search/slice/TermsSliceQueryTests.java +++ b/server/src/test/java/org/opensearch/search/slice/TermsSliceQueryTests.java @@ -38,11 +38,11 @@ import org.apache.lucene.document.StringField; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.search.Collector; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.LeafCollector; -import org.apache.lucene.search.QueryUtils; +import org.apache.lucene.tests.search.QueryUtils; import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreMode; import org.apache.lucene.store.Directory; diff --git a/server/src/test/java/org/opensearch/search/sort/FieldSortBuilderTests.java b/server/src/test/java/org/opensearch/search/sort/FieldSortBuilderTests.java index 070855481966f..44d48e9073e23 100644 --- a/server/src/test/java/org/opensearch/search/sort/FieldSortBuilderTests.java +++ b/server/src/test/java/org/opensearch/search/sort/FieldSortBuilderTests.java @@ -42,10 +42,10 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.sandbox.document.HalfFloatPoint; -import org.apache.lucene.search.AssertingIndexSearcher; +import org.apache.lucene.tests.search.AssertingIndexSearcher; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.SortField; import org.apache.lucene.search.SortedNumericSelector; diff --git a/server/src/test/java/org/opensearch/watcher/FileWatcherTests.java b/server/src/test/java/org/opensearch/watcher/FileWatcherTests.java index 6a8525de034c8..74c9cd91b72f0 100644 --- a/server/src/test/java/org/opensearch/watcher/FileWatcherTests.java +++ b/server/src/test/java/org/opensearch/watcher/FileWatcherTests.java @@ -32,7 +32,7 @@ package org.opensearch.watcher; import org.opensearch.core.internal.io.IOUtils; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.test.OpenSearchTestCase; import java.io.BufferedWriter; diff --git a/test/framework/src/main/java/org/opensearch/bootstrap/BootstrapForTesting.java b/test/framework/src/main/java/org/opensearch/bootstrap/BootstrapForTesting.java index 1b34dcacef7e7..4f135f2d14a75 100644 --- a/test/framework/src/main/java/org/opensearch/bootstrap/BootstrapForTesting.java +++ b/test/framework/src/main/java/org/opensearch/bootstrap/BootstrapForTesting.java @@ -35,7 +35,7 @@ import com.carrotsearch.randomizedtesting.RandomizedRunner; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.common.Booleans; import org.opensearch.common.Strings; import org.opensearch.common.SuppressForbidden; diff --git a/test/framework/src/main/java/org/opensearch/cluster/DataStreamTestHelper.java b/test/framework/src/main/java/org/opensearch/cluster/DataStreamTestHelper.java index d3d17f28de344..af78fd36dceb4 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/DataStreamTestHelper.java +++ b/test/framework/src/main/java/org/opensearch/cluster/DataStreamTestHelper.java @@ -32,7 +32,7 @@ package org.opensearch.cluster; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.Version; import org.opensearch.cluster.metadata.DataStream; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java b/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java index 32ef47c4366a4..0e308e64617fe 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java +++ b/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java @@ -50,7 +50,7 @@ import static com.carrotsearch.randomizedtesting.RandomizedTest.rarely; import static java.util.stream.Collectors.toSet; -import static org.apache.lucene.util.LuceneTestCase.random; +import static org.apache.lucene.tests.util.LuceneTestCase.random; import static org.opensearch.test.OpenSearchTestCase.randomBoolean; import static org.opensearch.test.OpenSearchTestCase.randomFrom; import static org.opensearch.test.OpenSearchTestCase.randomIntBetween; diff --git a/test/framework/src/main/java/org/opensearch/cluster/routing/TestShardRouting.java b/test/framework/src/main/java/org/opensearch/cluster/routing/TestShardRouting.java index c164733370359..29207cbc4ada1 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/routing/TestShardRouting.java +++ b/test/framework/src/main/java/org/opensearch/cluster/routing/TestShardRouting.java @@ -41,7 +41,7 @@ import org.opensearch.snapshots.SnapshotId; import org.opensearch.test.OpenSearchTestCase; -import static org.apache.lucene.util.LuceneTestCase.random; +import static org.apache.lucene.tests.util.LuceneTestCase.random; import static org.opensearch.test.OpenSearchTestCase.randomAlphaOfLength; /** diff --git a/test/framework/src/main/java/org/opensearch/cluster/service/FakeThreadPoolMasterService.java b/test/framework/src/main/java/org/opensearch/cluster/service/FakeThreadPoolMasterService.java index c3c591f5e1ea8..14d9f9554004f 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/service/FakeThreadPoolMasterService.java +++ b/test/framework/src/main/java/org/opensearch/cluster/service/FakeThreadPoolMasterService.java @@ -52,7 +52,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import static org.apache.lucene.util.LuceneTestCase.random; +import static org.apache.lucene.tests.util.LuceneTestCase.random; import static org.opensearch.test.OpenSearchTestCase.randomInt; public class FakeThreadPoolMasterService extends MasterService { diff --git a/test/framework/src/main/java/org/opensearch/common/io/PathUtilsForTesting.java b/test/framework/src/main/java/org/opensearch/common/io/PathUtilsForTesting.java index 2811c45f03e08..e6f2ac5d4c4de 100644 --- a/test/framework/src/main/java/org/opensearch/common/io/PathUtilsForTesting.java +++ b/test/framework/src/main/java/org/opensearch/common/io/PathUtilsForTesting.java @@ -32,7 +32,7 @@ package org.opensearch.common.io; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import java.nio.file.FileSystem; diff --git a/test/framework/src/main/java/org/opensearch/common/util/MockBigArrays.java b/test/framework/src/main/java/org/opensearch/common/util/MockBigArrays.java index b46a7bdbcfce7..fc628ca5228e6 100644 --- a/test/framework/src/main/java/org/opensearch/common/util/MockBigArrays.java +++ b/test/framework/src/main/java/org/opensearch/common/util/MockBigArrays.java @@ -37,7 +37,7 @@ import org.apache.lucene.util.Accountable; import org.apache.lucene.util.Accountables; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.common.breaker.CircuitBreaker; import org.opensearch.common.util.set.Sets; import org.opensearch.indices.breaker.CircuitBreakerService; diff --git a/test/framework/src/main/java/org/opensearch/common/util/MockPageCacheRecycler.java b/test/framework/src/main/java/org/opensearch/common/util/MockPageCacheRecycler.java index 3ae9ac6996524..471cf01a3f7d2 100644 --- a/test/framework/src/main/java/org/opensearch/common/util/MockPageCacheRecycler.java +++ b/test/framework/src/main/java/org/opensearch/common/util/MockPageCacheRecycler.java @@ -32,7 +32,7 @@ package org.opensearch.common.util; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.common.recycler.Recycler.V; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.set.Sets; diff --git a/test/framework/src/main/java/org/opensearch/geo/GeometryTestUtils.java b/test/framework/src/main/java/org/opensearch/geo/GeometryTestUtils.java index e3fa5281b54de..b588243803d30 100644 --- a/test/framework/src/main/java/org/opensearch/geo/GeometryTestUtils.java +++ b/test/framework/src/main/java/org/opensearch/geo/GeometryTestUtils.java @@ -32,7 +32,7 @@ package org.opensearch.geo; -import org.apache.lucene.geo.GeoTestUtil; +import org.apache.lucene.tests.geo.GeoTestUtil; import org.opensearch.geometry.Circle; import org.opensearch.geometry.Geometry; import org.opensearch.geometry.GeometryCollection; diff --git a/test/framework/src/main/java/org/opensearch/index/MapperTestUtils.java b/test/framework/src/main/java/org/opensearch/index/MapperTestUtils.java index c64a36c60eb73..b01b4ee20c421 100644 --- a/test/framework/src/main/java/org/opensearch/index/MapperTestUtils.java +++ b/test/framework/src/main/java/org/opensearch/index/MapperTestUtils.java @@ -52,7 +52,7 @@ import java.nio.file.Path; import java.util.Collections; -import static org.apache.lucene.util.LuceneTestCase.expectThrows; +import static org.apache.lucene.tests.util.LuceneTestCase.expectThrows; import static org.opensearch.test.OpenSearchTestCase.createTestAnalysis; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; diff --git a/test/framework/src/main/java/org/opensearch/index/MockEngineFactoryPlugin.java b/test/framework/src/main/java/org/opensearch/index/MockEngineFactoryPlugin.java index 812546b9c65e7..7d3282ca4443a 100644 --- a/test/framework/src/main/java/org/opensearch/index/MockEngineFactoryPlugin.java +++ b/test/framework/src/main/java/org/opensearch/index/MockEngineFactoryPlugin.java @@ -31,7 +31,7 @@ package org.opensearch.index; -import org.apache.lucene.index.AssertingDirectoryReader; +import org.apache.lucene.tests.index.AssertingDirectoryReader; import org.apache.lucene.index.FilterDirectoryReader; import org.opensearch.common.settings.Setting; import org.opensearch.index.engine.EngineFactory; diff --git a/test/framework/src/main/java/org/opensearch/index/mapper/MapperServiceTestCase.java b/test/framework/src/main/java/org/opensearch/index/mapper/MapperServiceTestCase.java index 03ac664da1734..db6c53bd0aa77 100644 --- a/test/framework/src/main/java/org/opensearch/index/mapper/MapperServiceTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/mapper/MapperServiceTestCase.java @@ -35,7 +35,7 @@ import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.store.Directory; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/test/framework/src/main/java/org/opensearch/index/store/OpenSearchBaseDirectoryTestCase.java b/test/framework/src/main/java/org/opensearch/index/store/OpenSearchBaseDirectoryTestCase.java index 945c3d8a3bb66..428b1a83f97d5 100644 --- a/test/framework/src/main/java/org/opensearch/index/store/OpenSearchBaseDirectoryTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/store/OpenSearchBaseDirectoryTestCase.java @@ -37,9 +37,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.lucene.store.BaseDirectoryTestCase; -import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.TimeUnits; +import org.apache.lucene.tests.store.BaseDirectoryTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; +import org.apache.lucene.tests.util.TimeUnits; import org.opensearch.bootstrap.BootstrapForTesting; import org.opensearch.test.junit.listeners.ReproduceInfoPrinter; diff --git a/test/framework/src/main/java/org/opensearch/indices/analysis/AnalysisFactoryTestCase.java b/test/framework/src/main/java/org/opensearch/indices/analysis/AnalysisFactoryTestCase.java index 80c573f3cc9ae..fd762289caddb 100644 --- a/test/framework/src/main/java/org/opensearch/indices/analysis/AnalysisFactoryTestCase.java +++ b/test/framework/src/main/java/org/opensearch/indices/analysis/AnalysisFactoryTestCase.java @@ -61,7 +61,7 @@ public abstract class AnalysisFactoryTestCase extends OpenSearchTestCase { private static final Map> KNOWN_TOKENIZERS = new MapBuilder>() - // exposed in ES + // exposed in OpenSearch .put("classic", MovedToAnalysisCommon.class) .put("edgengram", MovedToAnalysisCommon.class) .put("keyword", MovedToAnalysisCommon.class) @@ -81,7 +81,7 @@ public abstract class AnalysisFactoryTestCase extends OpenSearchTestCase { .immutableMap(); static final Map> KNOWN_TOKENFILTERS = new MapBuilder>() - // exposed in ES + // exposed in OpenSearch .put("apostrophe", MovedToAnalysisCommon.class) .put("arabicnormalization", MovedToAnalysisCommon.class) .put("arabicstem", MovedToAnalysisCommon.class) @@ -217,6 +217,10 @@ public abstract class AnalysisFactoryTestCase extends OpenSearchTestCase { .put("japanesecompletion", Void.class) // LUCENE-9575: recognize arbitrary patterns that include punctuation .put("patterntyping", Void.class) + // LUCENE-10248 + .put("spanishpluralstem", Void.class) + // LUCENE-10352 + .put("daitchmokotoffsoundex", Void.class) .immutableMap(); static final Map> KNOWN_CHARFILTERS = new MapBuilder>() diff --git a/test/framework/src/main/java/org/opensearch/repositories/blobstore/OpenSearchMockAPIBasedRepositoryIntegTestCase.java b/test/framework/src/main/java/org/opensearch/repositories/blobstore/OpenSearchMockAPIBasedRepositoryIntegTestCase.java index 3e075dd1bbc3b..f082c7a45a207 100644 --- a/test/framework/src/main/java/org/opensearch/repositories/blobstore/OpenSearchMockAPIBasedRepositoryIntegTestCase.java +++ b/test/framework/src/main/java/org/opensearch/repositories/blobstore/OpenSearchMockAPIBasedRepositoryIntegTestCase.java @@ -39,7 +39,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.action.admin.indices.forcemerge.ForceMergeResponse; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.Strings; diff --git a/test/framework/src/main/java/org/opensearch/search/aggregations/AggregatorTestCase.java b/test/framework/src/main/java/org/opensearch/search/aggregations/AggregatorTestCase.java index 241ae1170817a..38a0253305833 100644 --- a/test/framework/src/main/java/org/opensearch/search/aggregations/AggregatorTestCase.java +++ b/test/framework/src/main/java/org/opensearch/search/aggregations/AggregatorTestCase.java @@ -39,15 +39,15 @@ import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.document.SortedSetDocValuesField; import org.apache.lucene.document.StoredField; -import org.apache.lucene.index.AssertingDirectoryReader; +import org.apache.lucene.tests.index.AssertingDirectoryReader; import org.apache.lucene.index.CompositeReaderContext; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReaderContext; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.index.RandomIndexWriter; +import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.sandbox.document.HalfFloatPoint; -import org.apache.lucene.search.AssertingIndexSearcher; +import org.apache.lucene.tests.search.AssertingIndexSearcher; import org.apache.lucene.search.Collector; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; @@ -652,7 +652,7 @@ protected static DirectoryReader wrapInMockESDirectoryReader(DirectoryReader dir /** * Added to randomly run with more assertions on the index searcher level, - * like {@link org.apache.lucene.util.LuceneTestCase#newSearcher(IndexReader)}, which can't be used because it also + * like {@link org.apache.lucene.tests.util.LuceneTestCase#newSearcher(IndexReader)}, which can't be used because it also * wraps in the IndexSearcher's IndexReader with other implementations that we can't handle. (e.g. ParallelCompositeReader) */ protected static IndexSearcher newIndexSearcher(IndexReader indexReader) { @@ -666,7 +666,7 @@ protected static IndexSearcher newIndexSearcher(IndexReader indexReader) { /** * Added to randomly run with more assertions on the index reader level, - * like {@link org.apache.lucene.util.LuceneTestCase#wrapReader(IndexReader)}, which can't be used because it also + * like {@link org.apache.lucene.tests.util.LuceneTestCase#wrapReader(IndexReader)}, which can't be used because it also * wraps in the IndexReader with other implementations that we can't handle. (e.g. ParallelCompositeReader) */ protected static IndexReader maybeWrapReaderEs(DirectoryReader reader) throws IOException { diff --git a/test/framework/src/main/java/org/opensearch/test/CorruptionUtils.java b/test/framework/src/main/java/org/opensearch/test/CorruptionUtils.java index 1bcde48900364..abfb3edc26417 100644 --- a/test/framework/src/main/java/org/opensearch/test/CorruptionUtils.java +++ b/test/framework/src/main/java/org/opensearch/test/CorruptionUtils.java @@ -50,7 +50,7 @@ import java.nio.file.StandardOpenOption; import java.util.Random; -import static org.apache.lucene.util.LuceneTestCase.assumeTrue; +import static org.apache.lucene.tests.util.LuceneTestCase.assumeTrue; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; diff --git a/test/framework/src/main/java/org/opensearch/test/FieldMaskingReader.java b/test/framework/src/main/java/org/opensearch/test/FieldMaskingReader.java index e2ff8c09cd329..dba42b546c1a2 100644 --- a/test/framework/src/main/java/org/opensearch/test/FieldMaskingReader.java +++ b/test/framework/src/main/java/org/opensearch/test/FieldMaskingReader.java @@ -32,7 +32,7 @@ package org.opensearch.test; import org.apache.lucene.index.DirectoryReader; -import org.apache.lucene.index.FieldFilterLeafReader; +import org.apache.lucene.tests.index.FieldFilterLeafReader; import org.apache.lucene.index.FilterDirectoryReader; import org.apache.lucene.index.FilterLeafReader; import org.apache.lucene.index.LeafReader; diff --git a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java index 5ae441ed651b1..11b39f0ff8da1 100644 --- a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java @@ -155,8 +155,8 @@ import java.util.stream.IntStream; import java.util.stream.Stream; -import static org.apache.lucene.util.LuceneTestCase.TEST_NIGHTLY; -import static org.apache.lucene.util.LuceneTestCase.rarely; +import static org.apache.lucene.tests.util.LuceneTestCase.TEST_NIGHTLY; +import static org.apache.lucene.tests.util.LuceneTestCase.rarely; import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; import static org.opensearch.common.unit.TimeValue.timeValueMillis; import static org.opensearch.common.unit.TimeValue.timeValueSeconds; diff --git a/test/framework/src/main/java/org/opensearch/test/MockKeywordPlugin.java b/test/framework/src/main/java/org/opensearch/test/MockKeywordPlugin.java index d837b98e22111..c27f3f169fbae 100644 --- a/test/framework/src/main/java/org/opensearch/test/MockKeywordPlugin.java +++ b/test/framework/src/main/java/org/opensearch/test/MockKeywordPlugin.java @@ -31,7 +31,7 @@ package org.opensearch.test; -import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.tests.analysis.MockTokenizer; import org.opensearch.index.analysis.TokenizerFactory; import org.opensearch.indices.analysis.AnalysisModule; import org.opensearch.plugins.AnalysisPlugin; diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java index b9ee655dcc979..1c09fb2ff8c04 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java @@ -39,7 +39,7 @@ import org.apache.http.HttpHost; import org.apache.lucene.search.Sort; import org.apache.lucene.search.TotalHits; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.OpenSearchException; import org.opensearch.ExceptionsHelper; import org.opensearch.action.ActionListener; diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java index 6f4ea1ecb0601..96698036fca55 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java @@ -55,11 +55,11 @@ import org.apache.logging.log4j.status.StatusData; import org.apache.logging.log4j.status.StatusLogger; import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; -import org.apache.lucene.util.TestRuleMarkFailure; -import org.apache.lucene.util.TestUtil; -import org.apache.lucene.util.TimeUnits; +import org.apache.lucene.tests.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase.SuppressCodecs; +import org.apache.lucene.tests.util.TestRuleMarkFailure; +import org.apache.lucene.tests.util.TestUtil; +import org.apache.lucene.tests.util.TimeUnits; import org.opensearch.Version; import org.opensearch.bootstrap.BootstrapForTesting; import org.opensearch.bootstrap.JavaVersion; diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchTokenStreamTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchTokenStreamTestCase.java index 48c0451da20d0..e853c1e6314e1 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchTokenStreamTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchTokenStreamTestCase.java @@ -35,9 +35,9 @@ import com.carrotsearch.randomizedtesting.annotations.Listeners; import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; -import org.apache.lucene.analysis.BaseTokenStreamTestCase; -import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.TimeUnits; +import org.apache.lucene.tests.analysis.BaseTokenStreamTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; +import org.apache.lucene.tests.util.TimeUnits; import org.opensearch.Version; import org.opensearch.bootstrap.BootstrapForTesting; import org.opensearch.cluster.metadata.IndexMetadata; diff --git a/test/framework/src/main/java/org/opensearch/test/client/RandomizingClient.java b/test/framework/src/main/java/org/opensearch/test/client/RandomizingClient.java index 42aaca6c242df..e0e916c6da0f1 100644 --- a/test/framework/src/main/java/org/opensearch/test/client/RandomizingClient.java +++ b/test/framework/src/main/java/org/opensearch/test/client/RandomizingClient.java @@ -33,7 +33,7 @@ package org.opensearch.test.client; import com.carrotsearch.randomizedtesting.generators.RandomPicks; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.tests.util.TestUtil; import org.opensearch.action.search.SearchRequestBuilder; import org.opensearch.action.search.SearchType; import org.opensearch.client.Client; diff --git a/test/framework/src/main/java/org/opensearch/test/engine/MockEngineSupport.java b/test/framework/src/main/java/org/opensearch/test/engine/MockEngineSupport.java index b49bd88310dec..f2427dfda2742 100644 --- a/test/framework/src/main/java/org/opensearch/test/engine/MockEngineSupport.java +++ b/test/framework/src/main/java/org/opensearch/test/engine/MockEngineSupport.java @@ -33,11 +33,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.lucene.index.AssertingDirectoryReader; +import org.apache.lucene.tests.index.AssertingDirectoryReader; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.FilterDirectoryReader; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.OpenSearchException; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Setting.Property; diff --git a/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java b/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java index 421c022b38e9d..28afed1a50e59 100644 --- a/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java +++ b/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java @@ -90,8 +90,8 @@ import java.util.concurrent.TimeUnit; import java.util.function.Function; -import static org.apache.lucene.util.LuceneTestCase.expectThrows; -import static org.apache.lucene.util.LuceneTestCase.expectThrowsAnyOf; +import static org.apache.lucene.tests.util.LuceneTestCase.expectThrows; +import static org.apache.lucene.tests.util.LuceneTestCase.expectThrowsAnyOf; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java b/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java index f30b1bfdd1e6b..5a404ccd4b9fc 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java @@ -35,7 +35,7 @@ import com.carrotsearch.randomizedtesting.RandomizedTest; import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; import org.apache.http.HttpHost; -import org.apache.lucene.util.TimeUnits; +import org.apache.lucene.tests.util.TimeUnits; import org.opensearch.Version; import org.opensearch.client.Node; import org.opensearch.client.Request; diff --git a/test/framework/src/main/java/org/opensearch/test/store/MockFSDirectoryFactory.java b/test/framework/src/main/java/org/opensearch/test/store/MockFSDirectoryFactory.java index 03af3977e229b..47952af1cd06c 100644 --- a/test/framework/src/main/java/org/opensearch/test/store/MockFSDirectoryFactory.java +++ b/test/framework/src/main/java/org/opensearch/test/store/MockFSDirectoryFactory.java @@ -35,12 +35,12 @@ import com.carrotsearch.randomizedtesting.generators.RandomPicks; import org.apache.logging.log4j.Logger; import org.apache.lucene.index.CheckIndex; -import org.apache.lucene.store.BaseDirectoryWrapper; +import org.apache.lucene.tests.store.BaseDirectoryWrapper; import org.apache.lucene.store.Directory; import org.apache.lucene.store.LockObtainFailedException; -import org.apache.lucene.store.MockDirectoryWrapper; -import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.TestRuleMarkFailure; +import org.apache.lucene.tests.store.MockDirectoryWrapper; +import org.apache.lucene.tests.util.LuceneTestCase; +import org.apache.lucene.tests.util.TestRuleMarkFailure; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.lucene.Lucene; diff --git a/test/framework/src/main/java/org/opensearch/test/transport/MockTransport.java b/test/framework/src/main/java/org/opensearch/test/transport/MockTransport.java index de4d5250fec84..e1e5bcc968047 100644 --- a/test/framework/src/main/java/org/opensearch/test/transport/MockTransport.java +++ b/test/framework/src/main/java/org/opensearch/test/transport/MockTransport.java @@ -63,7 +63,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.function.Function; -import static org.apache.lucene.util.LuceneTestCase.rarely; +import static org.apache.lucene.tests.util.LuceneTestCase.rarely; /** * A basic transport implementation that allows to intercept requests that have been sent diff --git a/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java b/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java index 7e38061392312..7ffd96fb68911 100644 --- a/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java +++ b/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java @@ -31,7 +31,7 @@ package org.opensearch.test.test; -import org.apache.lucene.util.LuceneTestCase; +import org.apache.lucene.tests.util.LuceneTestCase; import org.opensearch.client.Client; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodeRole; From 3675400b926bfd607cb4e0f38821d02f8849c540 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Wed, 16 Mar 2022 17:35:08 -0500 Subject: [PATCH 05/46] [Remove] type from CIR.mapping and CIRB.mapping (#2478) First pass to remove types from CreateIndexRequest and CreateIndexRequestBuilder mapping method. This method is overloaded several times so the most widely used methods in the RequestBuilder are refactored from mapping to setMapping to avoid confusion, conflicts, and to be consistent with other method names (e.g., setSettings, setCause, setAlias). Signed-off-by: Nicholas Walter Knize --- .../common/HighlighterWithAnalyzersTests.java | 9 +- .../script/expression/MoreExpressionIT.java | 10 +- .../TokenCountFieldMapperIntegrationIT.java | 5 +- .../AbstractParentChildTestCase.java | 3 +- .../join/aggregations/ChildrenIT.java | 12 +- .../join/query/ChildQuerySearchIT.java | 118 +++-------- .../opensearch/join/query/InnerHitsIT.java | 34 +-- .../percolator/PercolatorQuerySearchIT.java | 12 +- .../PercolatorQuerySearchTests.java | 4 +- .../ICUCollationKeywordFieldMapperIT.java | 31 +-- .../index/mapper/size/SizeMappingIT.java | 6 +- .../admin/indices/create/CreateIndexIT.java | 16 +- .../action/termvectors/GetTermVectorsIT.java | 36 ++-- .../cluster/SimpleClusterStateIT.java | 6 +- .../gateway/GatewayIndexStateIT.java | 5 +- .../java/org/opensearch/get/GetActionIT.java | 10 +- .../org/opensearch/index/IndexSortIT.java | 8 +- .../index/fielddata/FieldDataLoadingIT.java | 5 +- .../mapper/CopyToMapperIntegrationIT.java | 4 +- .../ExternalValuesMapperIntegrationIT.java | 15 +- .../mapper/MultiFieldsIntegrationIT.java | 12 +- .../PreBuiltAnalyzerIntegrationIT.java | 4 +- .../mapping/SimpleGetFieldMappingsIT.java | 16 +- .../indices/mapping/SimpleGetMappingsIT.java | 10 +- .../org/opensearch/mget/SimpleMgetIT.java | 11 +- .../opensearch/routing/SimpleRoutingIT.java | 36 +--- .../search/aggregations/CombiIT.java | 5 +- .../search/aggregations/EquivalenceIT.java | 20 +- .../search/aggregations/bucket/NestedIT.java | 14 +- .../aggregations/bucket/ReverseNestedIT.java | 10 +- .../aggregations/metrics/CardinalityIT.java | 5 +- .../aggregations/metrics/TopHitsIT.java | 5 +- .../aggregations/pipeline/MaxBucketIT.java | 2 +- .../aggregations/pipeline/MovAvgIT.java | 5 +- .../search/fetch/FetchSubPhasePluginIT.java | 5 +- .../search/fetch/subphase/InnerHitsIT.java | 17 +- .../highlight/HighlighterSearchIT.java | 195 ++++++------------ .../search/fieldcaps/FieldCapabilitiesIT.java | 4 +- .../search/fields/SearchFieldsIT.java | 21 +- .../functionscore/DecayFunctionScoreIT.java | 80 ++----- .../FunctionScoreFieldValueIT.java | 10 +- .../functionscore/FunctionScorePluginIT.java | 5 +- .../search/functionscore/QueryRescorerIT.java | 39 +--- .../search/geo/GeoBoundingBoxQueryIT.java | 15 +- .../opensearch/search/geo/GeoDistanceIT.java | 5 +- .../opensearch/search/geo/GeoFilterIT.java | 4 +- .../search/morelikethis/MoreLikeThisIT.java | 44 +--- .../search/nested/SimpleNestedIT.java | 33 +-- .../org/opensearch/search/query/ExistsIT.java | 12 +- .../search/query/MultiMatchQueryIT.java | 4 +- .../search/query/QueryStringIT.java | 22 +- .../search/query/SearchQueryIT.java | 21 +- .../search/query/SimpleQueryStringIT.java | 9 +- .../scriptfilter/ScriptQuerySearchIT.java | 8 +- .../search/scroll/DuelScrollIT.java | 5 +- .../opensearch/search/sort/FieldSortIT.java | 35 +--- .../opensearch/search/sort/GeoDistanceIT.java | 25 +-- .../opensearch/search/sort/SimpleSortIT.java | 10 +- .../suggest/CompletionSuggestSearchIT.java | 25 +-- .../ContextCompletionSuggestSearchIT.java | 5 +- .../search/suggest/SuggestSearchIT.java | 54 ++--- .../opensearch/similarity/SimilarityIT.java | 5 +- .../indices/create/CreateIndexRequest.java | 25 ++- .../create/CreateIndexRequestBuilder.java | 31 ++- .../indices/rollover/RolloverRequest.java | 2 +- .../create/CreateIndexRequestTests.java | 6 +- .../mapping/put/PutMappingRequestTests.java | 2 +- .../rollover/RolloverRequestTests.java | 3 +- .../indices/stats/IndicesStatsTests.java | 4 +- .../AbstractTermVectorsTestCase.java | 6 +- .../termvectors/GetTermVectorsTests.java | 2 - .../index/analysis/PreBuiltAnalyzerTests.java | 2 - .../mapper/FieldFilterMapperPluginTests.java | 6 +- .../index/search/NestedHelperTests.java | 2 - .../index/similarity/SimilarityTests.java | 16 -- .../termvectors/TermVectorsServiceTests.java | 6 - .../search/geo/GeoPointShapeQueryTests.java | 12 +- .../opensearch/search/geo/GeoQueryTests.java | 22 +- .../search/geo/GeoShapeQueryTests.java | 12 +- .../CategoryContextMappingTests.java | 20 -- .../completion/GeoContextMappingTests.java | 4 - .../index/RandomCreateIndexGenerator.java | 12 +- .../test/OpenSearchSingleNodeTestCase.java | 2 +- 83 files changed, 392 insertions(+), 1026 deletions(-) diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java index faaf636d4a8ff..a8dd2d2578541 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java @@ -70,10 +70,8 @@ protected Collection> nodePlugins() { public void testNgramHighlightingWithBrokenPositions() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "test", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("test") .startObject("properties") .startObject("name") .field("type", "text") @@ -88,7 +86,6 @@ public void testNgramHighlightingWithBrokenPositions() throws IOException { .endObject() .endObject() .endObject() - .endObject() ) .setSettings( Settings.builder() @@ -260,7 +257,7 @@ public void testPhrasePrefix() throws IOException { .put("index.analysis.filter.synonym.type", "synonym") .putList("index.analysis.filter.synonym.synonyms", "quick => fast"); - assertAcked(prepareCreate("first_test_index").setSettings(builder.build()).addMapping("type1", type1TermVectorMapping())); + assertAcked(prepareCreate("first_test_index").setSettings(builder.build()).setMapping(type1TermVectorMapping())); ensureGreen(); @@ -421,7 +418,6 @@ public void testPhrasePrefix() throws IOException { public static XContentBuilder type1TermVectorMapping() throws IOException { return XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -432,7 +428,6 @@ public static XContentBuilder type1TermVectorMapping() throws IOException { .field("term_vector", "with_positions_offsets") .endObject() .endObject() - .endObject() .endObject(); } } diff --git a/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java b/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java index 259234d79ab42..450e70c3c8938 100644 --- a/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java +++ b/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java @@ -641,12 +641,11 @@ public void testPipelineAggregationScript() throws Exception { public void testGeo() throws Exception { XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("location") .field("type", "geo_point"); - xContentBuilder.endObject().endObject().endObject().endObject(); - assertAcked(prepareCreate("test").addMapping("type1", xContentBuilder)); + xContentBuilder.endObject().endObject().endObject(); + assertAcked(prepareCreate("test").setMapping(xContentBuilder)); ensureGreen(); client().prepareIndex("test") .setId("1") @@ -687,12 +686,11 @@ public void testGeo() throws Exception { public void testBoolean() throws Exception { XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() - .startObject("doc") .startObject("properties") .startObject("vip") .field("type", "boolean"); - xContentBuilder.endObject().endObject().endObject().endObject(); - assertAcked(prepareCreate("test").addMapping("doc", xContentBuilder)); + xContentBuilder.endObject().endObject().endObject(); + assertAcked(prepareCreate("test").setMapping(xContentBuilder)); ensureGreen(); indexRandom( true, diff --git a/modules/mapper-extras/src/javaRestTest/java/org/opensearch/index/mapper/TokenCountFieldMapperIntegrationIT.java b/modules/mapper-extras/src/javaRestTest/java/org/opensearch/index/mapper/TokenCountFieldMapperIntegrationIT.java index cbba425a04889..e25344a4bb4e3 100644 --- a/modules/mapper-extras/src/javaRestTest/java/org/opensearch/index/mapper/TokenCountFieldMapperIntegrationIT.java +++ b/modules/mapper-extras/src/javaRestTest/java/org/opensearch/index/mapper/TokenCountFieldMapperIntegrationIT.java @@ -128,10 +128,8 @@ private void init() throws IOException { settings.put("index.analysis.analyzer.mock_english.tokenizer", "standard"); settings.put("index.analysis.analyzer.mock_english.filter", "stop"); prepareCreate("test").setSettings(settings) - .addMapping( - "test", + .setMapping( jsonBuilder().startObject() - .startObject("test") .startObject("properties") .startObject("foo") .field("type", "text") @@ -162,7 +160,6 @@ private void init() throws IOException { .endObject() .endObject() .endObject() - .endObject() ) .get(); ensureGreen(); diff --git a/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/aggregations/AbstractParentChildTestCase.java b/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/aggregations/AbstractParentChildTestCase.java index c2536897f352a..5566c688aefbf 100644 --- a/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/aggregations/AbstractParentChildTestCase.java +++ b/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/aggregations/AbstractParentChildTestCase.java @@ -55,8 +55,7 @@ public abstract class AbstractParentChildTestCase extends ParentChildTestCase { @Before public void setupCluster() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "doc", + prepareCreate("test").setMapping( addFieldMappings( buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "article", "comment"), "commenter", diff --git a/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/aggregations/ChildrenIT.java b/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/aggregations/ChildrenIT.java index 4e98d2aa1af08..08354cbaaf93b 100644 --- a/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/aggregations/ChildrenIT.java +++ b/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/aggregations/ChildrenIT.java @@ -174,8 +174,7 @@ public void testParentWithMultipleBuckets() throws Exception { public void testWithDeletes() throws Exception { String indexName = "xyz"; assertAcked( - prepareCreate(indexName).addMapping( - "doc", + prepareCreate(indexName).setMapping( addFieldMappings(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"), "name", "keyword") ) ); @@ -234,8 +233,7 @@ public void testPostCollection() throws Exception { prepareCreate(indexName).setSettings( Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ) - .addMapping( - "doc", + .setMapping( addFieldMappings( buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, masterType, childType), "brand", @@ -309,8 +307,7 @@ public void testHierarchicalChildrenAggs() { String parentType = "country"; String childType = "city"; assertAcked( - prepareCreate(indexName).addMapping( - "doc", + prepareCreate(indexName).setMapping( addFieldMappings( buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, grandParentType, parentType, parentType, childType), "name", @@ -352,8 +349,7 @@ public void testPostCollectAllLeafReaders() throws Exception { // Before we only evaluated segments that yielded matches in 'towns' and 'parent_names' aggs, which caused // us to miss to evaluate child docs in segments we didn't have parent matches for. assertAcked( - prepareCreate("index").addMapping( - "doc", + prepareCreate("index").setMapping( addFieldMappings( buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parentType", "childType"), "name", diff --git a/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/query/ChildQuerySearchIT.java b/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/query/ChildQuerySearchIT.java index ce83790c0d302..d684f0bfebcfb 100644 --- a/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/query/ChildQuerySearchIT.java +++ b/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/query/ChildQuerySearchIT.java @@ -102,8 +102,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase { public void testMultiLevelChild() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "doc", + prepareCreate("test").setMapping( buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child", "child", "grandchild") ) ); @@ -166,9 +165,7 @@ public void testMultiLevelChild() throws Exception { // see #2744 public void test2744() throws IOException { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "foo", "test")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "foo", "test"))); ensureGreen(); // index simple data @@ -185,9 +182,7 @@ public void test2744() throws IOException { } public void testSimpleChildQuery() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); // index simple data @@ -251,9 +246,7 @@ public void testSimpleChildQuery() throws Exception { // Issue #3290 public void testCachingBugWithFqueryFilter() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); List builders = new ArrayList<>(); // index simple data @@ -290,9 +283,7 @@ public void testCachingBugWithFqueryFilter() throws Exception { } public void testHasParentFilter() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); Map> parentToChildren = new HashMap<>(); // Childless parent @@ -340,9 +331,7 @@ public void testHasParentFilter() throws Exception { } public void testSimpleChildQueryWithFlush() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); // index simple data with flushes, so we have many segments @@ -408,8 +397,7 @@ public void testSimpleChildQueryWithFlush() throws Exception { public void testScopedFacet() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "doc", + prepareCreate("test").setMapping( addFieldMappings(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"), "c_field", "keyword") ) ); @@ -459,9 +447,7 @@ public void testScopedFacet() throws Exception { } public void testDeletedParent() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); // index simple data createIndexRequest("test", "parent", "p1", null, "p_field", "p_value1").get(); @@ -496,9 +482,7 @@ public void testDeletedParent() throws Exception { } public void testDfsSearchType() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); // index simple data @@ -526,9 +510,7 @@ public void testDfsSearchType() throws Exception { } public void testHasChildAndHasParentFailWhenSomeSegmentsDontContainAnyParentOrChildDocs() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); createIndexRequest("test", "parent", "1", null, "p_field", 1).get(); @@ -551,9 +533,7 @@ public void testHasChildAndHasParentFailWhenSomeSegmentsDontContainAnyParentOrCh } public void testCountApiUsage() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); String parentId = "p1"; @@ -584,9 +564,7 @@ public void testCountApiUsage() throws Exception { } public void testExplainUsage() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); String parentId = "p1"; @@ -650,10 +628,8 @@ List createDocBuilders() { public void testScoreForParentChildQueriesWithFunctionScore() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "doc", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("doc") .startObject("properties") .startObject("join_field") .field("type", "join") @@ -663,7 +639,6 @@ public void testScoreForParentChildQueriesWithFunctionScore() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -758,9 +733,7 @@ public void testScoreForParentChildQueriesWithFunctionScore() throws Exception { // Issue #2536 public void testParentChildQueriesCanHandleNoRelevantTypesInIndex() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); SearchResponse response = client().prepareSearch("test") @@ -792,9 +765,7 @@ public void testParentChildQueriesCanHandleNoRelevantTypesInIndex() throws Excep } public void testHasChildAndHasParentFilter_withFilter() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); createIndexRequest("test", "parent", "1", null, "p_field", 1).get(); @@ -820,9 +791,7 @@ public void testHasChildAndHasParentFilter_withFilter() throws Exception { } public void testHasChildInnerHitsHighlighting() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); createIndexRequest("test", "parent", "1", null, "p_field", 1).get(); @@ -848,9 +817,7 @@ public void testHasChildInnerHitsHighlighting() throws Exception { } public void testHasChildAndHasParentWrappedInAQueryFilter() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); // query filter in case for p/c shouldn't execute per segment, but rather @@ -884,8 +851,7 @@ public void testHasChildAndHasParentWrappedInAQueryFilter() throws Exception { public void testSimpleQueryRewrite() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "doc", + prepareCreate("test").setMapping( addFieldMappings( buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"), "c_field", @@ -945,9 +911,7 @@ public void testSimpleQueryRewrite() throws Exception { // Issue #3144 public void testReIndexingParentAndChildDocuments() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); // index simple data @@ -1004,9 +968,7 @@ public void testReIndexingParentAndChildDocuments() throws Exception { // Issue #3203 public void testHasChildQueryWithMinimumScore() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); // index simple data @@ -1031,7 +993,7 @@ public void testHasChildQueryWithMinimumScore() throws Exception { public void testParentFieldQuery() throws Exception { assertAcked( prepareCreate("test").setSettings(Settings.builder().put("index.refresh_interval", -1)) - .addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) + .setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) ); ensureGreen(); @@ -1063,7 +1025,7 @@ public void testParentFieldQuery() throws Exception { public void testParentIdQuery() throws Exception { assertAcked( prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).put("index.refresh_interval", -1)) - .addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) + .setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) ); ensureGreen(); @@ -1083,9 +1045,7 @@ public void testParentIdQuery() throws Exception { } public void testHasChildNotBeingCached() throws IOException { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); // index simple data @@ -1146,10 +1106,8 @@ private QueryBuilder randomHasParent(String type, String field, String value) { // Issue #3818 public void testHasChildQueryOnlyReturnsSingleChildType() throws Exception { assertAcked( - prepareCreate("grandissue").addMapping( - "doc", + prepareCreate("grandissue").setMapping( jsonBuilder().startObject() - .startObject("doc") .startObject("properties") .startObject("join_field") .field("type", "join") @@ -1160,7 +1118,6 @@ public void testHasChildQueryOnlyReturnsSingleChildType() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -1203,8 +1160,7 @@ public void testHasChildQueryOnlyReturnsSingleChildType() throws Exception { public void testHasChildQueryWithNestedInnerObjects() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "doc", + prepareCreate("test").setMapping( addFieldMappings(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"), "objects", "nested") ) ); @@ -1282,9 +1238,7 @@ public void testHasChildQueryWithNestedInnerObjects() throws Exception { } public void testNamedFilters() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); String parentId = "p1"; @@ -1368,7 +1322,7 @@ public void testParentChildQueriesNoParentType() throws Exception { public void testParentChildCaching() throws Exception { assertAcked( prepareCreate("test").setSettings(Settings.builder().put("index.refresh_interval", -1)) - .addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) + .setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) ); ensureGreen(); @@ -1413,9 +1367,7 @@ public void testParentChildCaching() throws Exception { } public void testParentChildQueriesViaScrollApi() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); for (int i = 0; i < 10; i++) { createIndexRequest("test", "parent", "p" + i, null).get(); @@ -1496,9 +1448,7 @@ private SearchResponse minMaxQuery(ScoreMode scoreMode, int minChildren, Integer } public void testMinMaxChildren() throws Exception { - assertAcked( - prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); ensureGreen(); indexRandom(true, createMinMaxDocBuilders().toArray(new IndexRequestBuilder[0])); @@ -1811,10 +1761,7 @@ public void testMinMaxChildren() throws Exception { public void testHasParentInnerQueryType() { assertAcked( - prepareCreate("test").addMapping( - "doc", - buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent-type", "child-type") - ) + prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent-type", "child-type")) ); createIndexRequest("test", "child-type", "child-id", "parent-id").get(); createIndexRequest("test", "parent-type", "parent-id", null).get(); @@ -1834,8 +1781,7 @@ public void testHasParentInnerQueryType() { public void testHighlightersIgnoreParentChild() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "doc", + prepareCreate("test").setMapping( jsonBuilder().startObject() .startObject("properties") .startObject("join_field") @@ -1888,7 +1834,7 @@ public void testHighlightersIgnoreParentChild() throws IOException { public void testAliasesFilterWithHasChildQuery() throws Exception { assertAcked( - prepareCreate("my-index").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) + prepareCreate("my-index").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) ); createIndexRequest("my-index", "parent", "1", null).get(); createIndexRequest("my-index", "child", "2", "1").get(); diff --git a/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/query/InnerHitsIT.java b/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/query/InnerHitsIT.java index ed53b1643cc75..ffcc9cf38545f 100644 --- a/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/query/InnerHitsIT.java +++ b/modules/parent-join/src/internalClusterTest/java/org/opensearch/join/query/InnerHitsIT.java @@ -103,10 +103,8 @@ protected Map, Object>> pluginScripts() { public void testSimpleParentChild() throws Exception { assertAcked( - prepareCreate("articles").addMapping( - "doc", + prepareCreate("articles").setMapping( jsonBuilder().startObject() - .startObject("doc") .startObject("properties") .startObject("join_field") .field("type", "join") @@ -123,7 +121,6 @@ public void testSimpleParentChild() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -223,10 +220,8 @@ public void testSimpleParentChild() throws Exception { public void testRandomParentChild() throws Exception { assertAcked( - prepareCreate("idx").addMapping( - "doc", + prepareCreate("idx").setMapping( jsonBuilder().startObject() - .startObject("doc") .startObject("properties") .startObject("id") .field("type", "keyword") @@ -239,7 +234,6 @@ public void testRandomParentChild() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); int numDocs = scaledRandomIntBetween(5, 50); @@ -323,8 +317,7 @@ public void testRandomParentChild() throws Exception { public void testInnerHitsOnHasParent() throws Exception { assertAcked( - prepareCreate("stack").addMapping( - "doc", + prepareCreate("stack").setMapping( addFieldMappings(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "question", "answer"), "body", "text") ) ); @@ -379,8 +372,7 @@ public void testInnerHitsOnHasParent() throws Exception { public void testParentChildMultipleLayers() throws Exception { assertAcked( - prepareCreate("articles").addMapping( - "doc", + prepareCreate("articles").setMapping( addFieldMappings( buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "article", "comment", "comment", "remark"), "title", @@ -449,8 +441,7 @@ public void testParentChildMultipleLayers() throws Exception { public void testRoyals() throws Exception { assertAcked( - prepareCreate("royals").addMapping( - "doc", + prepareCreate("royals").setMapping( buildParentJoinFieldMappingFromSimplifiedDef( "join_field", true, @@ -536,9 +527,7 @@ public void testRoyals() throws Exception { } public void testMatchesQueriesParentChildInnerHits() throws Exception { - assertAcked( - prepareCreate("index").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) - ); + assertAcked(prepareCreate("index").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))); List requests = new ArrayList<>(); requests.add(createIndexRequest("index", "parent", "1", null)); requests.add(createIndexRequest("index", "child", "3", "1", "field", "value1")); @@ -577,7 +566,7 @@ public void testMatchesQueriesParentChildInnerHits() throws Exception { public void testUseMaxDocInsteadOfSize() throws Exception { assertAcked( - prepareCreate("index1").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) + prepareCreate("index1").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")) ); client().admin() .indices() @@ -599,8 +588,7 @@ public void testUseMaxDocInsteadOfSize() throws Exception { public void testNestedInnerHitWrappedInParentChildInnerhit() { assertAcked( - prepareCreate("test").addMapping( - "doc", + prepareCreate("test").setMapping( addFieldMappings( buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent_type", "child_type"), "nested_type", @@ -632,8 +620,7 @@ public void testNestedInnerHitWrappedInParentChildInnerhit() { public void testInnerHitsWithIgnoreUnmapped() { assertAcked( - prepareCreate("index1").addMapping( - "doc", + prepareCreate("index1").setMapping( addFieldMappings( buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent_type", "child_type"), "nested_type", @@ -662,8 +649,7 @@ public void testInnerHitsWithIgnoreUnmapped() { public void testTooHighResultWindow() { assertAcked( - prepareCreate("index1").addMapping( - "doc", + prepareCreate("index1").setMapping( addFieldMappings( buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent_type", "child_type"), "nested_type", diff --git a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java index 37c0eb051cd55..1cb5d81136de1 100644 --- a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java @@ -844,10 +844,8 @@ public void testManyPercolatorFields() throws Exception { client().admin() .indices() .prepareCreate("test3") - .addMapping( - "type", + .setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("field") .field("type", "keyword") @@ -862,7 +860,6 @@ public void testManyPercolatorFields() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); } @@ -876,10 +873,8 @@ public void testWithMultiplePercolatorFields() throws Exception { client().admin() .indices() .prepareCreate("test2") - .addMapping( - "type", + .setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("field") .field("type", "keyword") @@ -894,7 +889,6 @@ public void testWithMultiplePercolatorFields() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -977,7 +971,7 @@ public void testPercolateQueryWithNestedDocuments() throws Exception { .endObject() .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate("test").addMapping("employee", mapping)); + assertAcked(client().admin().indices().prepareCreate("test").setMapping(mapping)); client().prepareIndex("test") .setId("q1") .setSource( diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java index e212ad6630e9a..d3da99ffbc102 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java @@ -150,7 +150,7 @@ public void testPercolateQueryWithNestedDocuments_doNotLeakBitsetCacheEntries() .prepareCreate("test") // to avoid normal document from being cached by BitsetFilterCache .setSettings(Settings.builder().put(BitsetFilterCache.INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING.getKey(), false)) - .addMapping("employee", mapping) + .setMapping(mapping) ); client().prepareIndex("test") .setId("q1") @@ -238,7 +238,7 @@ public void testPercolateQueryWithNestedDocuments_doLeakFieldDataCacheEntries() mapping.endObject(); } mapping.endObject(); - createIndex("test", client().admin().indices().prepareCreate("test").addMapping("employee", mapping)); + createIndex("test", client().admin().indices().prepareCreate("test").setMapping(mapping)); Script script = new Script(ScriptType.INLINE, MockScriptPlugin.NAME, "use_fielddata_please", Collections.emptyMap()); client().prepareIndex("test") .setId("q1") diff --git a/plugins/analysis-icu/src/internalClusterTest/java/org/opensearch/index/mapper/ICUCollationKeywordFieldMapperIT.java b/plugins/analysis-icu/src/internalClusterTest/java/org/opensearch/index/mapper/ICUCollationKeywordFieldMapperIT.java index 46b9c45b9cf82..4735f39033081 100644 --- a/plugins/analysis-icu/src/internalClusterTest/java/org/opensearch/index/mapper/ICUCollationKeywordFieldMapperIT.java +++ b/plugins/analysis-icu/src/internalClusterTest/java/org/opensearch/index/mapper/ICUCollationKeywordFieldMapperIT.java @@ -71,8 +71,6 @@ protected Collection> nodePlugins() { */ public void testBasicUsage() throws Exception { String index = "foo"; - String type = "mytype"; - String[] equivalent = { "I WİLL USE TURKİSH CASING", "ı will use turkish casıng" }; XContentBuilder builder = jsonBuilder().startObject() @@ -88,7 +86,7 @@ public void testBasicUsage() throws Exception { .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder)); + assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder)); // both values should collate to same value indexRandom( @@ -114,7 +112,6 @@ public void testBasicUsage() throws Exception { public void testMultipleValues() throws Exception { String index = "foo"; - String type = "mytype"; String[] equivalent = { "a", "C", "a", "B" }; @@ -130,7 +127,7 @@ public void testMultipleValues() throws Exception { .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder)); + assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder)); // everything should be indexed fine, no exceptions indexRandom( @@ -177,7 +174,6 @@ public void testMultipleValues() throws Exception { */ public void testNormalization() throws Exception { String index = "foo"; - String type = "mytype"; String[] equivalent = { "I W\u0049\u0307LL USE TURKİSH CASING", "ı will use turkish casıng" }; @@ -195,7 +191,7 @@ public void testNormalization() throws Exception { .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder)); + assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder)); indexRandom( true, @@ -223,7 +219,6 @@ public void testNormalization() throws Exception { */ public void testSecondaryStrength() throws Exception { String index = "foo"; - String type = "mytype"; String[] equivalent = { "TESTING", "testing" }; @@ -241,7 +236,7 @@ public void testSecondaryStrength() throws Exception { .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder)); + assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder)); indexRandom( true, @@ -269,7 +264,6 @@ public void testSecondaryStrength() throws Exception { */ public void testIgnorePunctuation() throws Exception { String index = "foo"; - String type = "mytype"; String[] equivalent = { "foo-bar", "foo bar" }; @@ -287,7 +281,7 @@ public void testIgnorePunctuation() throws Exception { .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder)); + assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder)); indexRandom( true, @@ -315,7 +309,6 @@ public void testIgnorePunctuation() throws Exception { */ public void testIgnoreWhitespace() throws Exception { String index = "foo"; - String type = "mytype"; XContentBuilder builder = jsonBuilder().startObject() .startObject("properties") @@ -333,7 +326,7 @@ public void testIgnoreWhitespace() throws Exception { .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder)); + assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder)); indexRandom( true, @@ -363,7 +356,6 @@ public void testIgnoreWhitespace() throws Exception { */ public void testNumerics() throws Exception { String index = "foo"; - String type = "mytype"; XContentBuilder builder = jsonBuilder().startObject() .startObject("properties") @@ -376,7 +368,7 @@ public void testNumerics() throws Exception { .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder)); + assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder)); indexRandom( true, @@ -399,7 +391,6 @@ public void testNumerics() throws Exception { */ public void testIgnoreAccentsButNotCase() throws Exception { String index = "foo"; - String type = "mytype"; XContentBuilder builder = jsonBuilder().startObject() .startObject("properties") @@ -416,7 +407,7 @@ public void testIgnoreAccentsButNotCase() throws Exception { .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder)); + assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder)); indexRandom( true, @@ -441,7 +432,6 @@ public void testIgnoreAccentsButNotCase() throws Exception { */ public void testUpperCaseFirst() throws Exception { String index = "foo"; - String type = "mytype"; XContentBuilder builder = jsonBuilder().startObject() .startObject("properties") @@ -455,7 +445,7 @@ public void testUpperCaseFirst() throws Exception { .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder)); + assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder)); indexRandom( true, @@ -481,7 +471,6 @@ public void testUpperCaseFirst() throws Exception { */ public void testCustomRules() throws Exception { String index = "foo"; - String type = "mytype"; RuleBasedCollator baseCollator = (RuleBasedCollator) Collator.getInstance(new ULocale("de_DE")); String DIN5007_2_tailorings = "& ae , a\u0308 & AE , A\u0308" + "& oe , o\u0308 & OE , O\u0308" + "& ue , u\u0308 & UE , u\u0308"; @@ -504,7 +493,7 @@ public void testCustomRules() throws Exception { .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder)); + assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder)); indexRandom( true, diff --git a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java index 2cf05da26c193..375222cd2af44 100644 --- a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java +++ b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java @@ -63,10 +63,9 @@ protected Collection> nodePlugins() { // issue 5053 public void testThatUpdatingMappingShouldNotRemoveSizeMappingConfiguration() throws Exception { String index = "foo"; - String type = MapperService.SINGLE_MAPPING_NAME; XContentBuilder builder = jsonBuilder().startObject().startObject("_size").field("enabled", true).endObject().endObject(); - assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder)); + assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder)); // check mapping again assertSizeMappingEnabled(index, true); @@ -88,10 +87,9 @@ public void testThatUpdatingMappingShouldNotRemoveSizeMappingConfiguration() thr public void testThatSizeCanBeSwitchedOnAndOff() throws Exception { String index = "foo"; - String type = MapperService.SINGLE_MAPPING_NAME; XContentBuilder builder = jsonBuilder().startObject().startObject("_size").field("enabled", true).endObject().endObject(); - assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder)); + assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder)); // check mapping again assertSizeMappingEnabled(index, true); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java index 476bd72ee3ca3..3ef2a63c7d0ac 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/CreateIndexIT.java @@ -110,8 +110,7 @@ public void testCreationDateGenerated() { public void testNonNestedMappings() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "_doc", + prepareCreate("test").setMapping( XContentFactory.jsonBuilder() .startObject() .startObject("properties") @@ -131,7 +130,7 @@ public void testNonNestedMappings() throws Exception { } public void testEmptyNestedMappings() throws Exception { - assertAcked(prepareCreate("test").addMapping("_doc", XContentFactory.jsonBuilder().startObject().endObject())); + assertAcked(prepareCreate("test").setMapping(XContentFactory.jsonBuilder().startObject().endObject())); GetMappingsResponse response = client().admin().indices().prepareGetMappings("test").get(); @@ -144,10 +143,8 @@ public void testEmptyNestedMappings() throws Exception { public void testMappingParamAndNestedMismatch() throws Exception { MapperParsingException e = expectThrows( MapperParsingException.class, - () -> prepareCreate("test").addMapping( - MapperService.SINGLE_MAPPING_NAME, - XContentFactory.jsonBuilder().startObject().startObject("type2").endObject().endObject() - ).get() + () -> prepareCreate("test").setMapping(XContentFactory.jsonBuilder().startObject().startObject("type2").endObject().endObject()) + .get() ); assertThat( e.getMessage(), @@ -159,10 +156,7 @@ public void testMappingParamAndNestedMismatch() throws Exception { public void testEmptyMappings() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "_doc", - XContentFactory.jsonBuilder().startObject().startObject("_doc").endObject().endObject() - ) + prepareCreate("test").setMapping(XContentFactory.jsonBuilder().startObject().startObject("_doc").endObject().endObject()) ); GetMappingsResponse response = client().admin().indices().prepareGetMappings("test").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java b/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java index d28dcbb924f95..8ab6450ead2af 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java @@ -88,7 +88,7 @@ public void testNoSuchDoc() throws Exception { .endObject() .endObject() .endObject(); - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1", mapping)); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping(mapping)); client().prepareIndex("test").setId("667").setSource("field", "foo bar").execute().actionGet(); refresh(); @@ -105,16 +105,14 @@ public void testNoSuchDoc() throws Exception { public void testExistingFieldWithNoTermVectorsNoNPE() throws Exception { XContentBuilder mapping = jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("existingfield") .field("type", "text") .field("term_vector", "with_positions_offsets_payloads") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1", mapping)); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping(mapping)); // when indexing a field that simply has a question mark, the term vectors will be null client().prepareIndex("test").setId("0").setSource("existingfield", "?").execute().actionGet(); @@ -133,16 +131,14 @@ public void testExistingFieldWithNoTermVectorsNoNPE() throws Exception { public void testExistingFieldButNotInDocNPE() throws Exception { XContentBuilder mapping = jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("existingfield") .field("type", "text") .field("term_vector", "with_positions_offsets_payloads") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1", mapping)); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping(mapping)); // when indexing a field that simply has a question mark, the term vectors will be null client().prepareIndex("test").setId("0").setSource("anotherexistingfield", 1).execute().actionGet(); @@ -205,7 +201,6 @@ public void testNotIndexedField() throws Exception { public void testSimpleTermVectors() throws IOException { XContentBuilder mapping = jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("field") .field("type", "text") @@ -213,10 +208,9 @@ public void testSimpleTermVectors() throws IOException { .field("analyzer", "tv_test") .endObject() .endObject() - .endObject() .endObject(); assertAcked( - prepareCreate("test").addMapping("type1", mapping) + prepareCreate("test").setMapping(mapping) .addAlias(new Alias("alias")) .setSettings( Settings.builder() @@ -316,7 +310,6 @@ public void testRandomSingleTermVectors() throws IOException { String optionString = termVectorOptionsToString(ft); XContentBuilder mapping = jsonBuilder().startObject() - .startObject("_doc") .startObject("properties") .startObject("field") .field("type", "text") @@ -324,10 +317,9 @@ public void testRandomSingleTermVectors() throws IOException { .field("analyzer", "tv_test") .endObject() .endObject() - .endObject() .endObject(); assertAcked( - prepareCreate("test").addMapping("_doc", mapping) + prepareCreate("test").setMapping(mapping) .setSettings( Settings.builder() .put("index.analysis.analyzer.tv_test.tokenizer", "standard") @@ -466,7 +458,7 @@ public void testSimpleTermVectorsWithGenerate() throws IOException { fieldNames[i] = "field" + String.valueOf(i); } - XContentBuilder mapping = jsonBuilder().startObject().startObject("type1").startObject("properties"); + XContentBuilder mapping = jsonBuilder().startObject().startObject("properties"); XContentBuilder source = jsonBuilder().startObject(); for (String field : fieldNames) { mapping.startObject(field) @@ -476,11 +468,11 @@ public void testSimpleTermVectorsWithGenerate() throws IOException { .endObject(); source.field(field, "the quick brown fox jumps over the lazy dog"); } - mapping.endObject().endObject().endObject(); + mapping.endObject().endObject(); source.endObject(); assertAcked( - prepareCreate("test").addMapping("type1", mapping) + prepareCreate("test").setMapping(mapping) .setSettings( Settings.builder() .put(indexSettings()) @@ -640,16 +632,16 @@ private void compareTermVectors(String fieldName, Fields fields0, Fields fields1 public void testSimpleWildCards() throws IOException { int numFields = 25; - XContentBuilder mapping = jsonBuilder().startObject().startObject("type1").startObject("properties"); + XContentBuilder mapping = jsonBuilder().startObject().startObject("properties"); XContentBuilder source = jsonBuilder().startObject(); for (int i = 0; i < numFields; i++) { mapping.startObject("field" + i).field("type", "text").field("term_vector", randomBoolean() ? "yes" : "no").endObject(); source.field("field" + i, "some text here"); } source.endObject(); - mapping.endObject().endObject().endObject(); + mapping.endObject().endObject(); - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1", mapping)); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping(mapping)); ensureGreen(); client().prepareIndex("test").setId("0").setSource(source).get(); @@ -744,7 +736,7 @@ public void testPerFieldAnalyzer() throws IOException { // setup mapping and document source Set withTermVectors = new HashSet<>(); - XContentBuilder mapping = jsonBuilder().startObject().startObject("type1").startObject("properties"); + XContentBuilder mapping = jsonBuilder().startObject().startObject("properties"); XContentBuilder source = jsonBuilder().startObject(); for (int i = 0; i < numFields; i++) { String fieldName = "field" + i; @@ -758,11 +750,11 @@ public void testPerFieldAnalyzer() throws IOException { source.field(fieldName, "some text here"); } source.endObject(); - mapping.endObject().endObject().endObject(); + mapping.endObject().endObject(); // setup indices with mapping Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "standard"); - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSettings(settings).addMapping("type1", mapping)); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSettings(settings).setMapping(mapping)); ensureGreen(); // index a single document with prepared source diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleClusterStateIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleClusterStateIT.java index 93a903e0b5e0c..fcf5dcf3891ce 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleClusterStateIT.java @@ -261,7 +261,7 @@ public void testLargeClusterStatePublishing() throws Exception { ByteSizeValue.parseBytesSizeValue("10k", "estimatedBytesSize").bytesAsInt(), ByteSizeValue.parseBytesSizeValue("256k", "estimatedBytesSize").bytesAsInt() ); - XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties"); + XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties"); int counter = 0; int numberOfFields = 0; while (true) { @@ -273,7 +273,7 @@ public void testLargeClusterStatePublishing() throws Exception { } } logger.info("number of fields [{}], estimated bytes [{}]", numberOfFields, estimatedBytesSize); - mapping.endObject().endObject().endObject(); + mapping.endObject().endObject(); int numberOfShards = scaledRandomIntBetween(1, cluster().numDataNodes()); // if the create index is ack'ed, then all nodes have successfully processed the cluster state @@ -287,7 +287,7 @@ public void testLargeClusterStatePublishing() throws Exception { .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), Long.MAX_VALUE) ) - .addMapping("type", mapping) + .setMapping(mapping) .setTimeout("60s") .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/gateway/GatewayIndexStateIT.java b/server/src/internalClusterTest/java/org/opensearch/gateway/GatewayIndexStateIT.java index 24aff104ce837..a8828c7ad38b5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/gateway/GatewayIndexStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/gateway/GatewayIndexStateIT.java @@ -105,10 +105,7 @@ public void testMappingMetadataParsed() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping( - "type1", - XContentFactory.jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject() - ) + .setMapping(XContentFactory.jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject()) .execute() .actionGet(); diff --git a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java index ec0b47ccd0ecf..a09778582b604 100644 --- a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java @@ -541,10 +541,8 @@ public void testMultiGetWithVersion() throws Exception { public void testGetFieldsNonLeafField() throws Exception { assertAcked( prepareCreate("test").addAlias(new Alias("alias")) - .addMapping( - "my-type1", + .setMapping( jsonBuilder().startObject() - .startObject("my-type1") .startObject("properties") .startObject("field1") .startObject("properties") @@ -555,7 +553,6 @@ public void testGetFieldsNonLeafField() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .setSettings(Settings.builder().put("index.refresh_interval", -1)) ); @@ -582,10 +579,8 @@ public void testGetFieldsComplexField() throws Exception { prepareCreate("my-index") // multi types in 5.6 .setSettings(Settings.builder().put("index.refresh_interval", -1)) - .addMapping( - "my-type", + .setMapping( jsonBuilder().startObject() - .startObject("my-type") .startObject("properties") .startObject("field1") .field("type", "object") @@ -608,7 +603,6 @@ public void testGetFieldsComplexField() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/IndexSortIT.java b/server/src/internalClusterTest/java/org/opensearch/index/IndexSortIT.java index c0bc9d29af992..69eb34c39c10c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/IndexSortIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/IndexSortIT.java @@ -92,7 +92,7 @@ public void testIndexSort() { .put("index.number_of_shards", "1") .put("index.number_of_replicas", "1") .putList("index.sort.field", "date", "numeric_dv", "keyword_dv") - ).addMapping("test", TEST_MAPPING).get(); + ).setMapping(TEST_MAPPING).get(); for (int i = 0; i < 20; i++) { client().prepareIndex("test") .setId(Integer.toString(i)) @@ -108,7 +108,7 @@ public void testInvalidIndexSort() { IllegalArgumentException exc = expectThrows( IllegalArgumentException.class, () -> prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).putList("index.sort.field", "invalid_field")) - .addMapping("test", TEST_MAPPING) + .setMapping(TEST_MAPPING) .get() ); assertThat(exc.getMessage(), containsString("unknown index sort field:[invalid_field]")); @@ -116,7 +116,7 @@ public void testInvalidIndexSort() { exc = expectThrows( IllegalArgumentException.class, () -> prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).putList("index.sort.field", "numeric")) - .addMapping("test", TEST_MAPPING) + .setMapping(TEST_MAPPING) .get() ); assertThat(exc.getMessage(), containsString("docvalues not found for index sort field:[numeric]")); @@ -124,7 +124,7 @@ public void testInvalidIndexSort() { exc = expectThrows( IllegalArgumentException.class, () -> prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).putList("index.sort.field", "keyword")) - .addMapping("test", TEST_MAPPING) + .setMapping(TEST_MAPPING) .get() ); assertThat(exc.getMessage(), containsString("docvalues not found for index sort field:[keyword]")); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/fielddata/FieldDataLoadingIT.java b/server/src/internalClusterTest/java/org/opensearch/index/fielddata/FieldDataLoadingIT.java index 0aa2abed14b79..51e2cf669cbfb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/fielddata/FieldDataLoadingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/fielddata/FieldDataLoadingIT.java @@ -43,10 +43,8 @@ public class FieldDataLoadingIT extends OpenSearchIntegTestCase { public void testEagerGlobalOrdinalsFieldDataLoading() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("name") .field("type", "text") @@ -55,7 +53,6 @@ public void testEagerGlobalOrdinalsFieldDataLoading() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/mapper/CopyToMapperIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/index/mapper/CopyToMapperIntegrationIT.java index f23e319a5e8d2..d4733e4f31cb2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/mapper/CopyToMapperIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/mapper/CopyToMapperIntegrationIT.java @@ -50,7 +50,7 @@ public class CopyToMapperIntegrationIT extends OpenSearchIntegTestCase { public void testDynamicTemplateCopyTo() throws Exception { - assertAcked(client().admin().indices().prepareCreate("test-idx").addMapping("_doc", createDynamicTemplateMapping())); + assertAcked(client().admin().indices().prepareCreate("test-idx").setMapping(createDynamicTemplateMapping())); int recordCount = between(1, 200); @@ -98,7 +98,6 @@ public void testDynamicObjectCopyTo() throws Exception { private XContentBuilder createDynamicTemplateMapping() throws IOException { return XContentFactory.jsonBuilder() .startObject() - .startObject("_doc") .startArray("dynamic_templates") .startObject() @@ -124,7 +123,6 @@ private XContentBuilder createDynamicTemplateMapping() throws IOException { .endObject() .endArray() - .endObject() .endObject(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/index/mapper/ExternalValuesMapperIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/index/mapper/ExternalValuesMapperIntegrationIT.java index 2251ec62f5c15..138081e56dd63 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/mapper/ExternalValuesMapperIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/mapper/ExternalValuesMapperIntegrationIT.java @@ -55,18 +55,15 @@ protected Collection> nodePlugins() { } public void testHighlightingOnCustomString() throws Exception { - prepareCreate("test-idx").addMapping( - "type", + prepareCreate("test-idx").setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("field") .field("type", FakeStringFieldMapper.CONTENT_TYPE) .endObject() .endObject() .endObject() - .endObject() ).execute().get(); index( @@ -118,11 +115,9 @@ public void testHighlightingOnCustomString() throws Exception { } public void testExternalValues() throws Exception { - prepareCreate("test-idx").addMapping( - "type", + prepareCreate("test-idx").setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject(ExternalMetadataMapper.CONTENT_TYPE) .endObject() .startObject("properties") @@ -131,7 +126,6 @@ public void testExternalValues() throws Exception { .endObject() .endObject() .endObject() - .endObject() ).execute().get(); index("test-idx", "type", "1", XContentFactory.jsonBuilder().startObject().field("field", "1234").endObject()); @@ -166,11 +160,9 @@ public void testExternalValues() throws Exception { } public void testExternalValuesWithMultifield() throws Exception { - prepareCreate("test-idx").addMapping( - "_doc", + prepareCreate("test-idx").setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("_doc") .startObject("properties") .startObject("f") .field("type", ExternalMapperPlugin.EXTERNAL_UPPER) @@ -189,7 +181,6 @@ public void testExternalValuesWithMultifield() throws Exception { .endObject() .endObject() .endObject() - .endObject() ).execute().get(); index("test-idx", "_doc", "1", "f", "This is my text"); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/mapper/MultiFieldsIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/index/mapper/MultiFieldsIntegrationIT.java index 37fa8cdd11a8b..7dbb6a45b857d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/mapper/MultiFieldsIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/mapper/MultiFieldsIntegrationIT.java @@ -58,7 +58,7 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase { @SuppressWarnings("unchecked") public void testMultiFields() throws Exception { - assertAcked(client().admin().indices().prepareCreate("my-index").addMapping("my-type", createTypeSource())); + assertAcked(client().admin().indices().prepareCreate("my-index").setMapping(createTypeSource())); GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get(); MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index"); @@ -98,7 +98,7 @@ public void testMultiFields() throws Exception { @SuppressWarnings("unchecked") public void testGeoPointMultiField() throws Exception { - assertAcked(client().admin().indices().prepareCreate("my-index").addMapping("my-type", createMappingSource("geo_point"))); + assertAcked(client().admin().indices().prepareCreate("my-index").setMapping(createMappingSource("geo_point"))); GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get(); MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index"); @@ -127,7 +127,7 @@ public void testGeoPointMultiField() throws Exception { @SuppressWarnings("unchecked") public void testCompletionMultiField() throws Exception { - assertAcked(client().admin().indices().prepareCreate("my-index").addMapping("my-type", createMappingSource("completion"))); + assertAcked(client().admin().indices().prepareCreate("my-index").setMapping(createMappingSource("completion"))); GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get(); MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index"); @@ -149,7 +149,7 @@ public void testCompletionMultiField() throws Exception { @SuppressWarnings("unchecked") public void testIpMultiField() throws Exception { - assertAcked(client().admin().indices().prepareCreate("my-index").addMapping("my-type", createMappingSource("ip"))); + assertAcked(client().admin().indices().prepareCreate("my-index").setMapping(createMappingSource("ip"))); GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get(); MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index"); @@ -172,7 +172,6 @@ public void testIpMultiField() throws Exception { private XContentBuilder createMappingSource(String fieldType) throws IOException { return XContentFactory.jsonBuilder() .startObject() - .startObject("my-type") .startObject("properties") .startObject("a") .field("type", fieldType) @@ -183,14 +182,12 @@ private XContentBuilder createMappingSource(String fieldType) throws IOException .endObject() .endObject() .endObject() - .endObject() .endObject(); } private XContentBuilder createTypeSource() throws IOException { return XContentFactory.jsonBuilder() .startObject() - .startObject("my-type") .startObject("properties") .startObject("title") .field("type", "text") @@ -201,7 +198,6 @@ private XContentBuilder createTypeSource() throws IOException { .endObject() .endObject() .endObject() - .endObject() .endObject(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java index d38fbfa1a51e1..a857f6cf6e96c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java @@ -78,18 +78,16 @@ public void testThatPreBuiltAnalyzersAreNotClosedOnIndexClose() throws Exception loadedAnalyzers.get(preBuiltAnalyzer).add(randomVersion); final XContentBuilder mapping = jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("foo") .field("type", "text") .field("analyzer", name) .endObject() .endObject() - .endObject() .endObject(); Settings versionSettings = settings(randomVersion).build(); - client().admin().indices().prepareCreate(indexName).addMapping("type", mapping).setSettings(versionSettings).get(); + client().admin().indices().prepareCreate(indexName).setMapping(mapping).setSettings(versionSettings).get(); } ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/SimpleGetFieldMappingsIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/SimpleGetFieldMappingsIT.java index 92a65f43361d6..3de2001acd1e7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/SimpleGetFieldMappingsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/SimpleGetFieldMappingsIT.java @@ -80,9 +80,8 @@ public void testGetMappingsWhereThereAreNone() { assertThat(response.fieldMappings("index", "field"), nullValue()); } - private XContentBuilder getMappingForType(String type) throws IOException { + private XContentBuilder getMappingForType() throws IOException { return jsonBuilder().startObject() - .startObject(type) .startObject("properties") .startObject("field1") .field("type", "text") @@ -99,14 +98,13 @@ private XContentBuilder getMappingForType(String type) throws IOException { .endObject() .endObject() .endObject() - .endObject() .endObject(); } public void testGetFieldMappings() throws Exception { - assertAcked(prepareCreate("indexa").addMapping("typeA", getMappingForType("typeA"))); - assertAcked(client().admin().indices().prepareCreate("indexb").addMapping("typeB", getMappingForType("typeB"))); + assertAcked(prepareCreate("indexa").setMapping(getMappingForType())); + assertAcked(client().admin().indices().prepareCreate("indexb").setMapping(getMappingForType())); // Get mappings by full name GetFieldMappingsResponse response = client().admin() @@ -136,7 +134,7 @@ public void testGetFieldMappings() throws Exception { @SuppressWarnings("unchecked") public void testSimpleGetFieldMappingsWithDefaults() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", getMappingForType("type"))); + assertAcked(prepareCreate("test").setMapping(getMappingForType())); client().admin().indices().preparePutMapping("test").setSource("num", "type=long").get(); client().admin().indices().preparePutMapping("test").setSource("field2", "type=text,index=false").get(); @@ -163,7 +161,7 @@ public void testSimpleGetFieldMappingsWithDefaults() throws Exception { @SuppressWarnings("unchecked") public void testGetFieldMappingsWithFieldAlias() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", getMappingForType("type"))); + assertAcked(prepareCreate("test").setMapping(getMappingForType())); GetFieldMappingsResponse response = client().admin().indices().prepareGetFieldMappings().setFields("alias", "field1").get(); @@ -179,7 +177,7 @@ public void testGetFieldMappingsWithFieldAlias() throws Exception { // fix #6552 public void testSimpleGetFieldMappingsWithPretty() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", getMappingForType("type"))); + assertAcked(prepareCreate("index").setMapping(getMappingForType())); Map params = new HashMap<>(); params.put("pretty", "true"); GetFieldMappingsResponse response = client().admin() @@ -209,7 +207,7 @@ public void testSimpleGetFieldMappingsWithPretty() throws Exception { } public void testGetFieldMappingsWithBlocks() throws Exception { - assertAcked(prepareCreate("test").addMapping("_doc", getMappingForType("_doc"))); + assertAcked(prepareCreate("test").setMapping(getMappingForType())); for (String block : Arrays.asList(SETTING_BLOCKS_READ, SETTING_BLOCKS_WRITE, SETTING_READ_ONLY)) { try { diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/SimpleGetMappingsIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/SimpleGetMappingsIT.java index aac12522afa2f..f54e60a8baa88 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/SimpleGetMappingsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/SimpleGetMappingsIT.java @@ -70,21 +70,19 @@ public void testGetMappingsWhereThereAreNone() { assertEquals(MappingMetadata.EMPTY_MAPPINGS, response.mappings().get("index")); } - private XContentBuilder getMappingForType(String type) throws IOException { + private XContentBuilder getMappingForType() throws IOException { return jsonBuilder().startObject() - .startObject(type) .startObject("properties") .startObject("field1") .field("type", "text") .endObject() .endObject() - .endObject() .endObject(); } public void testSimpleGetMappings() throws Exception { - client().admin().indices().prepareCreate("indexa").addMapping("typeA", getMappingForType("typeA")).execute().actionGet(); - client().admin().indices().prepareCreate("indexb").addMapping("typeA", getMappingForType("typeA")).execute().actionGet(); + client().admin().indices().prepareCreate("indexa").setMapping(getMappingForType()).execute().actionGet(); + client().admin().indices().prepareCreate("indexb").setMapping(getMappingForType()).execute().actionGet(); ClusterHealthResponse clusterHealth = client().admin() .cluster() @@ -114,7 +112,7 @@ public void testSimpleGetMappings() throws Exception { } public void testGetMappingsWithBlocks() throws IOException { - client().admin().indices().prepareCreate("test").addMapping("_doc", getMappingForType("_doc")).execute().actionGet(); + client().admin().indices().prepareCreate("test").setMapping(getMappingForType()).execute().actionGet(); ensureGreen(); for (String block : Arrays.asList(SETTING_BLOCKS_READ, SETTING_BLOCKS_WRITE, SETTING_READ_ONLY)) { diff --git a/server/src/internalClusterTest/java/org/opensearch/mget/SimpleMgetIT.java b/server/src/internalClusterTest/java/org/opensearch/mget/SimpleMgetIT.java index 5b78c5686dc6a..c9d18e64ca038 100644 --- a/server/src/internalClusterTest/java/org/opensearch/mget/SimpleMgetIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/mget/SimpleMgetIT.java @@ -129,16 +129,7 @@ public void testThatMgetShouldWorkWithMultiIndexAlias() throws IOException { public void testThatMgetShouldWorkWithAliasRouting() throws IOException { assertAcked( prepareCreate("test").addAlias(new Alias("alias1").routing("abc")) - .addMapping( - "test", - jsonBuilder().startObject() - .startObject("test") - .startObject("_routing") - .field("required", true) - .endObject() - .endObject() - .endObject() - ) + .setMapping(jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject()) ); client().prepareIndex("alias1") diff --git a/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java b/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java index f3179a0c4acb3..8909b9deece9b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java @@ -351,17 +351,7 @@ public void testRequiredRoutingCrudApis() throws Exception { .indices() .prepareCreate("test") .addAlias(new Alias("alias")) - .addMapping( - "type1", - XContentFactory.jsonBuilder() - .startObject() - .startObject("type1") - .startObject("_routing") - .field("required", true) - .endObject() - .endObject() - .endObject() - ) + .setMapping(XContentFactory.jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject()) .execute() .actionGet(); ensureGreen(); @@ -450,17 +440,7 @@ public void testRequiredRoutingBulk() throws Exception { .indices() .prepareCreate("test") .addAlias(new Alias("alias")) - .addMapping( - "type1", - XContentFactory.jsonBuilder() - .startObject() - .startObject("type1") - .startObject("_routing") - .field("required", true) - .endObject() - .endObject() - .endObject() - ) + .setMapping(XContentFactory.jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject()) .execute() .actionGet(); ensureGreen(); @@ -544,17 +524,7 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { .indices() .prepareCreate("test") .addAlias(new Alias("alias")) - .addMapping( - "type1", - XContentFactory.jsonBuilder() - .startObject() - .startObject("type1") - .startObject("_routing") - .field("required", true) - .endObject() - .endObject() - .endObject() - ) + .setMapping(XContentFactory.jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject()) .execute() .actionGet(); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/CombiIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/CombiIT.java index f49938fb27e72..c5794c76e21de 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/CombiIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/CombiIT.java @@ -115,10 +115,8 @@ public void testMultipleAggsOnSameField_WithDifferentRequiredValueSourceType() t */ public void testSubAggregationForTopAggregationOnUnmappedField() throws Exception { - prepareCreate("idx").addMapping( - "type", + prepareCreate("idx").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("name") .field("type", "keyword") @@ -128,7 +126,6 @@ public void testSubAggregationForTopAggregationOnUnmappedField() throws Exceptio .endObject() .endObject() .endObject() - .endObject() ).get(); ensureSearchable("idx"); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/EquivalenceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/EquivalenceIT.java index 29c325d01492e..d03b10ce092c9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/EquivalenceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/EquivalenceIT.java @@ -133,17 +133,14 @@ public void testRandomRanges() throws Exception { } } - prepareCreate("idx").addMapping( - "type", + prepareCreate("idx").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("values") .field("type", "double") .endObject() .endObject() .endObject() - .endObject() ).get(); for (int i = 0; i < docs.length; ++i) { @@ -235,10 +232,8 @@ public void testDuelTerms() throws Exception { final IntHashSet valuesSet = new IntHashSet(); cluster().wipeIndices("idx"); - prepareCreate("idx").addMapping( - "type", + prepareCreate("idx").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("num") .field("type", "double") @@ -260,7 +255,6 @@ public void testDuelTerms() throws Exception { .endObject() .endObject() .endObject() - .endObject() ).get(); List indexingRequests = new ArrayList<>(); @@ -358,17 +352,14 @@ public void testDuelTerms() throws Exception { // Duel between histograms and scripted terms public void testDuelTermsHistogram() throws Exception { - prepareCreate("idx").addMapping( - "type", + prepareCreate("idx").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("num") .field("type", "double") .endObject() .endObject() .endObject() - .endObject() ).get(); final int numDocs = scaledRandomIntBetween(500, 5000); @@ -422,17 +413,14 @@ public void testDuelTermsHistogram() throws Exception { public void testLargeNumbersOfPercentileBuckets() throws Exception { // test high numbers of percentile buckets to make sure paging and release work correctly - prepareCreate("idx").addMapping( - "type", + prepareCreate("idx").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("double_value") .field("type", "double") .endObject() .endObject() .endObject() - .endObject() ).get(); final int numDocs = scaledRandomIntBetween(2500, 5000); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java index 256281f8c6833..969a48b514f1a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java @@ -158,10 +158,8 @@ public void setupSuiteScopeCluster() throws Exception { } assertAcked( - prepareCreate("idx_nested_nested_aggs").addMapping( - "type", + prepareCreate("idx_nested_nested_aggs").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("nested1") .field("type", "nested") @@ -173,7 +171,6 @@ public void setupSuiteScopeCluster() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen("idx_nested_nested_aggs"); @@ -400,7 +397,6 @@ public void testNestedOnObjectField() throws Exception { // Test based on: https://github.com/elastic/elasticsearch/issues/9280 public void testParentFilterResolvedCorrectly() throws Exception { XContentBuilder mapping = jsonBuilder().startObject() - .startObject("provider") .startObject("properties") .startObject("comments") .field("type", "nested") @@ -450,11 +446,10 @@ public void testParentFilterResolvedCorrectly() throws Exception { .endObject() .endObject() .endObject() - .endObject() .endObject(); assertAcked( prepareCreate("idx2").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping("provider", mapping) + .setMapping(mapping) ); ensureGreen("idx2"); @@ -649,10 +644,8 @@ public void testNestedSameDocIdProcessedMultipleTime() throws Exception { public void testFilterAggInsideNestedAgg() throws Exception { assertAcked( - prepareCreate("classes").addMapping( - "class", + prepareCreate("classes").setMapping( jsonBuilder().startObject() - .startObject("class") .startObject("properties") .startObject("name") .field("type", "text") @@ -681,7 +674,6 @@ public void testFilterAggInsideNestedAgg() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ReverseNestedIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ReverseNestedIT.java index e8a57ea3941ff..67ae145aece11 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ReverseNestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ReverseNestedIT.java @@ -75,8 +75,7 @@ public class ReverseNestedIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { assertAcked( - prepareCreate("idx1").addMapping( - "type", + prepareCreate("idx1").setMapping( jsonBuilder().startObject() .startObject("properties") .startObject("field1") @@ -99,8 +98,7 @@ public void setupSuiteScopeCluster() throws Exception { ) ); assertAcked( - prepareCreate("idx2").addMapping( - "type", + prepareCreate("idx2").setMapping( jsonBuilder().startObject() .startObject("properties") .startObject("nested1") @@ -531,7 +529,6 @@ public void testNonExistingNestedField() throws Exception { public void testSameParentDocHavingMultipleBuckets() throws Exception { XContentBuilder mapping = jsonBuilder().startObject() - .startObject("product") .field("dynamic", "strict") .startObject("properties") .startObject("id") @@ -562,11 +559,10 @@ public void testSameParentDocHavingMultipleBuckets() throws Exception { .endObject() .endObject() .endObject() - .endObject() .endObject(); assertAcked( prepareCreate("idx3").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping("product", mapping) + .setMapping(mapping) ); client().prepareIndex("idx3") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java index e01f966cadd9b..7996e2bee44c1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java @@ -128,10 +128,8 @@ public Settings indexSettings() { @Override public void setupSuiteScopeCluster() throws Exception { - prepareCreate("idx").addMapping( - "type", + prepareCreate("idx").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("str_value") .field("type", "keyword") @@ -153,7 +151,6 @@ public void setupSuiteScopeCluster() throws Exception { .endObject() .endObject() .endObject() - .endObject() ).get(); numDocs = randomIntBetween(2, 100); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java index b6fdcf4b6267d..53a3cd4da5446 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java @@ -139,10 +139,8 @@ public void setupSuiteScopeCluster() throws Exception { assertAcked(prepareCreate("field-collapsing").addMapping("type", "group", "type=keyword")); createIndex("empty"); assertAcked( - prepareCreate("articles").addMapping( - "article", + prepareCreate("articles").setMapping( jsonBuilder().startObject() - .startObject("article") .startObject("properties") .startObject(TERMS_AGGS_FIELD) .field("type", "keyword") @@ -174,7 +172,6 @@ public void setupSuiteScopeCluster() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen("idx", "empty", "articles"); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java index 3d9ebb469cba6..0d63e6d719610 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java @@ -556,7 +556,7 @@ public void testFieldIsntWrittenOutTwice() throws Exception { .endObject() .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate("foo_2").addMapping("doc", builder).get()); + assertAcked(client().admin().indices().prepareCreate("foo_2").setMapping(builder).get()); XContentBuilder docBuilder = jsonBuilder().startObject() .startObject("license") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MovAvgIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MovAvgIT.java index dc37b49e7a910..91390edc7e872 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MovAvgIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MovAvgIT.java @@ -130,18 +130,15 @@ public String toString() { @Override public void setupSuiteScopeCluster() throws Exception { - prepareCreate("idx").addMapping( - "type", + prepareCreate("idx").setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject(VALUE_FIELD) .field("type", "double") .endObject() .endObject() .endObject() - .endObject() ).execute().get(); createIndex("idx_unmapped"); List builders = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fetch/FetchSubPhasePluginIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fetch/FetchSubPhasePluginIT.java index 68bac89213c57..def247676ac1a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fetch/FetchSubPhasePluginIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fetch/FetchSubPhasePluginIT.java @@ -79,10 +79,8 @@ public void testPlugin() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping( - "type1", + .setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -90,7 +88,6 @@ public void testPlugin() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java index b16678d60fce7..e28ef3c00a485 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java @@ -100,10 +100,8 @@ protected Map, Object>> pluginScripts() { public void testSimpleNested() throws Exception { assertAcked( - prepareCreate("articles").addMapping( - "article", + prepareCreate("articles").setMapping( jsonBuilder().startObject() - .startObject("article") .startObject("properties") .startObject("comments") .field("type", "nested") @@ -119,7 +117,6 @@ public void testSimpleNested() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -313,10 +310,8 @@ public void testRandomNested() throws Exception { public void testNestedMultipleLayers() throws Exception { assertAcked( - prepareCreate("articles").addMapping( - "article", + prepareCreate("articles").setMapping( jsonBuilder().startObject() - .startObject("article") .startObject("properties") .startObject("comments") .field("type", "nested") @@ -339,7 +334,6 @@ public void testNestedMultipleLayers() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -583,8 +577,7 @@ public void testInnerHitsWithObjectFieldThatHasANestedField() throws Exception { // number_of_shards = 1, because then we catch the expected exception in the same way. // (See expectThrows(...) below) .setSettings(Settings.builder().put("index.number_of_shards", 1)) - .addMapping( - "article", + .setMapping( jsonBuilder().startObject() .startObject("properties") .startObject("comments") @@ -741,7 +734,6 @@ public void testInnerHitsWithObjectFieldThatHasANestedField() throws Exception { public void testMatchesQueriesNestedInnerHits() throws Exception { XContentBuilder builder = jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("nested1") .field("type", "nested") @@ -755,9 +747,8 @@ public void testMatchesQueriesNestedInnerHits() throws Exception { .field("type", "long") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("type1", builder)); + assertAcked(prepareCreate("test").setMapping(builder)); ensureGreen(); List requests = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java index 27513b575d6f0..74c2922ebf328 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java @@ -139,18 +139,16 @@ protected Collection> nodePlugins() { public void testHighlightingWithKeywordIgnoreBoundaryScanner() throws IOException { XContentBuilder mappings = jsonBuilder(); mappings.startObject(); - mappings.startObject("type") - .startObject("properties") + mappings.startObject("properties") .startObject("tags") .field("type", "keyword") .endObject() .startObject("sort") .field("type", "long") .endObject() - .endObject() .endObject(); mappings.endObject(); - assertAcked(prepareCreate("test").addMapping("type", mappings)); + assertAcked(prepareCreate("test").setMapping(mappings)); client().prepareIndex("test") .setId("1") .setSource(jsonBuilder().startObject().array("tags", "foo bar", "foo bar", "foo bar", "foo baz").field("sort", 1).endObject()) @@ -176,16 +174,9 @@ public void testHighlightingWithKeywordIgnoreBoundaryScanner() throws IOExceptio public void testHighlightingWithStoredKeyword() throws IOException { XContentBuilder mappings = jsonBuilder(); mappings.startObject(); - mappings.startObject("type") - .startObject("properties") - .startObject("text") - .field("type", "keyword") - .field("store", true) - .endObject() - .endObject() - .endObject(); + mappings.startObject("properties").startObject("text").field("type", "keyword").field("store", true).endObject().endObject(); mappings.endObject(); - assertAcked(prepareCreate("test").addMapping("type", mappings)); + assertAcked(prepareCreate("test").setMapping(mappings)); client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("text", "foo").endObject()).get(); refresh(); SearchResponse search = client().prepareSearch() @@ -199,18 +190,16 @@ public void testHighlightingWithWildcardName() throws IOException { // test the kibana case with * as fieldname that will try highlight all fields including meta fields XContentBuilder mappings = jsonBuilder(); mappings.startObject(); - mappings.startObject("type") - .startObject("properties") + mappings.startObject("properties") .startObject("text") .field("type", "text") .field("analyzer", "keyword") .field("index_options", "offsets") .field("term_vector", "with_positions_offsets") .endObject() - .endObject() .endObject(); mappings.endObject(); - assertAcked(prepareCreate("test").addMapping("type", mappings)); + assertAcked(prepareCreate("test").setMapping(mappings)); client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("text", "text").endObject()).get(); refresh(); for (String type : ALL_TYPES) { @@ -224,7 +213,6 @@ public void testHighlightingWithWildcardName() throws IOException { public void testFieldAlias() throws IOException { XContentBuilder mappings = jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("text") .field("type", "text") @@ -236,9 +224,8 @@ public void testFieldAlias() throws IOException { .field("path", "text") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("type", mappings)); + assertAcked(prepareCreate("test").setMapping(mappings)); client().prepareIndex("test").setId("1").setSource("text", "foo").get(); refresh(); @@ -253,7 +240,6 @@ public void testFieldAlias() throws IOException { public void testFieldAliasWithSourceLookup() throws IOException { XContentBuilder mappings = jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("text") .field("type", "text") @@ -266,9 +252,8 @@ public void testFieldAliasWithSourceLookup() throws IOException { .field("path", "text") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("type", mappings)); + assertAcked(prepareCreate("test").setMapping(mappings)); client().prepareIndex("test").setId("1").setSource("text", "foo bar").get(); refresh(); @@ -283,7 +268,6 @@ public void testFieldAliasWithSourceLookup() throws IOException { public void testFieldAliasWithWildcardField() throws IOException { XContentBuilder mappings = jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("keyword") .field("type", "keyword") @@ -293,9 +277,8 @@ public void testFieldAliasWithWildcardField() throws IOException { .field("path", "keyword") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("type", mappings)); + assertAcked(prepareCreate("test").setMapping(mappings)); client().prepareIndex("test").setId("1").setSource("keyword", "foo").get(); refresh(); @@ -308,8 +291,7 @@ public void testFieldAliasWithWildcardField() throws IOException { public void testHighlightingWhenFieldsAreNotStoredThereIsNoSource() throws IOException { XContentBuilder mappings = jsonBuilder(); mappings.startObject(); - mappings.startObject("type") - .startObject("_source") + mappings.startObject("_source") .field("enabled", false) .endObject() .startObject("properties") @@ -325,10 +307,9 @@ public void testHighlightingWhenFieldsAreNotStoredThereIsNoSource() throws IOExc .field("type", "text") .field("store", true) .endObject() - .endObject() .endObject(); mappings.endObject(); - assertAcked(prepareCreate("test").addMapping("type", mappings)); + assertAcked(prepareCreate("test").setMapping(mappings)); client().prepareIndex("test") .setId("1") .setSource(jsonBuilder().startObject().field("unstored_text", "text").field("text", "text").endObject()) @@ -410,10 +391,8 @@ public void testEnsureNoNegativeOffsets() throws Exception { public void testSourceLookupHighlightingUsingPlainHighlighter() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") // we don't store title and don't use term vector, now lets see if it works... .startObject("title") @@ -432,7 +411,6 @@ public void testSourceLookupHighlightingUsingPlainHighlighter() throws Exception .endObject() .endObject() .endObject() - .endObject() ) ); @@ -480,10 +458,8 @@ public void testSourceLookupHighlightingUsingPlainHighlighter() throws Exception public void testSourceLookupHighlightingUsingFastVectorHighlighter() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") // we don't store title, now lets see if it works... .startObject("title") @@ -502,7 +478,6 @@ public void testSourceLookupHighlightingUsingFastVectorHighlighter() throws Exce .endObject() .endObject() .endObject() - .endObject() ) ); @@ -550,10 +525,8 @@ public void testSourceLookupHighlightingUsingFastVectorHighlighter() throws Exce public void testSourceLookupHighlightingUsingPostingsHighlighter() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") // we don't store title, now lets see if it works... .startObject("title") @@ -572,7 +545,6 @@ public void testSourceLookupHighlightingUsingPostingsHighlighter() throws Except .endObject() .endObject() .endObject() - .endObject() ) ); @@ -771,10 +743,8 @@ public void testHighlightingOnWildcardFields() throws Exception { public void testForceSourceWithSourceDisabled() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("_source") .field("enabled", false) .endObject() @@ -790,7 +760,6 @@ public void testForceSourceWithSourceDisabled() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -852,7 +821,7 @@ public void testPlainHighlighter() throws Exception { } public void testFastVectorHighlighter() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping())); + assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping())); ensureGreen(); indexRandom( @@ -886,7 +855,7 @@ public void testFastVectorHighlighter() throws Exception { } public void testHighlighterWithSentenceBoundaryScanner() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping())); + assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping())); ensureGreen(); indexRandom( @@ -927,7 +896,7 @@ public void testHighlighterWithSentenceBoundaryScanner() throws Exception { } public void testHighlighterWithSentenceBoundaryScannerAndLocale() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping())); + assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping())); ensureGreen(); indexRandom( @@ -970,7 +939,7 @@ public void testHighlighterWithSentenceBoundaryScannerAndLocale() throws Excepti } public void testHighlighterWithWordBoundaryScanner() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping())); + assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping())); ensureGreen(); indexRandom(true, client().prepareIndex("test").setSource("field1", "some quick and hairy brown:fox jumped over the lazy dog")); @@ -1000,7 +969,7 @@ public void testHighlighterWithWordBoundaryScanner() throws Exception { } public void testHighlighterWithWordBoundaryScannerAndLocale() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping())); + assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping())); ensureGreen(); indexRandom(true, client().prepareIndex("test").setSource("field1", "some quick and hairy brown:fox jumped over the lazy dog")); @@ -1034,7 +1003,7 @@ public void testHighlighterWithWordBoundaryScannerAndLocale() throws Exception { * phraseLimit is not set. Its default is now reasonably low. */ public void testFVHManyMatches() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping())); + assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping())); ensureGreen(); // Index one megabyte of "t " over and over and over again @@ -1085,11 +1054,9 @@ private void checkMatchedFieldsCase(boolean requireFieldMatch) throws Exception settings.put("index.analysis.analyzer.mock_english.filter", "mock_snowball"); assertAcked( prepareCreate("test").setSettings(settings) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("foo") .field("type", "text") @@ -1119,7 +1086,6 @@ private void checkMatchedFieldsCase(boolean requireFieldMatch) throws Exception .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -1270,7 +1236,7 @@ private void checkMatchedFieldsCase(boolean requireFieldMatch) throws Exception } public void testFastVectorHighlighterManyDocs() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping())); + assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping())); ensureGreen(); int COUNT = between(20, 100); @@ -1297,7 +1263,6 @@ public void testFastVectorHighlighterManyDocs() throws Exception { public XContentBuilder type1TermVectorMapping() throws IOException { return XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -1308,7 +1273,6 @@ public XContentBuilder type1TermVectorMapping() throws IOException { .field("term_vector", "with_positions_offsets") .endObject() .endObject() - .endObject() .endObject(); } @@ -1406,10 +1370,8 @@ public void testEscapeHtmlVector() throws Exception { public void testMultiMapperVectorWithStore() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("title") .field("type", "text") @@ -1427,7 +1389,6 @@ public void testMultiMapperVectorWithStore() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -1453,10 +1414,8 @@ public void testMultiMapperVectorWithStore() throws Exception { public void testMultiMapperVectorFromSource() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("title") .field("type", "text") @@ -1474,7 +1433,6 @@ public void testMultiMapperVectorFromSource() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -1501,10 +1459,8 @@ public void testMultiMapperVectorFromSource() throws Exception { public void testMultiMapperNoVectorWithStore() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("title") .field("type", "text") @@ -1522,7 +1478,6 @@ public void testMultiMapperNoVectorWithStore() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -1549,10 +1504,8 @@ public void testMultiMapperNoVectorWithStore() throws Exception { public void testMultiMapperNoVectorFromSource() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("title") .field("type", "text") @@ -1570,7 +1523,6 @@ public void testMultiMapperNoVectorFromSource() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -1739,7 +1691,7 @@ public void testBoostingQuery() { } public void testBoostingQueryTermVector() throws IOException { - assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping())); + assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping())); ensureGreen(); client().prepareIndex("test").setSource("field1", "this is a test", "field2", "The quick brown fox jumps over the lazy dog").get(); refresh(); @@ -1770,7 +1722,7 @@ public void testCommonTermsQuery() { } public void testCommonTermsTermVector() throws IOException { - assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping())); + assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping())); ensureGreen(); client().prepareIndex("test").setSource("field1", "this is a test", "field2", "The quick brown fox jumps over the lazy dog").get(); @@ -2278,7 +2230,7 @@ public void testHighlightNoMatchSizeNumberOfFragments() throws IOException { } public void testPostingsHighlighter() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test") @@ -2349,7 +2301,7 @@ public void testPostingsHighlighter() throws Exception { } public void testPostingsHighlighterMultipleFields() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()).get()); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()).get()); ensureGreen(); index( @@ -2371,7 +2323,7 @@ public void testPostingsHighlighterMultipleFields() throws Exception { } public void testPostingsHighlighterNumberOfFragments() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test") @@ -2457,7 +2409,6 @@ public void testPostingsHighlighterNumberOfFragments() throws Exception { public void testMultiMatchQueryHighlight() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -2470,9 +2421,8 @@ public void testMultiMatchQueryHighlight() throws IOException { .field("term_vector", "with_positions_offsets") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("type1", mapping)); + assertAcked(prepareCreate("test").setMapping(mapping)); ensureGreen(); client().prepareIndex("test") .setSource("field1", "The quick brown fox jumps over", "field2", "The quick brown fox jumps over") @@ -2507,7 +2457,7 @@ public void testMultiMatchQueryHighlight() throws IOException { } public void testPostingsHighlighterOrderByScore() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test") @@ -2585,10 +2535,8 @@ public void testPostingsHighlighterEscapeHtml() throws Exception { public void testPostingsHighlighterMultiMapperWithStore() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("title") .field("type", "text") @@ -2606,7 +2554,6 @@ public void testPostingsHighlighterMultiMapperWithStore() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -2645,10 +2592,8 @@ public void testPostingsHighlighterMultiMapperWithStore() throws Exception { public void testPostingsHighlighterMultiMapperFromSource() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("title") .field("type", "text") @@ -2666,7 +2611,6 @@ public void testPostingsHighlighterMultiMapperFromSource() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -2693,10 +2637,8 @@ public void testPostingsHighlighterMultiMapperFromSource() throws Exception { public void testPostingsHighlighterShouldFailIfNoOffsets() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("title") .field("type", "text") @@ -2705,7 +2647,6 @@ public void testPostingsHighlighterShouldFailIfNoOffsets() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -2726,7 +2667,7 @@ public void testPostingsHighlighterShouldFailIfNoOffsets() throws Exception { } public void testPostingsHighlighterBoostingQuery() throws IOException { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test") .setSource("field1", "this is a test", "field2", "The quick brown fox jumps over the lazy dog! Second sentence.") @@ -2743,7 +2684,7 @@ public void testPostingsHighlighterBoostingQuery() throws IOException { } public void testPostingsHighlighterCommonTermsQuery() throws IOException { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test") @@ -2770,7 +2711,6 @@ public void testPostingsHighlighterCommonTermsQuery() throws IOException { private static XContentBuilder type1PostingsffsetsMapping() throws IOException { return XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -2781,12 +2721,11 @@ private static XContentBuilder type1PostingsffsetsMapping() throws IOException { .field("index_options", "offsets") .endObject() .endObject() - .endObject() .endObject(); } public void testPostingsHighlighterPrefixQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test") @@ -2808,7 +2747,7 @@ public void testPostingsHighlighterPrefixQuery() throws Exception { } public void testPostingsHighlighterFuzzyQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test") @@ -2831,7 +2770,7 @@ public void testPostingsHighlighterFuzzyQuery() throws Exception { } public void testPostingsHighlighterRegexpQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test") @@ -2854,7 +2793,7 @@ public void testPostingsHighlighterRegexpQuery() throws Exception { } public void testPostingsHighlighterWildcardQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test") @@ -2890,7 +2829,7 @@ public void testPostingsHighlighterWildcardQuery() throws Exception { } public void testPostingsHighlighterTermRangeQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test").setSource("field1", "this is a test", "field2", "aaab").get(); @@ -2905,7 +2844,7 @@ public void testPostingsHighlighterTermRangeQuery() throws Exception { } public void testPostingsHighlighterQueryString() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test") @@ -2928,7 +2867,7 @@ public void testPostingsHighlighterQueryString() throws Exception { } public void testPostingsHighlighterRegexpQueryWithinConstantScoreQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test").setSource("field1", "The photography word will get highlighted").get(); @@ -2942,7 +2881,7 @@ public void testPostingsHighlighterRegexpQueryWithinConstantScoreQuery() throws } public void testPostingsHighlighterMultiTermQueryMultipleLevels() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test").setSource("field1", "The photography word will get highlighted").get(); @@ -2959,7 +2898,7 @@ public void testPostingsHighlighterMultiTermQueryMultipleLevels() throws Excepti } public void testPostingsHighlighterPrefixQueryWithinBooleanQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test").setSource("field1", "The photography word will get highlighted").get(); @@ -2974,7 +2913,7 @@ public void testPostingsHighlighterPrefixQueryWithinBooleanQuery() throws Except } public void testPostingsHighlighterQueryStringWithinFilteredQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); client().prepareIndex("test").setSource("field1", "The photography word will get highlighted").get(); @@ -2989,7 +2928,7 @@ public void testPostingsHighlighterQueryStringWithinFilteredQuery() throws Excep } public void testPostingsHighlighterManyDocs() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping())); + assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping())); ensureGreen(); int COUNT = between(20, 100); @@ -3025,7 +2964,6 @@ public void testPostingsHighlighterManyDocs() throws Exception { public void testDoesNotHighlightTypeName() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("typename") .startObject("properties") .startObject("foo") .field("type", "text") @@ -3033,9 +2971,8 @@ public void testDoesNotHighlightTypeName() throws Exception { .field("term_vector", "with_positions_offsets") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("typename", mapping)); + assertAcked(prepareCreate("test").setMapping(mapping)); ensureGreen(); indexRandom(true, client().prepareIndex("test").setSource("foo", "test typename")); @@ -3052,7 +2989,6 @@ public void testDoesNotHighlightTypeName() throws Exception { public void testDoesNotHighlightAliasFilters() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("typename") .startObject("properties") .startObject("foo") .field("type", "text") @@ -3060,9 +2996,8 @@ public void testDoesNotHighlightAliasFilters() throws Exception { .field("term_vector", "with_positions_offsets") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("typename", mapping)); + assertAcked(prepareCreate("test").setMapping(mapping)); assertAcked(client().admin().indices().prepareAliases().addAlias("test", "filtered_alias", matchQuery("foo", "japanese"))); ensureGreen(); @@ -3078,7 +3013,7 @@ public void testDoesNotHighlightAliasFilters() throws Exception { } public void testFastVectorHighlighterPhraseBoost() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping())); + assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping())); phraseBoostTestCase("fvh"); } @@ -3174,8 +3109,7 @@ public void testGeoFieldHighlightingWithDifferentHighlighters() throws IOExcepti // see https://github.com/elastic/elasticsearch/issues/17537 XContentBuilder mappings = jsonBuilder(); mappings.startObject(); - mappings.startObject("type") - .startObject("properties") + mappings.startObject("properties") .startObject("geo_point") .field("type", "geo_point") .endObject() @@ -3184,10 +3118,9 @@ public void testGeoFieldHighlightingWithDifferentHighlighters() throws IOExcepti .field("term_vector", "with_positions_offsets_payloads") .field("index_options", "offsets") .endObject() - .endObject() .endObject(); mappings.endObject(); - assertAcked(prepareCreate("test").addMapping("type", mappings)); + assertAcked(prepareCreate("test").setMapping(mappings)); client().prepareIndex("test") .setId("1") @@ -3216,18 +3149,16 @@ public void testGeoFieldHighlightingWhenQueryGetsRewritten() throws IOException // see https://github.com/elastic/elasticsearch/issues/17537#issuecomment-244939633 XContentBuilder mappings = jsonBuilder(); mappings.startObject(); - mappings.startObject("jobs") - .startObject("properties") + mappings.startObject("properties") .startObject("loc") .field("type", "geo_point") .endObject() .startObject("jd") .field("type", "text") .endObject() - .endObject() .endObject(); mappings.endObject(); - assertAcked(prepareCreate("test").addMapping("jobs", mappings)); + assertAcked(prepareCreate("test").setMapping(mappings)); ensureYellow(); client().prepareIndex("test") @@ -3259,15 +3190,9 @@ public void testKeywordFieldHighlighting() throws IOException { // check that keyword highlighting works XContentBuilder mappings = jsonBuilder(); mappings.startObject(); - mappings.startObject("type") - .startObject("properties") - .startObject("keyword_field") - .field("type", "keyword") - .endObject() - .endObject() - .endObject(); + mappings.startObject("properties").startObject("keyword_field").field("type", "keyword").endObject().endObject(); mappings.endObject(); - assertAcked(prepareCreate("test").addMapping("type", mappings)); + assertAcked(prepareCreate("test").setMapping(mappings)); client().prepareIndex("test") .setId("1") @@ -3299,7 +3224,7 @@ public void testCopyToFields() throws Exception { // If field is not stored, it is looked up in source (but source has only 'foo' b.startObject("foo_copy").field("type", "text").field("store", true).endObject(); b.endObject().endObject(); - prepareCreate("test").addMapping("type", b).get(); + prepareCreate("test").setMapping(b).get(); client().prepareIndex("test") .setId("1") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java index 8767904e03c72..aed2975ed3234 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java @@ -88,7 +88,7 @@ public void setUp() throws Exception { .endObject() .endObject() .endObject(); - assertAcked(prepareCreate("old_index").addMapping("_doc", oldIndexMapping)); + assertAcked(prepareCreate("old_index").setMapping(oldIndexMapping)); XContentBuilder newIndexMapping = XContentFactory.jsonBuilder() .startObject() @@ -106,7 +106,7 @@ public void setUp() throws Exception { .endObject() .endObject() .endObject(); - assertAcked(prepareCreate("new_index").addMapping("_doc", newIndexMapping)); + assertAcked(prepareCreate("new_index").setMapping(newIndexMapping)); assertAcked(client().admin().indices().prepareAliases().addAlias("new_index", "current")); } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java index 72c60e98ec328..46d47d838f68b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java @@ -774,10 +774,8 @@ public void testGetFieldsComplexField() throws Exception { .indices() .prepareCreate("my-index") .setSettings(Settings.builder().put("index.refresh_interval", -1)) - .addMapping( - MapperService.SINGLE_MAPPING_NAME, + .setMapping( jsonBuilder().startObject() - .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("field1") .field("type", "object") @@ -800,7 +798,6 @@ public void testGetFieldsComplexField() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .get(); @@ -1181,7 +1178,6 @@ public void testScriptFields() throws Exception { public void testDocValueFieldsWithFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("_source") .field("enabled", false) .endObject() @@ -1203,9 +1199,8 @@ public void testDocValueFieldsWithFieldAlias() throws Exception { .field("path", "date_field") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)); + assertAcked(prepareCreate("test").setMapping(mapping)); ensureGreen("test"); DateTime date = new DateTime(1990, 12, 29, 0, 0, DateTimeZone.UTC); @@ -1244,7 +1239,6 @@ public void testDocValueFieldsWithFieldAlias() throws Exception { public void testWildcardDocValueFieldsWithFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("_source") .field("enabled", false) .endObject() @@ -1266,9 +1260,8 @@ public void testWildcardDocValueFieldsWithFieldAlias() throws Exception { .field("path", "date_field") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)); + assertAcked(prepareCreate("test").setMapping(mapping)); ensureGreen("test"); DateTime date = new DateTime(1990, 12, 29, 0, 0, DateTimeZone.UTC); @@ -1306,7 +1299,6 @@ public void testWildcardDocValueFieldsWithFieldAlias() throws Exception { public void testStoredFieldsWithFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("field1") .field("type", "text") @@ -1325,9 +1317,8 @@ public void testStoredFieldsWithFieldAlias() throws Exception { .field("path", "field2") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)); + assertAcked(prepareCreate("test").setMapping(mapping)); index("test", MapperService.SINGLE_MAPPING_NAME, "1", "field1", "value1", "field2", "value2"); refresh("test"); @@ -1350,7 +1341,6 @@ public void testStoredFieldsWithFieldAlias() throws Exception { public void testWildcardStoredFieldsWithFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("field1") .field("type", "text") @@ -1369,9 +1359,8 @@ public void testWildcardStoredFieldsWithFieldAlias() throws Exception { .field("path", "field2") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)); + assertAcked(prepareCreate("test").setMapping(mapping)); index("test", MapperService.SINGLE_MAPPING_NAME, "1", "field1", "value1", "field2", "value2"); refresh("test"); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/DecayFunctionScoreIT.java b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/DecayFunctionScoreIT.java index 712026eaf5c43..709a916d98838 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/DecayFunctionScoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/DecayFunctionScoreIT.java @@ -96,10 +96,8 @@ protected boolean forbidPrivateIndexSettings() { public void testDistanceScoreGeoLinGaussExp() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -109,7 +107,6 @@ public void testDistanceScoreGeoLinGaussExp() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -223,10 +220,8 @@ public void testDistanceScoreGeoLinGaussExp() throws Exception { public void testDistanceScoreGeoLinGaussExpWithOffset() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -236,7 +231,6 @@ public void testDistanceScoreGeoLinGaussExpWithOffset() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -337,10 +331,8 @@ public void testBoostModeSettingWorks() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1).build(); assertAcked( prepareCreate("test").setSettings(settings) - .addMapping( - "type1", + .setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -350,7 +342,6 @@ public void testBoostModeSettingWorks() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -436,10 +427,8 @@ public void testBoostModeSettingWorks() throws Exception { public void testParseGeoPoint() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -449,7 +438,6 @@ public void testParseGeoPoint() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -504,10 +492,8 @@ public void testParseGeoPoint() throws Exception { public void testCombineModes() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -517,7 +503,6 @@ public void testCombineModes() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -621,10 +606,8 @@ public void testCombineModes() throws Exception { public void testCombineModesExplain() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -634,7 +617,6 @@ public void testCombineModesExplain() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -691,10 +673,8 @@ public void testCombineModesExplain() throws Exception { public void testExceptionThrownIfScaleLE0() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -704,7 +684,6 @@ public void testExceptionThrownIfScaleLE0() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); client().index( @@ -731,10 +710,8 @@ public void testExceptionThrownIfScaleLE0() throws Exception { public void testParseDateMath() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -745,7 +722,6 @@ public void testParseDateMath() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); client().index( @@ -785,10 +761,8 @@ public void testParseDateMath() throws Exception { public void testValueMissingLin() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -801,7 +775,6 @@ public void testValueMissingLin() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -854,10 +827,8 @@ public void testDateWithoutOrigin() throws Exception { ZonedDateTime dt = ZonedDateTime.now(ZoneOffset.UTC); assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -867,7 +838,6 @@ public void testDateWithoutOrigin() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -933,7 +903,6 @@ public void testManyDocsLin() throws Exception { Version version = VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("test") .field("type", "text") @@ -949,8 +918,8 @@ public void testManyDocsLin() throws Exception { .startObject("geo") .field("type", "geo_point") .field("ignore_malformed", true); - xContentBuilder.endObject().endObject().endObject().endObject(); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type", xContentBuilder)); + xContentBuilder.endObject().endObject().endObject(); + assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder)); int numDocs = 200; List indexBuilders = new ArrayList<>(); @@ -1013,10 +982,8 @@ public void testManyDocsLin() throws Exception { public void testParsingExceptionIfFieldDoesNotExist() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("test") .field("type", "text") @@ -1026,7 +993,6 @@ public void testParsingExceptionIfFieldDoesNotExist() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); int numDocs = 2; @@ -1066,10 +1032,8 @@ public void testParsingExceptionIfFieldDoesNotExist() throws Exception { public void testParsingExceptionIfFieldTypeDoesNotMatch() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("test") .field("type", "text") @@ -1079,7 +1043,6 @@ public void testParsingExceptionIfFieldTypeDoesNotMatch() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); client().index( @@ -1105,10 +1068,8 @@ public void testParsingExceptionIfFieldTypeDoesNotMatch() throws Exception { public void testNoQueryGiven() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("test") .field("type", "text") @@ -1118,7 +1079,6 @@ public void testNoQueryGiven() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); client().index(indexRequest("test").source(jsonBuilder().startObject().field("test", "value").field("num", 1.0).endObject())) @@ -1138,10 +1098,8 @@ public void testNoQueryGiven() throws Exception { public void testMultiFieldOptions() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -1154,7 +1112,6 @@ public void testMultiFieldOptions() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -1271,10 +1228,8 @@ public void testMultiFieldOptions() throws Exception { public void testDistanceScoreGeoLinGaussExplain() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -1284,7 +1239,6 @@ public void testDistanceScoreGeoLinGaussExplain() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/FunctionScoreFieldValueIT.java b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/FunctionScoreFieldValueIT.java index 8e0a14b7062a7..4e1df591cb245 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/FunctionScoreFieldValueIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/FunctionScoreFieldValueIT.java @@ -57,10 +57,8 @@ public class FunctionScoreFieldValueIT extends OpenSearchIntegTestCase { public void testFieldValueFactor() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", randomFrom(new String[] { "short", "float", "long", "integer", "double" })) @@ -70,7 +68,6 @@ public void testFieldValueFactor() throws IOException { .endObject() .endObject() .endObject() - .endObject() ).get() ); @@ -169,10 +166,8 @@ public void testFieldValueFactor() throws IOException { public void testFieldValueFactorExplain() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", randomFrom(new String[] { "short", "float", "long", "integer", "double" })) @@ -182,7 +177,6 @@ public void testFieldValueFactorExplain() throws IOException { .endObject() .endObject() .endObject() - .endObject() ).get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/FunctionScorePluginIT.java b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/FunctionScorePluginIT.java index 885f1aa7ff7a0..a7a14f3b0d889 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/FunctionScorePluginIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/FunctionScorePluginIT.java @@ -76,10 +76,8 @@ public void testPlugin() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping( - "type1", + .setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("test") .field("type", "text") @@ -89,7 +87,6 @@ public void testPlugin() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .get(); client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/QueryRescorerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/QueryRescorerIT.java index e216e92c63bad..c4a41ad5b76e2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/QueryRescorerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/QueryRescorerIT.java @@ -127,10 +127,8 @@ public void testEnforceWindowSize() { public void testRescorePhrase() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("analyzer", "whitespace") @@ -138,7 +136,6 @@ public void testRescorePhrase() throws Exception { .endObject() .endObject() .endObject() - .endObject() ).setSettings(Settings.builder().put(indexSettings()).put("index.number_of_shards", 1)) ); @@ -190,22 +187,16 @@ public void testMoreDocs() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") .field("analyzer", "whitespace") .endObject() .endObject() - .endObject() .endObject(); assertAcked( - client().admin() - .indices() - .prepareCreate("test") - .addMapping("type1", mapping) - .setSettings(builder.put("index.number_of_shards", 1)) + client().admin().indices().prepareCreate("test").setMapping(mapping).setSettings(builder.put("index.number_of_shards", 1)) ); client().prepareIndex("test").setId("1").setSource("field1", "massachusetts avenue boston massachusetts").get(); @@ -285,22 +276,16 @@ public void testSmallRescoreWindow() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") .field("analyzer", "whitespace") .endObject() .endObject() - .endObject() .endObject(); assertAcked( - client().admin() - .indices() - .prepareCreate("test") - .addMapping("type1", mapping) - .setSettings(builder.put("index.number_of_shards", 1)) + client().admin().indices().prepareCreate("test").setMapping(mapping).setSettings(builder.put("index.number_of_shards", 1)) ); client().prepareIndex("test").setId("3").setSource("field1", "massachusetts").get(); @@ -371,22 +356,16 @@ public void testRescorerMadeScoresWorse() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") .field("analyzer", "whitespace") .endObject() .endObject() - .endObject() .endObject(); assertAcked( - client().admin() - .indices() - .prepareCreate("test") - .addMapping("type1", mapping) - .setSettings(builder.put("index.number_of_shards", 1)) + client().admin().indices().prepareCreate("test").setMapping(mapping).setSettings(builder.put("index.number_of_shards", 1)) ); client().prepareIndex("test").setId("3").setSource("field1", "massachusetts").get(); @@ -524,10 +503,8 @@ public void testEquivalence() throws Exception { public void testExplain() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("analyzer", "whitespace") @@ -535,7 +512,6 @@ public void testExplain() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -785,10 +761,8 @@ private int indexRandomNumbers(String analyzer, int shards, boolean dummyDocs) t } assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("analyzer", analyzer) @@ -796,7 +770,6 @@ private int indexRandomNumbers(String analyzer, int shards, boolean dummyDocs) t .endObject() .endObject() .endObject() - .endObject() ).setSettings(builder) ); int numDocs = randomIntBetween(100, 150); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryIT.java index f865e56cd99e3..90e7163342547 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryIT.java @@ -64,12 +64,11 @@ public void testSimpleBoundingBoxTest() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("location") .field("type", "geo_point"); - xContentBuilder.endObject().endObject().endObject().endObject(); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder)); + xContentBuilder.endObject().endObject().endObject(); + assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder)); ensureGreen(); client().prepareIndex("test") @@ -195,12 +194,11 @@ public void testLimit2BoundingBox() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("location") .field("type", "geo_point"); - xContentBuilder.endObject().endObject().endObject().endObject(); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder)); + xContentBuilder.endObject().endObject().endObject(); + assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder)); ensureGreen(); client().prepareIndex("test") @@ -275,12 +273,11 @@ public void testCompleteLonRange() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("location") .field("type", "geo_point"); - xContentBuilder.endObject().endObject().endObject().endObject(); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder)); + xContentBuilder.endObject().endObject().endObject(); + assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder)); ensureGreen(); client().prepareIndex("test") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceIT.java index d00c0a8c0faf7..ba7af0ecfcb06 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceIT.java @@ -124,12 +124,11 @@ public void setupTestIndex() throws IOException { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("location") .field("type", "geo_point"); - xContentBuilder.endObject().endObject().endObject().endObject(); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder)); + xContentBuilder.endObject().endObject().endObject(); + assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder)); ensureGreen(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoFilterIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoFilterIT.java index 8322c9704eecb..975cb5f7e3b8c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoFilterIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoFilterIT.java @@ -393,7 +393,6 @@ public void testBulk() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() - .startObject("country") .startObject("properties") .startObject("pin") .field("type", "geo_point"); @@ -404,10 +403,9 @@ public void testBulk() throws Exception { .field("ignore_malformed", true) .endObject() .endObject() - .endObject() .endObject(); - client().admin().indices().prepareCreate("countries").setSettings(settings).addMapping("country", xContentBuilder).get(); + client().admin().indices().prepareCreate("countries").setSettings(settings).setMapping(xContentBuilder).get(); BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, null, xContentBuilder.contentType()).get(); for (BulkItemResponse item : bulk.getItems()) { diff --git a/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java b/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java index 7ffd648d06611..69b2e655dd0ad 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java @@ -86,17 +86,14 @@ protected Collection> nodePlugins() { public void testSimpleMoreLikeThis() throws Exception { logger.info("Creating index test"); assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("text") .field("type", "text") .endObject() .endObject() .endObject() - .endObject() ) ); @@ -119,17 +116,14 @@ public void testSimpleMoreLikeThis() throws Exception { public void testSimpleMoreLikeThisWithTypes() throws Exception { logger.info("Creating index test"); assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("text") .field("type", "text") .endObject() .endObject() .endObject() - .endObject() ) ); @@ -151,10 +145,8 @@ public void testSimpleMoreLikeThisWithTypes() throws Exception { // Issue #30148 public void testMoreLikeThisForZeroTokensInOneOfTheAnalyzedFields() throws Exception { - CreateIndexRequestBuilder createIndexRequestBuilder = prepareCreate("test").addMapping( - "type", + CreateIndexRequestBuilder createIndexRequestBuilder = prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("myField") .field("type", "text") @@ -164,7 +156,6 @@ public void testMoreLikeThisForZeroTokensInOneOfTheAnalyzedFields() throws Excep .endObject() .endObject() .endObject() - .endObject() ); assertAcked(createIndexRequestBuilder); @@ -214,17 +205,14 @@ public void testSimpleMoreLikeOnLongField() throws Exception { public void testMoreLikeThisWithAliases() throws Exception { logger.info("Creating index test"); assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("text") .field("type", "text") .endObject() .endObject() .endObject() - .endObject() ) ); logger.info("Creating aliases alias release"); @@ -370,10 +358,8 @@ public void testMoreLikeThisIssueRoutingNotSerialized() throws Exception { // Issue #3252 public void testNumericField() throws Exception { final String[] numericTypes = new String[] { "byte", "short", "integer", "long" }; - prepareCreate("test").addMapping( - "type", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("int_value") .field("type", randomFrom(numericTypes)) @@ -383,7 +369,6 @@ public void testNumericField() throws Exception { .endObject() .endObject() .endObject() - .endObject() ).get(); ensureGreen(); client().prepareIndex("test") @@ -486,7 +471,6 @@ public void testNumericField() throws Exception { public void testMoreLikeThisWithFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("_doc") .startObject("properties") .startObject("text") .field("type", "text") @@ -496,10 +480,9 @@ public void testMoreLikeThisWithFieldAlias() throws Exception { .field("path", "text") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("_doc", mapping)); + assertAcked(prepareCreate("test").setMapping(mapping)); ensureGreen(); index("test", "_doc", "1", "text", "lucene"); @@ -517,17 +500,14 @@ public void testMoreLikeThisWithFieldAlias() throws Exception { public void testSimpleMoreLikeInclude() throws Exception { logger.info("Creating index test"); assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("text") .field("type", "text") .endObject() .endObject() .endObject() - .endObject() ) ); @@ -584,17 +564,14 @@ public void testSimpleMoreLikeInclude() throws Exception { public void testSimpleMoreLikeThisIds() throws Exception { logger.info("Creating index test"); assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("text") .field("type", "text") .endObject() .endObject() .endObject() - .endObject() ) ); @@ -867,10 +844,8 @@ public void testWithRouting() throws IOException { public void testWithMissingRouting() throws IOException { logger.info("Creating index test with routing required for type1"); assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("text") .field("type", "text") @@ -880,7 +855,6 @@ public void testWithMissingRouting() throws IOException { .field("required", true) .endObject() .endObject() - .endObject() ) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java index c6c58e6fcb6a5..e3c1abff5d206 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java @@ -213,10 +213,8 @@ public void testSimpleNested() throws Exception { public void testMultiNested() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("nested1") .field("type", "nested") @@ -228,7 +226,6 @@ public void testMultiNested() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -371,10 +368,8 @@ public void testMultiNested() throws Exception { public void testDeleteNestedDocsWithAlias() throws Exception { assertAcked( prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).put("index.refresh_interval", -1).build()) - .addMapping( - "type1", + .setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -384,7 +379,6 @@ public void testDeleteNestedDocsWithAlias() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -437,17 +431,14 @@ public void testDeleteNestedDocsWithAlias() throws Exception { public void testExplain() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("nested1") .field("type", "nested") .endObject() .endObject() .endObject() - .endObject() ) ); @@ -485,10 +476,8 @@ public void testExplain() throws Exception { public void testSimpleNestedSorting() throws Exception { assertAcked( prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).put("index.refresh_interval", -1)) - .addMapping( - "type1", + .setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("nested1") .field("type", "nested") @@ -501,7 +490,6 @@ public void testSimpleNestedSorting() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -586,10 +574,8 @@ public void testSimpleNestedSorting() throws Exception { public void testSimpleNestedSortingWithNestedFilterMissing() throws Exception { assertAcked( prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).put("index.refresh_interval", -1)) - .addMapping( - "type1", + .setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("nested1") .field("type", "nested") @@ -604,7 +590,6 @@ public void testSimpleNestedSortingWithNestedFilterMissing() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -1048,11 +1033,9 @@ public void testLeakingSortValues() throws Exception { public void testSortNestedWithNestedFilter() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("grand_parent_values") .field("type", "long") @@ -1075,7 +1058,6 @@ public void testSortNestedWithNestedFilter() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -1448,8 +1430,7 @@ public void testSortNestedWithNestedFilter() throws Exception { // Issue #9305 public void testNestedSortingWithNestedFilterAsFilter() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type", + prepareCreate("test").setMapping( jsonBuilder().startObject() .startObject("properties") .startObject("officelocation") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/ExistsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/ExistsIT.java index 89c614485b620..75b8e46802061 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/ExistsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/ExistsIT.java @@ -70,7 +70,6 @@ public void testEmptyIndex() throws Exception { public void testExists() throws Exception { XContentBuilder mapping = XContentBuilder.builder(JsonXContent.jsonXContent) .startObject() - .startObject("type") .startObject("properties") .startObject("foo") .field("type", "text") @@ -95,10 +94,9 @@ public void testExists() throws Exception { .endObject() .endObject() .endObject() - .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", mapping)); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping(mapping)); Map barObject = new HashMap<>(); barObject.put("foo", "bar"); barObject.put("bar", singletonMap("bar", "foo")); @@ -176,7 +174,6 @@ public void testExists() throws Exception { public void testFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("bar") .field("type", "long") @@ -194,9 +191,8 @@ public void testFieldAlias() throws Exception { .field("path", "foo.bar") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("idx").addMapping("type", mapping)); + assertAcked(prepareCreate("idx").setMapping(mapping)); ensureGreen("idx"); List indexRequests = new ArrayList<>(); @@ -226,7 +222,6 @@ public void testFieldAlias() throws Exception { public void testFieldAliasWithNoDocValues() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("foo") .field("type", "long") @@ -237,9 +232,8 @@ public void testFieldAliasWithNoDocValues() throws Exception { .field("path", "foo") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("idx").addMapping("type", mapping)); + assertAcked(prepareCreate("idx").setMapping(mapping)); ensureGreen("idx"); List indexRequests = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java index b40a034fc2c92..66b42fe266887 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java @@ -109,7 +109,7 @@ public void init() throws Exception { .put("index.analysis.analyzer.category.tokenizer", "standard") .put("index.analysis.analyzer.category.filter", "lowercase") ); - assertAcked(builder.addMapping("test", createMapping())); + assertAcked(builder.setMapping(createMapping())); ensureGreen(); int numDocs = scaledRandomIntBetween(50, 100); List builders = new ArrayList<>(); @@ -259,7 +259,6 @@ public void init() throws Exception { private XContentBuilder createMapping() throws IOException { return XContentFactory.jsonBuilder() .startObject() - .startObject("test") .startObject("properties") .startObject("id") .field("type", "keyword") @@ -287,7 +286,6 @@ private XContentBuilder createMapping() throws IOException { .field("type", "date") .endObject() .endObject() - .endObject() .endObject(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/QueryStringIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/QueryStringIT.java index 494aa4c0e6b88..5c7e53fda3f23 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/QueryStringIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/QueryStringIT.java @@ -278,16 +278,14 @@ public void testAllFieldsWithSpecifiedLeniency() throws IOException { public void testLimitOnExpandedFieldsButIgnoreUnmappedFields() throws Exception { XContentBuilder builder = jsonBuilder(); builder.startObject(); - builder.startObject("_doc"); builder.startObject("properties"); for (int i = 0; i < CLUSTER_MAX_CLAUSE_COUNT; i++) { builder.startObject("field" + i).field("type", "text").endObject(); } builder.endObject(); // properties - builder.endObject(); // type1 builder.endObject(); - assertAcked(prepareCreate("ignoreunmappedfields").addMapping("_doc", builder)); + assertAcked(prepareCreate("ignoreunmappedfields").setMapping(builder)); client().prepareIndex("ignoreunmappedfields").setId("1").setSource("field1", "foo bar baz").get(); refresh(); @@ -303,25 +301,19 @@ public void testLimitOnExpandedFields() throws Exception { XContentBuilder builder = jsonBuilder(); builder.startObject(); { - builder.startObject("_doc"); - { - builder.startObject("properties"); - { - for (int i = 0; i < CLUSTER_MAX_CLAUSE_COUNT; i++) { - builder.startObject("field_A" + i).field("type", "text").endObject(); - builder.startObject("field_B" + i).field("type", "text").endObject(); - } - builder.endObject(); - } - builder.endObject(); + builder.startObject("properties"); + for (int i = 0; i < CLUSTER_MAX_CLAUSE_COUNT; i++) { + builder.startObject("field_A" + i).field("type", "text").endObject(); + builder.startObject("field_B" + i).field("type", "text").endObject(); } builder.endObject(); } + builder.endObject(); assertAcked( prepareCreate("testindex").setSettings( Settings.builder().put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), CLUSTER_MAX_CLAUSE_COUNT + 100) - ).addMapping("_doc", builder) + ).setMapping(builder) ); client().prepareIndex("testindex").setId("1").setSource("field_A0", "foo bar baz").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java index fb744ccfc4655..fa2d79ecb2017 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java @@ -1119,10 +1119,8 @@ public void testTermsQuery() throws Exception { public void testTermsLookupFilter() throws Exception { assertAcked(prepareCreate("lookup").addMapping("type", "terms", "type=text", "other", "type=text")); assertAcked( - prepareCreate("lookup2").addMapping( - "type", + prepareCreate("lookup2").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("arr") .startObject("properties") @@ -1133,7 +1131,6 @@ public void testTermsLookupFilter() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); assertAcked(prepareCreate("lookup3").addMapping("type", "_source", "enabled=false", "terms", "type=text")); @@ -1600,10 +1597,8 @@ public void testSpanNot() throws IOException, ExecutionException, InterruptedExc public void testSimpleDFSQuery() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "_doc", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("_doc") .startObject("_routing") .field("required", true) .endObject() @@ -1621,7 +1616,6 @@ public void testSimpleDFSQuery() throws IOException { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -1876,8 +1870,7 @@ public void testRangeQueryWithLocaleMapping() throws Exception { assert ("SPI,COMPAT".equals(System.getProperty("java.locale.providers"))) : "`-Djava.locale.providers=SPI,COMPAT` needs to be set"; assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() .startObject("properties") .startObject("date_field") @@ -1978,7 +1971,6 @@ public void testRangeQueryRangeFields_24744() throws Exception { public void testNestedQueryWithFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("_doc") .startObject("properties") .startObject("section") .field("type", "nested") @@ -1993,9 +1985,8 @@ public void testNestedQueryWithFieldAlias() throws Exception { .endObject() .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("index").addMapping("_doc", mapping)); + assertAcked(prepareCreate("index").setMapping(mapping)); XContentBuilder source = XContentFactory.jsonBuilder() .startObject() @@ -2019,7 +2010,6 @@ public void testNestedQueryWithFieldAlias() throws Exception { public void testFieldAliasesForMetaFields() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("id-alias") .field("type", "alias") @@ -2030,9 +2020,8 @@ public void testFieldAliasesForMetaFields() throws Exception { .field("path", "_routing") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("type", mapping)); + assertAcked(prepareCreate("test").setMapping(mapping)); IndexRequestBuilder indexRequest = client().prepareIndex("test").setId("1").setRouting("custom").setSource("field", "value"); indexRandom(true, false, indexRequest); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/SimpleQueryStringIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/SimpleQueryStringIT.java index c53eda63f155f..e0391d9cbc971 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/SimpleQueryStringIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/SimpleQueryStringIT.java @@ -239,10 +239,8 @@ public void testSimpleQueryStringMinimumShouldMatch() throws Exception { public void testNestedFieldSimpleQueryString() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("body") .field("type", "text") @@ -253,7 +251,6 @@ public void testNestedFieldSimpleQueryString() throws IOException { .endObject() // fields .endObject() // body .endObject() // properties - .endObject() // type1 .endObject() ) ); @@ -607,19 +604,17 @@ public void testAllFieldsWithSpecifiedLeniency() throws IOException { public void testLimitOnExpandedFields() throws Exception { XContentBuilder builder = jsonBuilder(); builder.startObject(); - builder.startObject("type1"); builder.startObject("properties"); for (int i = 0; i < CLUSTER_MAX_CLAUSE_COUNT + 1; i++) { builder.startObject("field" + i).field("type", "text").endObject(); } builder.endObject(); // properties - builder.endObject(); // type1 builder.endObject(); assertAcked( prepareCreate("toomanyfields").setSettings( Settings.builder().put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), CLUSTER_MAX_CLAUSE_COUNT + 100) - ).addMapping("type1", builder) + ).setMapping(builder) ); client().prepareIndex("toomanyfields").setId("1").setSource("field1", "foo bar baz").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java index 3b120dcab22f2..3bc9eb5b25261 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java @@ -127,11 +127,7 @@ public void testCustomScriptBinaryField() throws Exception { final byte[] randomBytesDoc2 = getRandomBytes(16); assertAcked( - client().admin() - .indices() - .prepareCreate("my-index") - .addMapping("my-type", createMappingSource("binary")) - .setSettings(indexSettings()) + client().admin().indices().prepareCreate("my-index").setMapping(createMappingSource("binary")).setSettings(indexSettings()) ); client().prepareIndex("my-index") .setId("1") @@ -170,14 +166,12 @@ private byte[] getRandomBytes(int len) { private XContentBuilder createMappingSource(String fieldType) throws IOException { return XContentFactory.jsonBuilder() .startObject() - .startObject("my-type") .startObject("properties") .startObject("binaryData") .field("type", fieldType) .field("doc_values", "true") .endObject() .endObject() - .endObject() .endObject(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/scroll/DuelScrollIT.java b/server/src/internalClusterTest/java/org/opensearch/search/scroll/DuelScrollIT.java index be55193da30cc..19cf1ee3a0ee7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/scroll/DuelScrollIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/scroll/DuelScrollIT.java @@ -115,10 +115,8 @@ public void testDuelQueryThenFetch() throws Exception { private TestContext create(SearchType... searchTypes) throws Exception { assertAcked( - prepareCreate("index").addMapping( - "type", + prepareCreate("index").setMapping( jsonBuilder().startObject() - .startObject("type") .startObject("properties") .startObject("field1") .field("type", "long") @@ -139,7 +137,6 @@ private TestContext create(SearchType... searchTypes) throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java index 38aac2850dc56..3d1d407b386e1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java @@ -276,11 +276,9 @@ public void testTrackScores() throws Exception { public void testRandomSorting() throws IOException, InterruptedException, ExecutionException { Random random = random(); assertAcked( - prepareCreate("test").addMapping( - "type", + prepareCreate("test").setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("sparse_bytes") .field("type", "keyword") @@ -290,7 +288,6 @@ public void testRandomSorting() throws IOException, InterruptedException, Execut .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -558,11 +555,9 @@ public void testIssue2991() { public void testSimpleSorts() throws Exception { Random random = random(); assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("str_value") .field("type", "keyword") @@ -590,7 +585,6 @@ public void testSimpleSorts() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -801,11 +795,9 @@ public void testSimpleSorts() throws Exception { public void testSortMissingNumbers() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("i_value") .field("type", "integer") @@ -815,7 +807,6 @@ public void testSortMissingNumbers() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -873,18 +864,15 @@ public void testSortMissingNumbers() throws Exception { public void testSortMissingStrings() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("value") .field("type", "keyword") .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -1009,11 +997,9 @@ public void testIgnoreUnmapped() throws Exception { public void testSortMVField() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("long_values") .field("type", "long") @@ -1038,7 +1024,6 @@ public void testSortMVField() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -1345,18 +1330,15 @@ public void testSortMVField() throws Exception { public void testSortOnRareField() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("string_values") .field("type", "keyword") .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -1494,11 +1476,9 @@ public void testSortMetaField() throws Exception { */ public void testNestedSort() throws IOException, InterruptedException, ExecutionException { assertAcked( - prepareCreate("test").addMapping( - "type", + prepareCreate("test").setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("nested") .field("type", "nested") @@ -1530,7 +1510,6 @@ public void testNestedSort() throws IOException, InterruptedException, Execution .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceIT.java index 1739add2ff5e8..5cc9ab77bcb2d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceIT.java @@ -72,12 +72,11 @@ public void testDistanceSortingMVFields() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("locations") .field("type", "geo_point"); - xContentBuilder.field("ignore_malformed", true).endObject().endObject().endObject().endObject(); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder)); + xContentBuilder.field("ignore_malformed", true).endObject().endObject().endObject(); + assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder)); ensureGreen(); client().prepareIndex("test") @@ -268,12 +267,11 @@ public void testDistanceSortingWithMissingGeoPoint() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("locations") .field("type", "geo_point"); - xContentBuilder.endObject().endObject().endObject().endObject(); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder)); + xContentBuilder.endObject().endObject().endObject(); + assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder)); ensureGreen(); client().prepareIndex("test") @@ -333,7 +331,6 @@ public void testDistanceSortingNestedFields() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() - .startObject("company") .startObject("properties") .startObject("name") .field("type", "text") @@ -346,9 +343,9 @@ public void testDistanceSortingNestedFields() throws Exception { .endObject() .startObject("location") .field("type", "geo_point"); - xContentBuilder.endObject().endObject().endObject().endObject().endObject().endObject(); + xContentBuilder.endObject().endObject().endObject().endObject().endObject(); - assertAcked(prepareCreate("companies").setSettings(settings).addMapping("company", xContentBuilder)); + assertAcked(prepareCreate("companies").setSettings(settings).setMapping(xContentBuilder)); ensureGreen(); indexRandom( @@ -590,15 +587,14 @@ public void testGeoDistanceFilter() throws IOException { XContentBuilder mapping = JsonXContent.contentBuilder() .startObject() - .startObject("location") .startObject("properties") .startObject("pin") .field("type", "geo_point"); - mapping.endObject().endObject().endObject().endObject(); + mapping.endObject().endObject().endObject(); XContentBuilder source = JsonXContent.contentBuilder().startObject().field("pin", Geohash.stringEncode(lon, lat)).endObject(); - assertAcked(prepareCreate("locations").setSettings(settings).addMapping("location", mapping)); + assertAcked(prepareCreate("locations").setSettings(settings).setMapping(mapping)); client().prepareIndex("locations").setId("1").setCreate(true).setSource(source).get(); refresh(); client().prepareGet("locations", "1").get(); @@ -614,12 +610,11 @@ public void testGeoDistanceFilter() throws IOException { public void testDistanceSortingWithUnmappedField() throws Exception { XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("locations") .field("type", "geo_point"); - xContentBuilder.endObject().endObject().endObject().endObject(); - assertAcked(prepareCreate("test1").addMapping("type1", xContentBuilder)); + xContentBuilder.endObject().endObject().endObject(); + assertAcked(prepareCreate("test1").setMapping(xContentBuilder)); assertAcked(prepareCreate("test2")); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/SimpleSortIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/SimpleSortIT.java index 70bb24532aa7d..8ff0790e7cb48 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/SimpleSortIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/SimpleSortIT.java @@ -134,10 +134,8 @@ static > T getMinValueScript( public void testSimpleSorts() throws Exception { Random random = random(); assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("str_value") .field("type", "keyword") @@ -165,7 +163,6 @@ public void testSimpleSorts() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); @@ -446,17 +443,14 @@ public void testDocumentsWithNullValue() throws Exception { public void test2920() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "test", + prepareCreate("test").setMapping( jsonBuilder().startObject() - .startObject("test") .startObject("properties") .startObject("value") .field("type", "keyword") .endObject() .endObject() .endObject() - .endObject() ) ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/suggest/CompletionSuggestSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/suggest/CompletionSuggestSearchIT.java index e85eff8450ca4..690564fe1cac8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/suggest/CompletionSuggestSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/suggest/CompletionSuggestSearchIT.java @@ -682,15 +682,13 @@ public void testThatDisablingPositionIncrementsWorkForStopwords() throws Excepti public void testThatUpgradeToMultiFieldsWorks() throws Exception { final XContentBuilder mapping = jsonBuilder().startObject() - .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject(FIELD) .field("type", "text") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate(INDEX).addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)); + assertAcked(prepareCreate(INDEX).setMapping(mapping)); client().prepareIndex(INDEX) .setId("1") .setRefreshPolicy(IMMEDIATE) @@ -1328,7 +1326,7 @@ private void createIndexAndMappingAndSettings(Settings settings, CompletionMappi .indices() .prepareCreate(INDEX) .setSettings(Settings.builder().put(indexSettings()).put(settings)) - .addMapping(MapperService.SINGLE_MAPPING_NAME, mapping) + .setMapping(mapping) .get() ); } @@ -1376,17 +1374,14 @@ public void testVeryLongInput() throws IOException { client().admin() .indices() .prepareCreate(INDEX) - .addMapping( - MapperService.SINGLE_MAPPING_NAME, + .setMapping( jsonBuilder().startObject() - .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject(FIELD) .field("type", "completion") .endObject() .endObject() .endObject() - .endObject() ) .get() ); @@ -1408,17 +1403,14 @@ public void testReservedChars() throws IOException { client().admin() .indices() .prepareCreate(INDEX) - .addMapping( - MapperService.SINGLE_MAPPING_NAME, + .setMapping( jsonBuilder().startObject() - .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject(FIELD) .field("type", "completion") .endObject() .endObject() .endObject() - .endObject() ) .get() ); @@ -1449,17 +1441,14 @@ public void testIssue5930() throws IOException { client().admin() .indices() .prepareCreate(INDEX) - .addMapping( - MapperService.SINGLE_MAPPING_NAME, + .setMapping( jsonBuilder().startObject() - .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject(FIELD) .field("type", "completion") .endObject() .endObject() .endObject() - .endObject() ) .get() ); @@ -1508,7 +1497,6 @@ public void testMultiDocSuggestions() throws Exception { public void testSuggestWithFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject(FIELD) .field("type", "completion") @@ -1518,9 +1506,8 @@ public void testSuggestWithFieldAlias() throws Exception { .field("path", FIELD) .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate(INDEX).addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)); + assertAcked(prepareCreate(INDEX).setMapping(mapping)); List builders = new ArrayList<>(); builders.add(client().prepareIndex(INDEX).setSource(FIELD, "apple")); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/suggest/ContextCompletionSuggestSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/suggest/ContextCompletionSuggestSearchIT.java index acc4350d149cd..27d3d455330f5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/suggest/ContextCompletionSuggestSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/suggest/ContextCompletionSuggestSearchIT.java @@ -42,7 +42,6 @@ import org.opensearch.common.unit.Fuzziness; import org.opensearch.common.xcontent.ToXContent; import org.opensearch.common.xcontent.XContentBuilder; -import org.opensearch.index.mapper.MapperService; import org.opensearch.rest.RestStatus; import org.opensearch.search.suggest.CompletionSuggestSearchIT.CompletionMappingBuilder; import org.opensearch.search.suggest.completion.CompletionSuggestionBuilder; @@ -608,7 +607,7 @@ public void testGeoField() throws Exception { mapping.endObject(); mapping.endObject(); - assertAcked(prepareCreate(INDEX).addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)); + assertAcked(prepareCreate(INDEX).setMapping(mapping)); XContentBuilder source1 = jsonBuilder().startObject() .startObject("location") @@ -754,7 +753,7 @@ private void createIndexAndMappingAndSettings(Settings settings, CompletionMappi .indices() .prepareCreate(INDEX) .setSettings(Settings.builder().put(indexSettings()).put(settings)) - .addMapping(MapperService.SINGLE_MAPPING_NAME, mapping) + .setMapping(mapping) .get() ); } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java index bb6e1643dd767..cd3921d91a3ed 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java @@ -127,16 +127,14 @@ public void testSuggestAcrossMultipleIndices() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("text") .field("type", "text") .field("analyzer", "keyword") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test_2").addMapping("type1", mapping)); + assertAcked(prepareCreate("test_2").setMapping(mapping)); ensureGreen(); index("test_2", "type1", "1", "text", "ab cd"); @@ -217,7 +215,6 @@ public void testSuggestModes() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("name") .field("type", "text") @@ -230,9 +227,8 @@ public void testSuggestModes() throws IOException { .endObject() .endObject() .endObject() - .endObject() .endObject(); - assertAcked(builder.addMapping("type1", mapping)); + assertAcked(builder.setMapping(mapping)); ensureGreen(); index("test", "type1", "1", "name", "I like iced tea"); @@ -300,7 +296,6 @@ public void testUnmappedField() throws IOException, InterruptedException, Execut ); XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("name") .field("type", "text") @@ -313,9 +308,8 @@ public void testUnmappedField() throws IOException, InterruptedException, Execut .endObject() .endObject() .endObject() - .endObject() .endObject(); - assertAcked(builder.addMapping("type1", mapping)); + assertAcked(builder.setMapping(mapping)); ensureGreen(); indexRandom( @@ -558,7 +552,6 @@ public void testPrefixLength() throws IOException { ); XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("body") .field("type", "text") @@ -569,9 +562,8 @@ public void testPrefixLength() throws IOException { .field("analyzer", "bigram") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(builder.addMapping("type1", mapping)); + assertAcked(builder.setMapping(mapping)); ensureGreen(); index("test", "type1", "1", "body", "hello world"); @@ -614,7 +606,6 @@ public void testBasicPhraseSuggest() throws IOException, URISyntaxException { ); XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("body") .field("type", "text") @@ -625,9 +616,8 @@ public void testBasicPhraseSuggest() throws IOException, URISyntaxException { .field("analyzer", "bigram") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(builder.addMapping("type1", mapping)); + assertAcked(builder.setMapping(mapping)); ensureGreen(); String[] strings = new String[] { @@ -758,7 +748,6 @@ public void testSizeParam() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("body") .field("type", "text") @@ -769,9 +758,8 @@ public void testSizeParam() throws IOException { .field("analyzer", "bigram") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(builder.addMapping("type1", mapping)); + assertAcked(builder.setMapping(mapping)); ensureGreen(); String line = "xorr the god jewel"; @@ -833,16 +821,14 @@ public void testShardFailures() throws IOException, InterruptedException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type2") .startObject("properties") .startObject("name") .field("type", "text") .field("analyzer", "suggest") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(builder.addMapping("type2", mapping)); + assertAcked(builder.setMapping(mapping)); ensureGreen(); index("test", "type2", "1", "foo", "bar"); @@ -880,14 +866,12 @@ public void testShardFailures() throws IOException, InterruptedException { public void testEmptyShards() throws IOException, InterruptedException { XContentBuilder mappingBuilder = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("name") .field("type", "text") .field("analyzer", "suggest") .endObject() .endObject() - .endObject() .endObject(); assertAcked( prepareCreate("test").setSettings( @@ -901,7 +885,7 @@ public void testEmptyShards() throws IOException, InterruptedException { .put("index.analysis.filter.shingler.min_shingle_size", 2) .put("index.analysis.filter.shingler.max_shingle_size", 5) .put("index.analysis.filter.shingler.output_unigrams", true) - ).addMapping("type1", mappingBuilder) + ).setMapping(mappingBuilder) ); ensureGreen(); @@ -978,16 +962,14 @@ public void testSearchForRarePhrase() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("body") .field("type", "text") .field("analyzer", "body") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(builder.addMapping("type1", mapping)); + assertAcked(builder.setMapping(mapping)); ensureGreen(); NumShards test = getNumShards("test"); @@ -1039,16 +1021,14 @@ public void testSuggestWithManyCandidates() throws InterruptedException, Executi XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("title") .field("type", "text") .field("analyzer", "text") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(builder.addMapping("type1", mapping)); + assertAcked(builder.setMapping(mapping)); ensureGreen(); List titles = new ArrayList<>(); @@ -1166,7 +1146,6 @@ public void testSuggestWithManyCandidates() throws InterruptedException, Executi public void testSuggestWithFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("text") .field("type", "keyword") @@ -1176,9 +1155,8 @@ public void testSuggestWithFieldAlias() throws Exception { .field("path", "text") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("type", mapping)); + assertAcked(prepareCreate("test").setMapping(mapping)); List builders = new ArrayList<>(); builders.add(client().prepareIndex("test").setSource("text", "apple")); @@ -1195,17 +1173,13 @@ public void testSuggestWithFieldAlias() throws Exception { public void testPhraseSuggestMinDocFreq() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("text") .field("type", "keyword") .endObject() .endObject() - .endObject() .endObject(); - assertAcked( - prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", 1).build()).addMapping("type", mapping) - ); + assertAcked(prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", 1).build()).setMapping(mapping)); List builders = new ArrayList<>(); builders.add(client().prepareIndex("test").setSource("text", "apple")); @@ -1298,16 +1272,14 @@ public void testPhraseSuggesterCollate() throws InterruptedException, ExecutionE XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("title") .field("type", "text") .field("analyzer", "text") .endObject() .endObject() - .endObject() .endObject(); - assertAcked(builder.addMapping("type1", mapping)); + assertAcked(builder.setMapping(mapping)); ensureGreen(); List titles = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/similarity/SimilarityIT.java b/server/src/internalClusterTest/java/org/opensearch/similarity/SimilarityIT.java index 57c14876b25ff..929aac388b678 100644 --- a/server/src/internalClusterTest/java/org/opensearch/similarity/SimilarityIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/similarity/SimilarityIT.java @@ -53,10 +53,8 @@ public void testCustomBM25Similarity() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping( - "type1", + .setMapping( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("similarity", "custom") @@ -68,7 +66,6 @@ public void testCustomBM25Similarity() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .setSettings( Settings.builder() diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java index 8b38308d39c93..b234561563e56 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java @@ -248,28 +248,33 @@ public CreateIndexRequest mapping(String mapping) { /** * Adds mapping that will be added when the index gets created. * - * @param type The mapping type * @param source The mapping source * @param xContentType the content type of the mapping source * @deprecated types are being removed */ @Deprecated - private CreateIndexRequest mapping(String type, BytesReference source, XContentType xContentType) { + private CreateIndexRequest mapping(BytesReference source, XContentType xContentType) { Objects.requireNonNull(xContentType); Map mappingAsMap = XContentHelper.convertToMap(source, false, xContentType).v2(); - return mapping(type, mappingAsMap); + return mapping(MapperService.SINGLE_MAPPING_NAME, mappingAsMap); } /** * Adds mapping that will be added when the index gets created. * - * @param type The mapping type * @param source The mapping source - * @deprecated types are being removed */ - @Deprecated - public CreateIndexRequest mapping(String type, XContentBuilder source) { - return mapping(type, BytesReference.bytes(source), source.contentType()); + public CreateIndexRequest mapping(XContentBuilder source) { + return mapping(BytesReference.bytes(source), source.contentType()); + } + + /** + * Set the mapping for this index + * + * @param source The mapping source + */ + public CreateIndexRequest mapping(Map source) { + return mapping(MapperService.SINGLE_MAPPING_NAME, source); } /** @@ -280,7 +285,7 @@ public CreateIndexRequest mapping(String type, XContentBuilder source) { * @deprecated types are being removed */ @Deprecated - public CreateIndexRequest mapping(String type, Map source) { + private CreateIndexRequest mapping(String type, Map source) { // wrap it in a type map if its not if (source.size() != 1 || !source.containsKey(type)) { source = Collections.singletonMap(MapperService.SINGLE_MAPPING_NAME, source); @@ -304,7 +309,7 @@ public CreateIndexRequest mapping(String type, Map source) { */ @Deprecated public CreateIndexRequest mapping(String type, Object... source) { - mapping(type, PutMappingRequest.buildFromSimplifiedDef(source)); + mapping(PutMappingRequest.buildFromSimplifiedDef(source)); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java index 77e48d079cb5c..41f364517fd06 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java @@ -113,43 +113,28 @@ public CreateIndexRequestBuilder setSettings(Map source) { * * @param source The mapping source */ - @Deprecated public CreateIndexRequestBuilder setMapping(String source) { request.mapping(source); return this; } - /** - * The cause for this index creation. - */ - public CreateIndexRequestBuilder setCause(String cause) { - request.cause(cause); - return this; - } - /** * Adds mapping that will be added when the index gets created. * - * @param type The mapping type * @param source The mapping source - * @deprecated types are being removed */ - @Deprecated - public CreateIndexRequestBuilder addMapping(String type, XContentBuilder source) { - request.mapping(type, source); + public CreateIndexRequestBuilder setMapping(XContentBuilder source) { + request.mapping(source); return this; } /** * Adds mapping that will be added when the index gets created. * - * @param type The mapping type * @param source The mapping source - * @deprecated types are being removed */ - @Deprecated - public CreateIndexRequestBuilder addMapping(String type, Map source) { - request.mapping(type, source); + public CreateIndexRequestBuilder setMapping(Map source) { + request.mapping(source); return this; } @@ -164,6 +149,14 @@ public CreateIndexRequestBuilder addMapping(String type, Object... source) { return this; } + /** + * The cause for this index creation. + */ + public CreateIndexRequestBuilder setCause(String cause) { + request.cause(cause); + return this; + } + /** * Sets the aliases that will be associated with the index when it gets created */ diff --git a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequest.java index f06cb599a60df..402b3741205a2 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequest.java @@ -101,7 +101,7 @@ public class RolloverRequest extends AcknowledgedRequest implem if (MapperService.isMappingSourceTyped(MapperService.SINGLE_MAPPING_NAME, mappings)) { throw new IllegalArgumentException("The mapping definition cannot be nested under a type"); } - request.createIndexRequest.mapping(MapperService.SINGLE_MAPPING_NAME, mappings); + request.createIndexRequest.mapping(mappings); }, CreateIndexRequest.MAPPINGS, ObjectParser.ValueType.OBJECT); PARSER.declareField( (parser, request, context) -> request.createIndexRequest.aliases(parser.map()), diff --git a/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexRequestTests.java index 320db79428300..31039826868ac 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/create/CreateIndexRequestTests.java @@ -116,10 +116,10 @@ public void testMappingKeyedByType() throws IOException { .endObject() .endObject() .endObject(); - request1.mapping("type1", builder); + request1.mapping(builder); builder = XContentFactory.contentBuilder(randomFrom(XContentType.values())); builder.startObject() - .startObject("type1") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("field1") .field("type", "text") @@ -134,7 +134,7 @@ public void testMappingKeyedByType() throws IOException { .endObject() .endObject() .endObject(); - request2.mapping("type1", builder); + request2.mapping(builder); assertEquals(request1.mappings(), request2.mappings()); } } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java index fd6fc3b6839d7..ab401b7d45792 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java @@ -160,7 +160,7 @@ private static PutMappingRequest createTestItem() throws IOException { String index = randomAlphaOfLength(5); PutMappingRequest request = new PutMappingRequest(index); - request.source(RandomCreateIndexGenerator.randomMapping("_doc")); + request.source(RandomCreateIndexGenerator.randomMapping()); return request; } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/rollover/RolloverRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/rollover/RolloverRequestTests.java index 0fcc60e2a4087..079e5d388bbf4 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/rollover/RolloverRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/rollover/RolloverRequestTests.java @@ -218,8 +218,7 @@ public void testValidation() { private static RolloverRequest createTestItem() throws IOException { RolloverRequest rolloverRequest = new RolloverRequest(); if (randomBoolean()) { - rolloverRequest.getCreateIndexRequest() - .mapping(MapperService.SINGLE_MAPPING_NAME, RandomCreateIndexGenerator.randomMapping(MapperService.SINGLE_MAPPING_NAME)); + rolloverRequest.getCreateIndexRequest().mapping(RandomCreateIndexGenerator.randomMapping()); } if (randomBoolean()) { RandomCreateIndexGenerator.randomAliases(rolloverRequest.getCreateIndexRequest()); diff --git a/server/src/test/java/org/opensearch/action/admin/indices/stats/IndicesStatsTests.java b/server/src/test/java/org/opensearch/action/admin/indices/stats/IndicesStatsTests.java index 6a84c5894fceb..171639083be58 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/stats/IndicesStatsTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/stats/IndicesStatsTests.java @@ -67,7 +67,6 @@ public void testSegmentStats() throws Exception { IndexModule.Type storeType = IndexModule.defaultStoreType(true); XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("doc") .startObject("properties") .startObject("foo") .field("type", "keyword") @@ -82,13 +81,12 @@ public void testSegmentStats() throws Exception { .field("type", "long") .endObject() .endObject() - .endObject() .endObject(); assertAcked( client().admin() .indices() .prepareCreate("test") - .addMapping("doc", mapping) + .setMapping(mapping) .setSettings(Settings.builder().put("index.store.type", storeType.getSettingsKey())) ); ensureGreen("test"); diff --git a/server/src/test/java/org/opensearch/action/termvectors/AbstractTermVectorsTestCase.java b/server/src/test/java/org/opensearch/action/termvectors/AbstractTermVectorsTestCase.java index 78214334928a4..d9613176c0156 100644 --- a/server/src/test/java/org/opensearch/action/termvectors/AbstractTermVectorsTestCase.java +++ b/server/src/test/java/org/opensearch/action/termvectors/AbstractTermVectorsTestCase.java @@ -219,16 +219,16 @@ public String toString() { protected void createIndexBasedOnFieldSettings(String index, String alias, TestFieldSetting[] fieldSettings) throws IOException { XContentBuilder mappingBuilder = jsonBuilder(); - mappingBuilder.startObject().startObject("type1").startObject("properties"); + mappingBuilder.startObject().startObject("properties"); for (TestFieldSetting field : fieldSettings) { field.addToMappings(mappingBuilder); } - mappingBuilder.endObject().endObject().endObject(); + mappingBuilder.endObject().endObject(); Settings.Builder settings = Settings.builder() .put(indexSettings()) .put("index.analysis.analyzer.tv_test.tokenizer", "standard") .putList("index.analysis.analyzer.tv_test.filter", "lowercase"); - assertAcked(prepareCreate(index).addMapping("type1", mappingBuilder).setSettings(settings).addAlias(new Alias(alias))); + assertAcked(prepareCreate(index).setMapping(mappingBuilder).setSettings(settings).addAlias(new Alias(alias))); } /** diff --git a/server/src/test/java/org/opensearch/action/termvectors/GetTermVectorsTests.java b/server/src/test/java/org/opensearch/action/termvectors/GetTermVectorsTests.java index 5486d110c9329..1217efb883468 100644 --- a/server/src/test/java/org/opensearch/action/termvectors/GetTermVectorsTests.java +++ b/server/src/test/java/org/opensearch/action/termvectors/GetTermVectorsTests.java @@ -169,7 +169,6 @@ public void testRandomPayloadWithDelimitedPayloadTokenFilter() throws IOExceptio String queryString = createString(tokens, payloads, encoding, delimiter.charAt(0)); // create the mapping XContentBuilder mapping = jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("field") .field("type", "text") @@ -177,7 +176,6 @@ public void testRandomPayloadWithDelimitedPayloadTokenFilter() throws IOExceptio .field("analyzer", "payload_test") .endObject() .endObject() - .endObject() .endObject(); Settings setting = Settings.builder() .put("index.analysis.analyzer.payload_test.tokenizer", "mock-whitespace") diff --git a/server/src/test/java/org/opensearch/index/analysis/PreBuiltAnalyzerTests.java b/server/src/test/java/org/opensearch/index/analysis/PreBuiltAnalyzerTests.java index 9dfdbb4469956..d8e0a4ea3bc2e 100644 --- a/server/src/test/java/org/opensearch/index/analysis/PreBuiltAnalyzerTests.java +++ b/server/src/test/java/org/opensearch/index/analysis/PreBuiltAnalyzerTests.java @@ -114,14 +114,12 @@ public void testThatAnalyzersAreUsedInMapping() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("field") .field("type", "text") .field("analyzer", analyzerName) .endObject() .endObject() - .endObject() .endObject(); MapperService mapperService = createIndex("test", indexSettings, "type", mapping).mapperService(); diff --git a/server/src/test/java/org/opensearch/index/mapper/FieldFilterMapperPluginTests.java b/server/src/test/java/org/opensearch/index/mapper/FieldFilterMapperPluginTests.java index c0900cc40abff..1e5a212c59825 100644 --- a/server/src/test/java/org/opensearch/index/mapper/FieldFilterMapperPluginTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/FieldFilterMapperPluginTests.java @@ -101,7 +101,7 @@ public void testGetFieldMappings() { // as the one coming from a filtered index with same mappings GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("filtered").get(); MappingMetadata filtered = getMappingsResponse.getMappings().get("filtered"); - assertAcked(client().admin().indices().prepareCreate("test").addMapping("_doc", filtered.getSourceAsMap())); + assertAcked(client().admin().indices().prepareCreate("test").setMapping(filtered.getSourceAsMap())); GetFieldMappingsResponse response = client().admin().indices().prepareGetFieldMappings("test").setFields("*").get(); assertEquals(1, response.mappings().size()); assertFieldMappings(response.mappings().get("test"), FILTERED_FLAT_FIELDS); @@ -128,7 +128,7 @@ public void testFieldCapabilities() { // as the one coming from a filtered index with same mappings GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("filtered").get(); MappingMetadata filteredMapping = getMappingsResponse.getMappings().get("filtered"); - assertAcked(client().admin().indices().prepareCreate("test").addMapping("_doc", filteredMapping.getSourceAsMap())); + assertAcked(client().admin().indices().prepareCreate("test").setMapping(filteredMapping.getSourceAsMap())); FieldCapabilitiesResponse test = client().fieldCaps(new FieldCapabilitiesRequest().fields("*").indices("test")).actionGet(); // properties.value is an object field in the new mapping filteredFields.add("properties.value"); @@ -176,7 +176,7 @@ private void assertExpectedMappings(ImmutableOpenMap ma private void assertMappingsAreValid(Map sourceAsMap) { // check that the returned filtered mappings are still valid mappings by submitting them and retrieving them back - assertAcked(client().admin().indices().prepareCreate("test").addMapping("_doc", sourceAsMap)); + assertAcked(client().admin().indices().prepareCreate("test").setMapping(sourceAsMap)); GetMappingsResponse testMappingsResponse = client().admin().indices().prepareGetMappings("test").get(); assertEquals(1, testMappingsResponse.getMappings().size()); // the mappings are returned unfiltered for this index, yet they are the same as the previous ones that were returned filtered diff --git a/server/src/test/java/org/opensearch/index/search/NestedHelperTests.java b/server/src/test/java/org/opensearch/index/search/NestedHelperTests.java index 9164dba8a3f62..c02df8168afee 100644 --- a/server/src/test/java/org/opensearch/index/search/NestedHelperTests.java +++ b/server/src/test/java/org/opensearch/index/search/NestedHelperTests.java @@ -66,7 +66,6 @@ public void setUp() throws Exception { super.setUp(); XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("foo") .field("type", "keyword") @@ -110,7 +109,6 @@ public void setUp() throws Exception { .endObject() .endObject() .endObject() - .endObject() .endObject(); indexService = createIndex("index", Settings.EMPTY, "type", mapping); mapperService = indexService.mapperService(); diff --git a/server/src/test/java/org/opensearch/index/similarity/SimilarityTests.java b/server/src/test/java/org/opensearch/index/similarity/SimilarityTests.java index 418b933558e63..625064820df44 100644 --- a/server/src/test/java/org/opensearch/index/similarity/SimilarityTests.java +++ b/server/src/test/java/org/opensearch/index/similarity/SimilarityTests.java @@ -100,14 +100,12 @@ public void testResolveSimilaritiesFromMapping_classicIsForbidden() throws IOExc public void testResolveSimilaritiesFromMapping_bm25() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("field1") .field("type", "text") .field("similarity", "my_similarity") .endObject() .endObject() - .endObject() .endObject(); Settings indexSettings = Settings.builder() @@ -131,14 +129,12 @@ public void testResolveSimilaritiesFromMapping_bm25() throws IOException { public void testResolveSimilaritiesFromMapping_boolean() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("field1") .field("type", "text") .field("similarity", "boolean") .endObject() .endObject() - .endObject() .endObject(); MapperService mapperService = createIndex("foo", Settings.EMPTY, "type", mapping).mapperService(); @@ -148,14 +144,12 @@ public void testResolveSimilaritiesFromMapping_boolean() throws IOException { public void testResolveSimilaritiesFromMapping_DFR() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("field1") .field("type", "text") .field("similarity", "my_similarity") .endObject() .endObject() - .endObject() .endObject(); Settings indexSettings = Settings.builder() @@ -178,14 +172,12 @@ public void testResolveSimilaritiesFromMapping_DFR() throws IOException { public void testResolveSimilaritiesFromMapping_IB() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("field1") .field("type", "text") .field("similarity", "my_similarity") .endObject() .endObject() - .endObject() .endObject(); Settings indexSettings = Settings.builder() @@ -208,14 +200,12 @@ public void testResolveSimilaritiesFromMapping_IB() throws IOException { public void testResolveSimilaritiesFromMapping_DFI() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("field1") .field("type", "text") .field("similarity", "my_similarity") .endObject() .endObject() - .endObject() .endObject(); Settings indexSettings = Settings.builder() @@ -233,14 +223,12 @@ public void testResolveSimilaritiesFromMapping_DFI() throws IOException { public void testResolveSimilaritiesFromMapping_LMDirichlet() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("field1") .field("type", "text") .field("similarity", "my_similarity") .endObject() .endObject() - .endObject() .endObject(); Settings indexSettings = Settings.builder() @@ -261,14 +249,12 @@ public void testResolveSimilaritiesFromMapping_LMDirichlet() throws IOException public void testResolveSimilaritiesFromMapping_LMJelinekMercer() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("field1") .field("type", "text") .field("similarity", "my_similarity") .endObject() .endObject() - .endObject() .endObject(); Settings indexSettings = Settings.builder() @@ -292,7 +278,6 @@ public void testResolveSimilaritiesFromMapping_Unknown() throws IOException { String mapping = Strings.toString( XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("field1") .field("type", "text") @@ -300,7 +285,6 @@ public void testResolveSimilaritiesFromMapping_Unknown() throws IOException { .endObject() .endObject() .endObject() - .endObject() ); IndexService indexService = createIndex("foo"); diff --git a/server/src/test/java/org/opensearch/index/termvectors/TermVectorsServiceTests.java b/server/src/test/java/org/opensearch/index/termvectors/TermVectorsServiceTests.java index f35911c8a3553..60694c7d6d61a 100644 --- a/server/src/test/java/org/opensearch/index/termvectors/TermVectorsServiceTests.java +++ b/server/src/test/java/org/opensearch/index/termvectors/TermVectorsServiceTests.java @@ -60,14 +60,12 @@ public class TermVectorsServiceTests extends OpenSearchSingleNodeTestCase { public void testTook() throws Exception { XContentBuilder mapping = jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("field") .field("type", "text") .field("term_vector", "with_positions_offsets_payloads") .endObject() .endObject() - .endObject() .endObject(); createIndex("test", Settings.EMPTY, "type1", mapping); ensureGreen(); @@ -90,14 +88,12 @@ public void testTook() throws Exception { public void testDocFreqs() throws IOException { XContentBuilder mapping = jsonBuilder().startObject() - .startObject("_doc") .startObject("properties") .startObject("text") .field("type", "text") .field("term_vector", "with_positions_offsets_payloads") .endObject() .endObject() - .endObject() .endObject(); Settings settings = Settings.builder().put("number_of_shards", 1).build(); createIndex("test", settings, "_doc", mapping); @@ -130,7 +126,6 @@ public void testDocFreqs() throws IOException { public void testWithIndexedPhrases() throws IOException { XContentBuilder mapping = jsonBuilder().startObject() - .startObject("_doc") .startObject("properties") .startObject("text") .field("type", "text") @@ -138,7 +133,6 @@ public void testWithIndexedPhrases() throws IOException { .field("term_vector", "with_positions_offsets_payloads") .endObject() .endObject() - .endObject() .endObject(); Settings settings = Settings.builder().put("number_of_shards", 1).build(); createIndex("test", settings, "_doc", mapping); diff --git a/server/src/test/java/org/opensearch/search/geo/GeoPointShapeQueryTests.java b/server/src/test/java/org/opensearch/search/geo/GeoPointShapeQueryTests.java index a2171e6eabab3..3d4c82da0107e 100644 --- a/server/src/test/java/org/opensearch/search/geo/GeoPointShapeQueryTests.java +++ b/server/src/test/java/org/opensearch/search/geo/GeoPointShapeQueryTests.java @@ -89,7 +89,7 @@ protected XContentBuilder createDefaultMapping() throws Exception { public void testProcessRelationSupport() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate("test").setMapping(xcb).get(); ensureGreen(); Rectangle rectangle = new Rectangle(-35, -25, -25, -35); @@ -112,7 +112,7 @@ public void testProcessRelationSupport() throws Exception { public void testQueryLine() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate("test").setMapping(xcb).get(); ensureGreen(); Line line = new Line(new double[] { -25, -25 }, new double[] { -35, -35 }); @@ -126,7 +126,7 @@ public void testQueryLine() throws Exception { public void testQueryLinearRing() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate("test").setMapping(xcb).get(); ensureGreen(); LinearRing linearRing = new LinearRing(new double[] { -25, -35, -25 }, new double[] { -25, -35, -25 }); @@ -148,7 +148,7 @@ public void testQueryLinearRing() throws Exception { public void testQueryMultiLine() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate("test").setMapping(xcb).get(); ensureGreen(); CoordinatesBuilder coords1 = new CoordinatesBuilder().coordinate(-35, -35).coordinate(-25, -25); @@ -167,7 +167,7 @@ public void testQueryMultiLine() throws Exception { public void testQueryMultiPoint() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate("test").setMapping(xcb).get(); ensureGreen(); MultiPointBuilder mpb = new MultiPointBuilder().coordinate(-35, -25).coordinate(-15, -5); @@ -182,7 +182,7 @@ public void testQueryMultiPoint() throws Exception { public void testQueryPoint() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate("test").setMapping(xcb).get(); ensureGreen(); PointBuilder pb = new PointBuilder().coordinate(-35, -25); diff --git a/server/src/test/java/org/opensearch/search/geo/GeoQueryTests.java b/server/src/test/java/org/opensearch/search/geo/GeoQueryTests.java index b46ac4a72952b..dfaadaa8875ca 100644 --- a/server/src/test/java/org/opensearch/search/geo/GeoQueryTests.java +++ b/server/src/test/java/org/opensearch/search/geo/GeoQueryTests.java @@ -82,7 +82,7 @@ protected Collection> getPlugins() { public void testNullShape() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate(defaultIndexName).addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get(); ensureGreen(); client().prepareIndex(defaultIndexName) @@ -96,7 +96,7 @@ public void testNullShape() throws Exception { public void testIndexPointsFilterRectangle() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate(defaultIndexName).addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get(); ensureGreen(); client().prepareIndex(defaultIndexName) @@ -134,7 +134,7 @@ public void testIndexPointsFilterRectangle() throws Exception { public void testIndexPointsCircle() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate(defaultIndexName).addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get(); ensureGreen(); client().prepareIndex(defaultIndexName) @@ -167,7 +167,7 @@ public void testIndexPointsCircle() throws Exception { public void testIndexPointsPolygon() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate(defaultIndexName).addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get(); ensureGreen(); client().prepareIndex(defaultIndexName) @@ -203,7 +203,7 @@ public void testIndexPointsPolygon() throws Exception { public void testIndexPointsMultiPolygon() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate(defaultIndexName).addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get(); ensureGreen(); client().prepareIndex(defaultIndexName) @@ -257,7 +257,7 @@ public void testIndexPointsMultiPolygon() throws Exception { public void testIndexPointsRectangle() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate(defaultIndexName).addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get(); ensureGreen(); client().prepareIndex(defaultIndexName) @@ -285,7 +285,7 @@ public void testIndexPointsRectangle() throws Exception { public void testIndexPointsIndexedRectangle() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate(defaultIndexName).addMapping(defaultIndexName, xcb).get(); + client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get(); ensureGreen(); client().prepareIndex(defaultIndexName) @@ -310,7 +310,7 @@ public void testIndexPointsIndexedRectangle() throws Exception { .endObject() .endObject() .endObject(); - client().admin().indices().prepareCreate(indexedShapeIndex).addMapping(defaultIndexName, xcb).get(); + client().admin().indices().prepareCreate(indexedShapeIndex).setMapping(xcb).get(); ensureGreen(); client().prepareIndex(indexedShapeIndex) @@ -352,7 +352,7 @@ public void testIndexPointsIndexedRectangle() throws Exception { public void testRectangleSpanningDateline() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate("test").setMapping(xcb).get(); ensureGreen(); client().prepareIndex(defaultIndexName) @@ -385,7 +385,7 @@ public void testRectangleSpanningDateline() throws Exception { public void testPolygonSpanningDateline() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate("test").setMapping(xcb).get(); ensureGreen(); client().prepareIndex(defaultIndexName) @@ -429,7 +429,7 @@ public void testPolygonSpanningDateline() throws Exception { public void testMultiPolygonSpanningDateline() throws Exception { XContentBuilder xcb = createDefaultMapping(); - client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get(); + client().admin().indices().prepareCreate("test").setMapping(xcb).get(); ensureGreen(); client().prepareIndex(defaultIndexName) diff --git a/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java b/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java index 61458512b84e4..4247a2ccabff2 100644 --- a/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java +++ b/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java @@ -262,7 +262,7 @@ public void testRandomGeoCollectionQuery() throws Exception { XContentBuilder mapping = createRandomMapping(); Settings settings = Settings.builder().put("index.number_of_shards", 1).build(); - client().admin().indices().prepareCreate("test").addMapping("_doc", mapping).setSettings(settings).get(); + client().admin().indices().prepareCreate("test").setMapping(mapping).setSettings(settings).get(); ensureGreen(); XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("geo"), null).endObject(); @@ -282,7 +282,7 @@ public void testRandomGeoCollectionQuery() throws Exception { // Test for issue #34418 public void testEnvelopeSpanningDateline() throws Exception { XContentBuilder mapping = createDefaultMapping(); - client().admin().indices().prepareCreate("test").addMapping("_doc", mapping).get(); + client().admin().indices().prepareCreate("test").setMapping(mapping).get(); ensureGreen(); String doc1 = "{\"geo\": {\r\n" @@ -488,7 +488,7 @@ public void testEdgeCases() throws Exception { public void testIndexedShapeReferenceSourceDisabled() throws Exception { XContentBuilder mapping = createDefaultMapping(); - client().admin().indices().prepareCreate("test").addMapping("type1", mapping).get(); + client().admin().indices().prepareCreate("test").setMapping(mapping).get(); createIndex("shapes", Settings.EMPTY, "shape_type", "_source", "enabled=false"); ensureGreen(); @@ -612,7 +612,7 @@ public void testExistsQuery() throws Exception { GeometryCollectionBuilder gcb = RandomShapeGenerator.createGeometryCollection(random()); XContentBuilder builder = createRandomMapping(); - client().admin().indices().prepareCreate("test").addMapping("type", builder).execute().actionGet(); + client().admin().indices().prepareCreate("test").setMapping(builder).execute().actionGet(); XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("geo"), null).endObject(); client().prepareIndex("test").setId("1").setSource(docSource).setRefreshPolicy(IMMEDIATE).get(); @@ -748,7 +748,6 @@ public void testIndexedShapeReference() throws Exception { public void testFieldAlias() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") .startObject("properties") .startObject("location") .field("type", "geo_shape") @@ -759,7 +758,6 @@ public void testFieldAlias() throws IOException { .field("path", "location") .endObject() .endObject() - .endObject() .endObject(); createIndex("test", Settings.EMPTY, "type", mapping); @@ -786,7 +784,7 @@ public void testQueryRandomGeoCollection() throws Exception { gcb.shape(new PolygonBuilder(cb)); XContentBuilder builder = createRandomMapping(); - client().admin().indices().prepareCreate("test").addMapping("type", builder).get(); + client().admin().indices().prepareCreate("test").setMapping(builder).get(); XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("geo"), null).endObject(); client().prepareIndex("test").setId("1").setSource(docSource).setRefreshPolicy(IMMEDIATE).get(); diff --git a/server/src/test/java/org/opensearch/search/suggest/completion/CategoryContextMappingTests.java b/server/src/test/java/org/opensearch/search/suggest/completion/CategoryContextMappingTests.java index b2c54492b66d7..dc6cfdd281980 100644 --- a/server/src/test/java/org/opensearch/search/suggest/completion/CategoryContextMappingTests.java +++ b/server/src/test/java/org/opensearch/search/suggest/completion/CategoryContextMappingTests.java @@ -77,7 +77,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase { public void testIndexingWithNoContexts() throws Exception { String mapping = Strings.toString( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("completion") .field("type", "completion") @@ -90,7 +89,6 @@ public void testIndexingWithNoContexts() throws Exception { .endObject() .endObject() .endObject() - .endObject() ); DocumentMapper defaultMapper = createIndex("test").mapperService() @@ -129,7 +127,6 @@ public void testIndexingWithNoContexts() throws Exception { public void testIndexingWithSimpleContexts() throws Exception { String mapping = Strings.toString( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("completion") .field("type", "completion") @@ -142,7 +139,6 @@ public void testIndexingWithSimpleContexts() throws Exception { .endObject() .endObject() .endObject() - .endObject() ); DocumentMapper defaultMapper = createIndex("test").mapperService() @@ -176,7 +172,6 @@ public void testIndexingWithSimpleContexts() throws Exception { public void testIndexingWithSimpleNumberContexts() throws Exception { String mapping = Strings.toString( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("completion") .field("type", "completion") @@ -189,7 +184,6 @@ public void testIndexingWithSimpleNumberContexts() throws Exception { .endObject() .endObject() .endObject() - .endObject() ); DocumentMapper defaultMapper = createIndex("test").mapperService() @@ -223,7 +217,6 @@ public void testIndexingWithSimpleNumberContexts() throws Exception { public void testIndexingWithSimpleBooleanContexts() throws Exception { String mapping = Strings.toString( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("completion") .field("type", "completion") @@ -236,7 +229,6 @@ public void testIndexingWithSimpleBooleanContexts() throws Exception { .endObject() .endObject() .endObject() - .endObject() ); DocumentMapper defaultMapper = createIndex("test").mapperService() @@ -270,7 +262,6 @@ public void testIndexingWithSimpleBooleanContexts() throws Exception { public void testIndexingWithSimpleNULLContexts() throws Exception { String mapping = Strings.toString( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("completion") .field("type", "completion") @@ -283,7 +274,6 @@ public void testIndexingWithSimpleNULLContexts() throws Exception { .endObject() .endObject() .endObject() - .endObject() ); DocumentMapper defaultMapper = createIndex("test").mapperService() @@ -314,7 +304,6 @@ public void testIndexingWithSimpleNULLContexts() throws Exception { public void testIndexingWithContextList() throws Exception { String mapping = Strings.toString( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("completion") .field("type", "completion") @@ -327,7 +316,6 @@ public void testIndexingWithContextList() throws Exception { .endObject() .endObject() .endObject() - .endObject() ); DocumentMapper defaultMapper = createIndex("test").mapperService() @@ -359,7 +347,6 @@ public void testIndexingWithContextList() throws Exception { public void testIndexingWithMixedTypeContextList() throws Exception { String mapping = Strings.toString( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("completion") .field("type", "completion") @@ -372,7 +359,6 @@ public void testIndexingWithMixedTypeContextList() throws Exception { .endObject() .endObject() .endObject() - .endObject() ); DocumentMapper defaultMapper = createIndex("test").mapperService() @@ -404,7 +390,6 @@ public void testIndexingWithMixedTypeContextList() throws Exception { public void testIndexingWithMixedTypeContextListHavingNULL() throws Exception { String mapping = Strings.toString( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("completion") .field("type", "completion") @@ -417,7 +402,6 @@ public void testIndexingWithMixedTypeContextListHavingNULL() throws Exception { .endObject() .endObject() .endObject() - .endObject() ); DocumentMapper defaultMapper = createIndex("test").mapperService() @@ -443,7 +427,6 @@ public void testIndexingWithMixedTypeContextListHavingNULL() throws Exception { public void testIndexingWithMultipleContexts() throws Exception { String mapping = Strings.toString( jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("completion") .field("type", "completion") @@ -460,7 +443,6 @@ public void testIndexingWithMultipleContexts() throws Exception { .endObject() .endObject() .endObject() - .endObject() ); DocumentMapper defaultMapper = createIndex("test").mapperService() @@ -798,7 +780,6 @@ public void testQueryContextParsingMixedHavingNULL() throws Exception { public void testUnknownQueryContextParsing() throws Exception { XContentBuilder mapping = jsonBuilder().startObject() - .startObject("type1") .startObject("properties") .startObject("completion") .field("type", "completion") @@ -814,7 +795,6 @@ public void testUnknownQueryContextParsing() throws Exception { .endArray() .endObject() .endObject() - .endObject() .endObject(); MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService(); diff --git a/server/src/test/java/org/opensearch/search/suggest/completion/GeoContextMappingTests.java b/server/src/test/java/org/opensearch/search/suggest/completion/GeoContextMappingTests.java index 31cc2e73ff2a3..1a1f3b33f0646 100644 --- a/server/src/test/java/org/opensearch/search/suggest/completion/GeoContextMappingTests.java +++ b/server/src/test/java/org/opensearch/search/suggest/completion/GeoContextMappingTests.java @@ -245,7 +245,6 @@ public void testIndexingWithMultipleContexts() throws Exception { public void testMalformedGeoField() throws Exception { XContentBuilder mapping = jsonBuilder(); mapping.startObject(); - mapping.startObject("type1"); mapping.startObject("properties"); mapping.startObject("pin"); String type = randomFrom("text", "keyword", "long"); @@ -266,7 +265,6 @@ public void testMalformedGeoField() throws Exception { mapping.endObject(); - mapping.endObject(); mapping.endObject(); mapping.endObject(); @@ -281,7 +279,6 @@ public void testMalformedGeoField() throws Exception { public void testMissingGeoField() throws Exception { XContentBuilder mapping = jsonBuilder(); mapping.startObject(); - mapping.startObject("type1"); mapping.startObject("properties"); mapping.startObject("suggestion"); mapping.field("type", "completion"); @@ -298,7 +295,6 @@ public void testMissingGeoField() throws Exception { mapping.endObject(); - mapping.endObject(); mapping.endObject(); mapping.endObject(); diff --git a/test/framework/src/main/java/org/opensearch/index/RandomCreateIndexGenerator.java b/test/framework/src/main/java/org/opensearch/index/RandomCreateIndexGenerator.java index dbcbb0f65a491..1498a0b7b2d17 100644 --- a/test/framework/src/main/java/org/opensearch/index/RandomCreateIndexGenerator.java +++ b/test/framework/src/main/java/org/opensearch/index/RandomCreateIndexGenerator.java @@ -63,8 +63,7 @@ public static CreateIndexRequest randomCreateIndexRequest() throws IOException { CreateIndexRequest request = new CreateIndexRequest(index); randomAliases(request); if (randomBoolean()) { - String type = randomAlphaOfLength(5); - request.mapping(type, randomMapping(type)); + request.mapping(randomMapping()); } if (randomBoolean()) { request.settings(randomIndexSettings()); @@ -94,16 +93,15 @@ public static Settings randomIndexSettings() { } /** - * Creates a random mapping, with the mapping definition nested - * under the given type name. + * Creates a random mapping */ - public static XContentBuilder randomMapping(String type) throws IOException { + public static XContentBuilder randomMapping() throws IOException { XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values())); - builder.startObject().startObject(type); + builder.startObject(); randomMappingFields(builder, true); - builder.endObject().endObject(); + builder.endObject(); return builder; } diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java index 83e59e1edd8c8..fb4831f881092 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java @@ -310,7 +310,7 @@ protected IndexService createIndex(String index, Settings settings) { protected IndexService createIndex(String index, Settings settings, String type, XContentBuilder mappings) { CreateIndexRequestBuilder createIndexRequestBuilder = client().admin().indices().prepareCreate(index).setSettings(settings); if (type != null && mappings != null) { - createIndexRequestBuilder.addMapping(type, mappings); + createIndexRequestBuilder.setMapping(mappings); } return createIndex(index, createIndexRequestBuilder); } From f34a75381d40575c9859760a6be655acd5da2058 Mon Sep 17 00:00:00 2001 From: Suraj Singh <79435743+dreamer-89@users.noreply.github.com> Date: Thu, 17 Mar 2022 09:02:08 -0700 Subject: [PATCH 06/46] [Remove] Type metadata from ingest documents (#2491) Signed-off-by: Suraj Singh --- .../ingest/common/AppendProcessorTests.java | 2 +- .../ingest/common/SetProcessorTests.java | 2 +- .../ingest/SimulatePipelineRequest.java | 6 ---- .../org/opensearch/ingest/IngestDocument.java | 2 -- .../SimulatePipelineRequestParsingTests.java | 33 ++----------------- 5 files changed, 4 insertions(+), 41 deletions(-) diff --git a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/AppendProcessorTests.java b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/AppendProcessorTests.java index 9a507338df332..7caa63792f347 100644 --- a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/AppendProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/AppendProcessorTests.java @@ -147,7 +147,7 @@ public void testConvertScalarToList() throws Exception { public void testAppendMetadataExceptVersion() throws Exception { // here any metadata field value becomes a list, which won't make sense in most of the cases, // but support for append is streamlined like for set so we test it - Metadata randomMetadata = randomFrom(Metadata.INDEX, Metadata.TYPE, Metadata.ID, Metadata.ROUTING); + Metadata randomMetadata = randomFrom(Metadata.INDEX, Metadata.ID, Metadata.ROUTING); List values = new ArrayList<>(); Processor appendProcessor; if (randomBoolean()) { diff --git a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/SetProcessorTests.java b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/SetProcessorTests.java index 0e7ba5556fbf8..923757b605108 100644 --- a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/SetProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/SetProcessorTests.java @@ -116,7 +116,7 @@ public void testSetExistingNullFieldWithOverrideDisabled() throws Exception { } public void testSetMetadataExceptVersion() throws Exception { - Metadata randomMetadata = randomFrom(Metadata.INDEX, Metadata.TYPE, Metadata.ID, Metadata.ROUTING); + Metadata randomMetadata = randomFrom(Metadata.INDEX, Metadata.ID, Metadata.ROUTING); Processor processor = createSetProcessor(randomMetadata.getFieldName(), "_value", true, false); IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); processor.execute(ingestDocument); diff --git a/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineRequest.java b/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineRequest.java index 6223f25488d88..bc0317e076319 100644 --- a/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineRequest.java +++ b/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineRequest.java @@ -194,12 +194,6 @@ private static List parseDocs(Map config) { Map dataMap = (Map) object; Map document = ConfigurationUtils.readMap(null, null, dataMap, Fields.SOURCE); String index = ConfigurationUtils.readStringOrIntProperty(null, null, dataMap, Metadata.INDEX.getFieldName(), "_index"); - if (dataMap.containsKey(Metadata.TYPE.getFieldName())) { - deprecationLogger.deprecate( - "simulate_pipeline_with_types", - "[types removal] specifying _type in pipeline simulation requests is deprecated" - ); - } String id = ConfigurationUtils.readStringOrIntProperty(null, null, dataMap, Metadata.ID.getFieldName(), "_id"); String routing = ConfigurationUtils.readOptionalStringOrIntProperty(null, null, dataMap, Metadata.ROUTING.getFieldName()); Long version = null; diff --git a/server/src/main/java/org/opensearch/ingest/IngestDocument.java b/server/src/main/java/org/opensearch/ingest/IngestDocument.java index b496799c34dd0..b18946486f8c6 100644 --- a/server/src/main/java/org/opensearch/ingest/IngestDocument.java +++ b/server/src/main/java/org/opensearch/ingest/IngestDocument.java @@ -38,7 +38,6 @@ import org.opensearch.index.mapper.IndexFieldMapper; import org.opensearch.index.mapper.RoutingFieldMapper; import org.opensearch.index.mapper.SourceFieldMapper; -import org.opensearch.index.mapper.TypeFieldMapper; import org.opensearch.index.mapper.VersionFieldMapper; import org.opensearch.script.TemplateScript; @@ -846,7 +845,6 @@ public String toString() { public enum Metadata { INDEX(IndexFieldMapper.NAME), - TYPE(TypeFieldMapper.NAME), ID(IdFieldMapper.NAME), ROUTING(RoutingFieldMapper.NAME), VERSION(VersionFieldMapper.NAME), diff --git a/server/src/test/java/org/opensearch/action/ingest/SimulatePipelineRequestParsingTests.java b/server/src/test/java/org/opensearch/action/ingest/SimulatePipelineRequestParsingTests.java index c85c0a01de63e..36b1f8089fdea 100644 --- a/server/src/test/java/org/opensearch/action/ingest/SimulatePipelineRequestParsingTests.java +++ b/server/src/test/java/org/opensearch/action/ingest/SimulatePipelineRequestParsingTests.java @@ -57,7 +57,6 @@ import static org.opensearch.ingest.IngestDocument.Metadata.ID; import static org.opensearch.ingest.IngestDocument.Metadata.INDEX; import static org.opensearch.ingest.IngestDocument.Metadata.ROUTING; -import static org.opensearch.ingest.IngestDocument.Metadata.TYPE; import static org.opensearch.ingest.IngestDocument.Metadata.VERSION; import static org.opensearch.ingest.IngestDocument.Metadata.VERSION_TYPE; import static org.opensearch.ingest.IngestDocument.Metadata.IF_SEQ_NO; @@ -132,15 +131,7 @@ public void testParseUsingPipelineStore(boolean useExplicitType) throws Exceptio assertThat(actualRequest.getPipeline().getProcessors().size(), equalTo(1)); } - public void testParseWithProvidedPipelineNoType() throws Exception { - innerTestParseWithProvidedPipeline(false); - } - - public void testParseWithProvidedPipelineWithType() throws Exception { - innerTestParseWithProvidedPipeline(true); - } - - private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws Exception { + public void innerTestParseWithProvidedPipeline() throws Exception { int numDocs = randomIntBetween(1, 10); Map requestContent = new HashMap<>(); @@ -150,16 +141,7 @@ private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws for (int i = 0; i < numDocs; i++) { Map doc = new HashMap<>(); Map expectedDoc = new HashMap<>(); - List fields = Arrays.asList( - INDEX, - TYPE, - ID, - ROUTING, - VERSION, - VERSION_TYPE, - IF_SEQ_NO, - IF_PRIMARY_TERM - ); + List fields = Arrays.asList(INDEX, ID, ROUTING, VERSION, VERSION_TYPE, IF_SEQ_NO, IF_PRIMARY_TERM); for (IngestDocument.Metadata field : fields) { if (field == VERSION) { Long value = randomLong(); @@ -173,14 +155,6 @@ private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws Long value = randomNonNegativeLong(); doc.put(field.getFieldName(), value); expectedDoc.put(field.getFieldName(), value); - } else if (field == TYPE) { - if (useExplicitType) { - String value = randomAlphaOfLengthBetween(1, 10); - doc.put(field.getFieldName(), value); - expectedDoc.put(field.getFieldName(), value); - } else { - expectedDoc.put(field.getFieldName(), "_doc"); - } } else { if (randomBoolean()) { String value = randomAlphaOfLengthBetween(1, 10); @@ -249,9 +223,6 @@ private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws assertThat(actualRequest.getPipeline().getId(), equalTo(SIMULATED_PIPELINE_ID)); assertThat(actualRequest.getPipeline().getDescription(), nullValue()); assertThat(actualRequest.getPipeline().getProcessors().size(), equalTo(numProcessors)); - if (useExplicitType) { - assertWarnings("[types removal] specifying _type in pipeline simulation requests is deprecated"); - } } public void testNullPipelineId() { From 2e3d3fef135442a59ec970c6bec7917467fa8d07 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Thu, 17 Mar 2022 12:05:24 -0500 Subject: [PATCH 07/46] [Remove] Type from PutIndexTemplateRequest and PITRB (#2497) Continues removal of types from PutIndexTemplateRequest and PutIndexTemplateRequestBuilder.mapping. Delegated mapping method in PutIndexTemplateRequestBuilder is refactored to setMapping for consistency with similar methods (e.g., setSettings, setAliases). Signed-off-by: Nicholas Walter Knize --- .../index/query/RankFeatureQueryBuilderTests.java | 2 +- .../percolator/PercolatorQuerySearchIT.java | 2 +- .../percolator/PercolateQueryBuilderTests.java | 4 ++-- .../PercolateWithNestedQueryBuilderTests.java | 2 +- .../document/AliasedIndexDocumentActionsIT.java | 2 +- .../java/org/opensearch/index/HiddenIndexIT.java | 10 +++++----- .../indices/template/SimpleIndexTemplateIT.java | 6 +++--- .../search/basic/TransportTwoNodesSearchIT.java | 2 +- .../search/searchafter/SearchAfterIT.java | 2 +- .../admin/indices/create/CreateIndexRequest.java | 6 ++---- .../indices/create/CreateIndexRequestBuilder.java | 4 ++-- .../indices/mapping/put/PutMappingRequest.java | 14 +++++++------- .../mapping/put/PutMappingRequestBuilder.java | 2 +- .../indices/rollover/RolloverRequestBuilder.java | 4 ++-- .../template/put/PutIndexTemplateRequest.java | 5 +++-- .../put/PutIndexTemplateRequestBuilder.java | 4 ++-- .../mapping/put/PutMappingRequestTests.java | 7 ++----- .../RangeFieldQueryStringQueryBuilderTests.java | 2 +- .../index/query/MatchQueryBuilderTests.java | 2 +- .../index/query/NestedQueryBuilderTests.java | 2 +- .../index/query/QueryStringQueryBuilderTests.java | 4 ++-- .../index/query/TermsSetQueryBuilderTests.java | 2 +- .../opensearch/test/AbstractBuilderTestCase.java | 2 +- .../test/OpenSearchSingleNodeTestCase.java | 2 +- 24 files changed, 45 insertions(+), 49 deletions(-) diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/query/RankFeatureQueryBuilderTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/query/RankFeatureQueryBuilderTests.java index b0d7bb9d2e14e..e183ba6f6735c 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/query/RankFeatureQueryBuilderTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/query/RankFeatureQueryBuilderTests.java @@ -62,7 +62,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws "_doc", new CompressedXContent( Strings.toString( - PutMappingRequest.buildFromSimplifiedDef( + PutMappingRequest.simpleMapping( "my_feature_field", "type=rank_feature", "my_negative_feature_field", diff --git a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java index 1cb5d81136de1..11fc61d6c6d99 100644 --- a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java @@ -565,7 +565,7 @@ public void testPercolatorQueryWithHighlighting() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", fieldMapping, "query", "type=percolator") + .addMapping("type", "id", "type=keyword", "field1", fieldMapping.toString(), "query", "type=percolator") ); client().prepareIndex("test") .setId("1") diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java index 12be15552652c..44d8d64086091 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java @@ -110,14 +110,14 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws docType, new CompressedXContent( Strings.toString( - PutMappingRequest.buildFromSimplifiedDef(queryField, "type=percolator", aliasField, "type=alias,path=" + queryField) + PutMappingRequest.simpleMapping(queryField, "type=percolator", aliasField, "type=alias,path=" + queryField) ) ), MapperService.MergeReason.MAPPING_UPDATE ); mapperService.merge( docType, - new CompressedXContent(Strings.toString(PutMappingRequest.buildFromSimplifiedDef(TEXT_FIELD_NAME, "type=text"))), + new CompressedXContent(Strings.toString(PutMappingRequest.simpleMapping(TEXT_FIELD_NAME, "type=text"))), MapperService.MergeReason.MAPPING_UPDATE ); } diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateWithNestedQueryBuilderTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateWithNestedQueryBuilderTests.java index 5038e72e9be5e..0ab9eff731bff 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateWithNestedQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateWithNestedQueryBuilderTests.java @@ -50,7 +50,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws super.initializeAdditionalMappings(mapperService); mapperService.merge( "_doc", - new CompressedXContent(Strings.toString(PutMappingRequest.buildFromSimplifiedDef("some_nested_object", "type=nested"))), + new CompressedXContent(Strings.toString(PutMappingRequest.simpleMapping("some_nested_object", "type=nested"))), MapperService.MergeReason.MAPPING_UPDATE ); } diff --git a/server/src/internalClusterTest/java/org/opensearch/document/AliasedIndexDocumentActionsIT.java b/server/src/internalClusterTest/java/org/opensearch/document/AliasedIndexDocumentActionsIT.java index de9db5f145116..1d9f7c1e39de2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/document/AliasedIndexDocumentActionsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/document/AliasedIndexDocumentActionsIT.java @@ -49,7 +49,7 @@ protected void createIndex() { logger.info("--> creating index test"); client().admin() .indices() - .create(createIndexRequest("test1").mapping("type1", "name", "type=keyword,store=true").alias(new Alias("test"))) + .create(createIndexRequest("test1").simpleMapping("name", "type=keyword,store=true").alias(new Alias("test"))) .actionGet(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/index/HiddenIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/index/HiddenIndexIT.java index 54fbc8cecb967..7d1c92cba3205 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/HiddenIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/HiddenIndexIT.java @@ -122,7 +122,7 @@ public void testGlobalTemplatesDoNotApply() { .indices() .preparePutTemplate("a_global_template") .setPatterns(Collections.singletonList("*")) - .addMapping("_doc", "foo", "type=text") + .setMapping("foo", "type=text") .get() ); assertAcked( @@ -130,7 +130,7 @@ public void testGlobalTemplatesDoNotApply() { .indices() .preparePutTemplate("not_global_template") .setPatterns(Collections.singletonList("a*")) - .addMapping("_doc", "bar", "type=text") + .setMapping("bar", "type=text") .get() ); assertAcked( @@ -138,7 +138,7 @@ public void testGlobalTemplatesDoNotApply() { .indices() .preparePutTemplate("specific_template") .setPatterns(Collections.singletonList("a_hidden_index")) - .addMapping("_doc", "baz", "type=text") + .setMapping("baz", "type=text") .get() ); assertAcked( @@ -146,7 +146,7 @@ public void testGlobalTemplatesDoNotApply() { .indices() .preparePutTemplate("unused_template") .setPatterns(Collections.singletonList("not_used")) - .addMapping("_doc", "foobar", "type=text") + .setMapping("foobar", "type=text") .get() ); @@ -192,7 +192,7 @@ public void testNonGlobalTemplateCanMakeIndexHidden() { .indices() .preparePutTemplate("a_global_template") .setPatterns(Collections.singletonList("my_hidden_pattern*")) - .addMapping("_doc", "foo", "type=text") + .setMapping("foo", "type=text") .setSettings(Settings.builder().put("index.hidden", true).build()) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java index 378657a6554b4..6065db46d8ee2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java @@ -554,7 +554,7 @@ public void testIndexTemplateWithAliases() throws Exception { .indices() .preparePutTemplate("template_with_aliases") .setPatterns(Collections.singletonList("te*")) - .addMapping("_doc", "type", "type=keyword", "field", "type=text") + .setMapping("type", "type=keyword", "field", "type=text") .addAlias(new Alias("simple_alias")) .addAlias(new Alias("templated_alias-{index}")) .addAlias(new Alias("filtered_alias").filter("{\"term\":{\"type\":\"type2\"}}")) @@ -820,7 +820,7 @@ public void testStrictAliasParsingInIndicesCreatedViaTemplates() throws Exceptio .preparePutTemplate("template1") .setPatterns(Collections.singletonList("a*")) .setOrder(0) - .addMapping("test", "field", "type=text") + .setMapping("field", "type=text") .addAlias(new Alias("alias1").filter(termQuery("field", "value"))) .get(); // Indexing into b index should fail, since there is field with name 'field' in the mapping @@ -930,7 +930,7 @@ public void testOrderAndVersion() { .setPatterns(Collections.singletonList("te*")) .setVersion(version) .setOrder(order) - .addMapping("test", "field", "type=text") + .setMapping("field", "type=text") .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportTwoNodesSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportTwoNodesSearchIT.java index 420121006a943..5cd6e76e1e487 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportTwoNodesSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportTwoNodesSearchIT.java @@ -96,7 +96,7 @@ private Set prepareData(int numShards) throws Exception { client().admin() .indices() - .create(createIndexRequest("test").settings(settingsBuilder).mapping("type", "foo", "type=geo_point")) + .create(createIndexRequest("test").settings(settingsBuilder).simpleMapping("foo", "type=geo_point")) .actionGet(); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java b/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java index b88e56b4f675d..aae6c1dec48b3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java @@ -323,7 +323,7 @@ private void createIndexMappingsFromObjectType(String indexName, String typeName fail("Can't match type [" + type + "]"); } } - indexRequestBuilder.addMapping(typeName, mappings.toArray()).get(); + indexRequestBuilder.addMapping(typeName, mappings.toArray(new String[0])).get(); ensureGreen(); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java index b234561563e56..7f1f516d13a04 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java @@ -305,11 +305,9 @@ private CreateIndexRequest mapping(String type, Map source) { /** * A specialized simplified mapping source method, takes the form of simple properties definition: * ("field1", "type=string,store=true"). - * @deprecated types are being removed */ - @Deprecated - public CreateIndexRequest mapping(String type, Object... source) { - mapping(PutMappingRequest.buildFromSimplifiedDef(source)); + public CreateIndexRequest simpleMapping(String... source) { + mapping(PutMappingRequest.simpleMapping(source)); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java index 41f364517fd06..ac80b3eb6a155 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java @@ -144,8 +144,8 @@ public CreateIndexRequestBuilder setMapping(Map source) { * @deprecated types are being removed */ @Deprecated - public CreateIndexRequestBuilder addMapping(String type, Object... source) { - request.mapping(type, source); + public CreateIndexRequestBuilder addMapping(String type, String... source) { + request.simpleMapping(source); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java index 52be45054ba55..be3e676a4a1a2 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java @@ -217,8 +217,8 @@ public String source() { * Also supports metadata mapping fields such as `_all` and `_parent` as property definition, these metadata * mapping fields will automatically be put on the top level mapping object. */ - public PutMappingRequest source(Object... source) { - return source(buildFromSimplifiedDef(source)); + public PutMappingRequest source(String... source) { + return source(simpleMapping(source)); } public String origin() { @@ -239,7 +239,7 @@ public PutMappingRequest origin(String origin) { * if the number of the source arguments is not divisible by two * @return the mappings definition */ - public static XContentBuilder buildFromSimplifiedDef(Object... source) { + public static XContentBuilder simpleMapping(String... source) { if (source.length % 2 != 0) { throw new IllegalArgumentException("mapping source must be pairs of fieldnames and properties definition."); } @@ -248,10 +248,10 @@ public static XContentBuilder buildFromSimplifiedDef(Object... source) { builder.startObject(); for (int i = 0; i < source.length; i++) { - String fieldName = source[i++].toString(); + String fieldName = source[i++]; if (RESERVED_FIELDS.contains(fieldName)) { builder.startObject(fieldName); - String[] s1 = Strings.splitStringByCommaToArray(source[i].toString()); + String[] s1 = Strings.splitStringByCommaToArray(source[i]); for (String s : s1) { String[] s2 = Strings.split(s, "="); if (s2.length != 2) { @@ -265,13 +265,13 @@ public static XContentBuilder buildFromSimplifiedDef(Object... source) { builder.startObject("properties"); for (int i = 0; i < source.length; i++) { - String fieldName = source[i++].toString(); + String fieldName = source[i++]; if (RESERVED_FIELDS.contains(fieldName)) { continue; } builder.startObject(fieldName); - String[] s1 = Strings.splitStringByCommaToArray(source[i].toString()); + String[] s1 = Strings.splitStringByCommaToArray(source[i]); for (String s : s1) { String[] s2 = Strings.split(s, "="); if (s2.length != 2) { diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java index a1b3b40d4e961..3ef96254b3f9b 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java @@ -102,7 +102,7 @@ public PutMappingRequestBuilder setSource(String mappingSource, XContentType xCo * A specialized simplified mapping source method, takes the form of simple properties definition: * ("field1", "type=string,store=true"). */ - public PutMappingRequestBuilder setSource(Object... source) { + public PutMappingRequestBuilder setSource(String... source) { request.source(source); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequestBuilder.java index a7af2f963d15b..c74f71a70e09d 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequestBuilder.java @@ -84,8 +84,8 @@ public RolloverRequestBuilder alias(Alias alias) { return this; } - public RolloverRequestBuilder mapping(String type, Object... source) { - this.request.getCreateIndexRequest().mapping(type, source); + public RolloverRequestBuilder simpleMapping(String... source) { + this.request.getCreateIndexRequest().simpleMapping(source); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index 2ea2e492ffe4d..d443d14f3f463 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -58,6 +58,7 @@ import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.common.xcontent.support.XContentMapValues; +import org.opensearch.index.mapper.MapperService; import java.io.IOException; import java.util.Collections; @@ -303,8 +304,8 @@ public PutIndexTemplateRequest mapping(String type, Map source) * A specialized simplified mapping source method, takes the form of simple properties definition: * ("field1", "type=string,store=true"). */ - public PutIndexTemplateRequest mapping(String type, Object... source) { - mapping(type, PutMappingRequest.buildFromSimplifiedDef(source)); + public PutIndexTemplateRequest mapping(String... source) { + mapping(MapperService.SINGLE_MAPPING_NAME, PutMappingRequest.simpleMapping(source)); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java index caff201abeda7..df3b5f6417576 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java @@ -137,8 +137,8 @@ public PutIndexTemplateRequestBuilder addMapping(String type, String source, XCo * A specialized simplified mapping source method, takes the form of simple properties definition: * ("field1", "type=string,store=true"). */ - public PutIndexTemplateRequestBuilder addMapping(String type, Object... source) { - request.mapping(type, source); + public PutIndexTemplateRequestBuilder setMapping(String... source) { + request.mapping(source); return this; } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java index ab401b7d45792..d8178769ba7b1 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java @@ -92,15 +92,12 @@ public void testValidation() { } /** - * Test that {@link PutMappingRequest#buildFromSimplifiedDef(Object...)} + * Test that {@link PutMappingRequest#simpleMapping(String...)} * rejects inputs where the {@code Object...} varargs of field name and properties are not * paired correctly */ public void testBuildFromSimplifiedDef() { - IllegalArgumentException e = expectThrows( - IllegalArgumentException.class, - () -> PutMappingRequest.buildFromSimplifiedDef("only_field") - ); + IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> PutMappingRequest.simpleMapping("only_field")); assertEquals("mapping source must be pairs of fieldnames and properties definition.", e.getMessage()); } diff --git a/server/src/test/java/org/opensearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java index 0a01d86e76dea..a8245627c6930 100644 --- a/server/src/test/java/org/opensearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java @@ -73,7 +73,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws "_doc", new CompressedXContent( Strings.toString( - PutMappingRequest.buildFromSimplifiedDef( + PutMappingRequest.simpleMapping( INTEGER_RANGE_FIELD_NAME, "type=integer_range", LONG_RANGE_FIELD_NAME, diff --git a/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java index dac32849e3cef..d6cd157d6f84e 100644 --- a/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java @@ -390,7 +390,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws "_doc", new CompressedXContent( Strings.toString( - PutMappingRequest.buildFromSimplifiedDef("string_boost", "type=text", "string_no_pos", "type=text,index_options=docs") + PutMappingRequest.simpleMapping("string_boost", "type=text", "string_no_pos", "type=text,index_options=docs") ) ), MapperService.MergeReason.MAPPING_UPDATE diff --git a/server/src/test/java/org/opensearch/index/query/NestedQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/NestedQueryBuilderTests.java index b95d9f8d36ad8..abc3e0bb8c4c3 100644 --- a/server/src/test/java/org/opensearch/index/query/NestedQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/NestedQueryBuilderTests.java @@ -77,7 +77,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws "_doc", new CompressedXContent( Strings.toString( - PutMappingRequest.buildFromSimplifiedDef( + PutMappingRequest.simpleMapping( TEXT_FIELD_NAME, "type=text", INT_FIELD_NAME, diff --git a/server/src/test/java/org/opensearch/index/query/QueryStringQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/QueryStringQueryBuilderTests.java index b091fc2103344..393d4cb3f2121 100644 --- a/server/src/test/java/org/opensearch/index/query/QueryStringQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/QueryStringQueryBuilderTests.java @@ -1096,7 +1096,7 @@ public void testDisabledFieldNamesField() throws Exception { .merge( "_doc", new CompressedXContent( - Strings.toString(PutMappingRequest.buildFromSimplifiedDef("foo", "type=text", "_field_names", "enabled=false")) + Strings.toString(PutMappingRequest.simpleMapping("foo", "type=text", "_field_names", "enabled=false")) ), MapperService.MergeReason.MAPPING_UPDATE ); @@ -1112,7 +1112,7 @@ public void testDisabledFieldNamesField() throws Exception { .merge( "_doc", new CompressedXContent( - Strings.toString(PutMappingRequest.buildFromSimplifiedDef("foo", "type=text", "_field_names", "enabled=true")) + Strings.toString(PutMappingRequest.simpleMapping("foo", "type=text", "_field_names", "enabled=true")) ), MapperService.MergeReason.MAPPING_UPDATE ); diff --git a/server/src/test/java/org/opensearch/index/query/TermsSetQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/TermsSetQueryBuilderTests.java index 3c39773108830..43ca3139e30cb 100644 --- a/server/src/test/java/org/opensearch/index/query/TermsSetQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/TermsSetQueryBuilderTests.java @@ -93,7 +93,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws String docType = "_doc"; mapperService.merge( docType, - new CompressedXContent(Strings.toString(PutMappingRequest.buildFromSimplifiedDef("m_s_m", "type=long"))), + new CompressedXContent(Strings.toString(PutMappingRequest.simpleMapping("m_s_m", "type=long"))), MapperService.MergeReason.MAPPING_UPDATE ); } diff --git a/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java b/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java index e5d14333de828..ae32db5fe6032 100644 --- a/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java @@ -438,7 +438,7 @@ public void onRemoval(ShardId shardId, Accountable accountable) { "_doc", new CompressedXContent( Strings.toString( - PutMappingRequest.buildFromSimplifiedDef( + PutMappingRequest.simpleMapping( TEXT_FIELD_NAME, "type=text", KEYWORD_FIELD_NAME, diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java index fb4831f881092..fe65d14bbcd0f 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java @@ -320,7 +320,7 @@ protected IndexService createIndex(String index, Settings settings, String type, * @deprecated types are being removed */ @Deprecated - protected IndexService createIndex(String index, Settings settings, String type, Object... mappings) { + protected IndexService createIndex(String index, Settings settings, String type, String... mappings) { CreateIndexRequestBuilder createIndexRequestBuilder = client().admin().indices().prepareCreate(index).setSettings(settings); if (type != null) { createIndexRequestBuilder.addMapping(type, mappings); From f14e0a36c48ecb8d2f58b37cc18e86d3b6836319 Mon Sep 17 00:00:00 2001 From: Suraj Singh <79435743+dreamer-89@users.noreply.github.com> Date: Thu, 17 Mar 2022 13:59:14 -0700 Subject: [PATCH 08/46] Add 1.3.0 release notes in main (#2489) * Add 1.3.0 release notes in main Signed-off-by: Suraj Singh * Address review comment. Removed dependabot commits and fix indentation, linings, incorrect blocks Signed-off-by: Suraj Singh * Self review of md file Signed-off-by: Suraj Singh --- .../opensearch.release-notes-1.3.0.md | 1299 +++++++++++++++++ 1 file changed, 1299 insertions(+) create mode 100644 release-notes/opensearch.release-notes-1.3.0.md diff --git a/release-notes/opensearch.release-notes-1.3.0.md b/release-notes/opensearch.release-notes-1.3.0.md new file mode 100644 index 0000000000000..62c5be8413943 --- /dev/null +++ b/release-notes/opensearch.release-notes-1.3.0.md @@ -0,0 +1,1299 @@ +## Version 1.3.0 Release Notes + +* __MapperService has to be passed in as null for EnginePlugins CodecService constructor (#2177) (#2413)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Wed, 9 Mar 2022 10:17:33 -0500 + + efs/remotes/os_or/1.3 + * MapperService has to be passed in as null for EnginePlugins CodecService + constructor + + * Addressing code review comments + + * Delayed CodecService instantiation up to the shard initialization + + * Added logger (associated with shard) to CodecServiceConfig + + * Refactored the EngineConfigFactory / IndexShard instantiation of the + CodecService + (cherry picked from commit 9c679cbbfcf685e3865d2cf06b8f4e10c3082d49) + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Replace exclusionary words whitelist and blacklist in the places that… (#2365)__ + + [aponb](mailto:apre@gmx.at) - Mon, 7 Mar 2022 15:14:36 -0800 + + * Replace the exclusionary word whitelist with allowlist, and blacklist with + denylist, in code commet and internal variable/method/class/package name. + + Signed-off-by: Andreas <apre@gmx.at> + + +* __Install plugin command help (#2193) (#2264)__ + + [Joshua Palis](mailto:jpalis@amazon.com) - Mon, 7 Mar 2022 15:24:56 -0500 + * edited opensearch-plugin install help output to include plugin URL + * fixed unit test for plugin install help output by correctly identifying the + beginning og the non-option argument list + * added comments to install plugins help non option argument ouput unit test + * fixed format violation + * added additional details on valid plugin ids and how to use plugin URLs + * added additional information to plugin install help output + (cherry picked from commit b251d2b565b918708a1612ec16d1916122c7805d) Signed-off-by: Joshua Palis <jpalis@amazon.com> + + Signed-off-by: Joshua Palis <jpalis@amazon.com> + + +* __Add valuesField in PercentilesAggregationBuilder streamInput constructor (#2308) (#2389)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Mon, 7 Mar 2022 13:07:41 -0500 + + Signed-off-by: Subhobrata Dey <sbcd90@gmail.com> + (cherry picked from commit e1fd4b75b4f888d8d486baceeb9fd6fe7df44416) + Co-authored-by: Subhobrata Dey <sbcd90@gmail.com> + + +* __Updated the url for docker distribution (#2325) (#2360)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Mon, 7 Mar 2022 11:52:46 -0500 + + Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> + (cherry picked from commit 9224537704bb12980a129afb1e7b6ba6ab93680e) + Co-authored-by: Owais Kazi <owaiskazi19@gmail.com> + + +* __Reintroduce negative epoch_millis #1991 (#2232) (#2380)__ + + [Breno Faria](mailto:breno.faria@intrafind.com) - Mon, 7 Mar 2022 11:46:54 -0500 + + * Reintroduce negative epoch_millis #1991 + Fixes a regression introduced with Elasticsearch 7 regarding the date + field + type that removed support for negative timestamps with sub-second + granularity. Thanks to Ryan Kophs (https://github.com/rkophs) for allowing me to use + his previous work. + Signed-off-by: Breno Faria <breno.faria@intrafind.de> + + * applying spotless fix + Signed-off-by: Breno Faria <breno.faria@intrafind.de> + + * more conservative implementation of isSupportedBy + Signed-off-by: Breno Faria <breno.faria@intrafind.de> + + * adding braces to control flow statement + Signed-off-by: Breno Faria <breno.faria@intrafind.de> + + * spotless fix... + Signed-off-by: Breno Faria <breno.faria@intrafind.de> + Co-authored-by: Breno Faria <breno.faria@intrafind.de> + Co-authored-by: Breno Faria <breno.faria@intrafind.de> + + +* __Add 'key' field to 'function_score' query function definition in explanation response (#1711) (#2346)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Mon, 7 Mar 2022 11:42:03 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Fix java-version-checker source/target compatibility settings (#2354)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Fri, 4 Mar 2022 15:21:54 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + +* __Fixing the --release flag usage for javac (#2343)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Fri, 4 Mar 2022 13:49:01 -0500 + + * Fixing the --release flag usage for javac + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + * Fixing the --html5 flag usage for javadoc + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Fixing soft deletes deprecation warning (#2339)__ + + [Vacha Shah](mailto:vachshah@amazon.com) - Fri, 4 Mar 2022 10:06:11 -0500 + + Signed-off-by: Vacha Shah <vachshah@amazon.com> + + +* __Remove Github DCO action since DCO runs via Github App now (#2317) (#2323)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Thu, 3 Mar 2022 12:12:55 -0800 + + Signed-off-by: Vacha Shah <vachshah@amazon.com> + (cherry picked from commit cdb42ad3013f67970def21e15c546c9c4fd08d6f) + Co-authored-by: Vacha Shah <vachshah@amazon.com> + + +* __[Backport 1.x] Avoid logging duplicate deprecation warnings multiple times (#2315)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Thu, 3 Mar 2022 14:23:05 -0500 + + * Avoid logging duplicate deprecation warnings multiple times (#1660) + + * Avoid logging duplicate deprecation warnings multiple times + Signed-off-by: Vacha <vachshah@amazon.com> + + * Fixes test failures + Signed-off-by: Vacha <vachshah@amazon.com> + + * Adding deprecation logger tests + Signed-off-by: Vacha <vachshah@amazon.com> + + * Using ConcurrentHashMap keySet + Signed-off-by: Vacha Shah <vachshah@amazon.com> + (cherry picked from commit e66ea2c4f3ec583f087a82d1ebfb6383b2f159c1) + + * Fixing failing RestResizeHandlerTests in 1.x + Signed-off-by: Vacha Shah <vachshah@amazon.com> + Co-authored-by: Vacha <vachshah@amazon.com> + + +* __Restore Java 8 compatibility for build tools. (#2300)__ + + [Daniel Doubrovkine (dB.)](mailto:dblock@dblock.org) - Thu, 3 Mar 2022 14:14:23 -0500 + + * Restore Java 8 compatibility for build tools. + Signed-off-by: dblock <dblock@dblock.org> + + * Make source code compatible with Java 8. + Signed-off-by: dblock <dblock@dblock.org> + +* __Add support of SOCKS proxies for S3 repository (#2160) (#2316)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Thu, 3 Mar 2022 13:49:40 -0500 + + Signed-off-by: Andrey Pleskach <ples@aiven.io> + (cherry picked from commit f13b951c7006700a9b8a8bb2cdecd67439bc1e86) + Co-authored-by: Andrey Pleskach <ples@aiven.io> + + +* __Fix flaky test case - string profiler via global ordinals (#2226) (#2313)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Wed, 2 Mar 2022 17:48:34 -0600 + + forcemerge to one segment before executing aggregation query. + Signed-off-by: Peng Huo <penghuo@gmail.com> + (cherry picked from commit 9e225dc9b85c4fc2d3d910846bd0da25bc6a40df) + Co-authored-by: Peng Huo <penghuo@gmail.com> + +* __Auto-increment next development iteration. (#1816) (#2164)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Wed, 2 Mar 2022 15:46:28 -0800 + + * Auto-increment next development iteration. + Signed-off-by: dblock <dblock@amazon.com> + + * Make bwc increments on X.Y and main branches. + Signed-off-by: dblock <dblock@amazon.com> + Signed-off-by: dblock + <dblock@dblock.org> + Co-authored-by: Daniel Doubrovkine (dB.) <dblock@dblock.org> + + +* __Downgrade to JDK 11. (#2301)__ + + [Daniel Doubrovkine (dB.)](mailto:dblock@dblock.org) - Wed, 2 Mar 2022 13:37:23 -0500 + + * Downgrade to JDK 11. + Signed-off-by: dblock <dblock@dblock.org> + + * Added support for patch JDK version, like 11.0.14+1 + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + * Use JDK 11.0.14.1+1. + Signed-off-by: dblock <dblock@dblock.org> + + * ./gradlew :build-tools:spotlessApply + Signed-off-by: dblock <dblock@dblock.org> + Co-authored-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Adding shards per node constraint for predictability to testClusterGr… (#2110) (#2265)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Mon, 28 Feb 2022 15:59:57 -0600 + + * Adding shards per node constraint for predictability to + testClusterGreenAfterPartialRelocation + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Fixing precommit violation + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Adding assertion to ensure invariant + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + (cherry picked from commit 8ae0db5285963b8e3552ce106ef1368813dbc8b1) + Co-authored-by: Ankit Jain <jain.ankitk@gmail.com> + + +* __Revert "[Backport 1.x] Override Default Distribution Download Url with Custom Distribution Url When User Passes a Url (#2191)" (#2243)__ + + [Rabi Panda](mailto:adnapibar@gmail.com) - Thu, 24 Feb 2022 15:58:30 -0800 + + Signed-off-by: Rabi Panda <adnapibar@gmail.com> + + +* __added config file to git issue template directory to disable blank issue creation (#2158) (#2249)__ + + [Joshua Palis](mailto:99766446+joshpalis@users.noreply.github.com) - Thu, 24 Feb 2022 15:34:24 -0800 + + Signed-off-by: Joshua Palis <jpalis@amazon.com> + Co-authored-by: Joshua Palis <jpalis@amazon.com> + (cherry picked from commit fb187eacc26487cd644f09091e462001d8839315) + + +* __Case Insensitive Support in Regexp Interval (#2237) (#2246)__ + + [Matt Weber](mailto:matt@mattweber.org) - Thu, 24 Feb 2022 15:58:09 -0600 + + 1x backport of #2237. Add a `case_insensitive` flag to regexp interval source. + + Signed-off-by: Matt Weber <matt@mattweber.org> + + +* __Add Factory to enable Lucene ConcatenateGraphFilter (#1278) (#2152) (#2219)__ + + [Mau Bach Quang](mailto:quangmaubach@gmail.com) - Thu, 24 Feb 2022 10:49:31 -0800 + + Lucene has a ConcatenateGraphFilter that can concatenate tokens from a + TokenStream + to create a single token (or several tokens that have the same + position if + input TokenStream is a graph). + The change is to enable that ConcatenateGraphFilter by adding a Factory. + + (cherry-pick from 0e95bb9dff976a9c7f9cdac63a92040043d029e2) + Signed-off-by: Mau Bach Quang <quangmaubach@gmail.com> + + +* __[Backport 1.x] Override Default Distribution Download Url with Custom Distribution Url When User Passes a Url (#2191)__ + + [Rishikesh Pasham](mailto:62345295+Rishikesh1159@users.noreply.github.com) - Mon, 21 Feb 2022 10:56:00 -0800 + + * Backport Enabling Sort Optimization to make use of Lucene + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + + * Backport Enabling Sort Optimization to make use of Lucene and small change in + a method call signature + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + + * [Backport 1.x] Override Default Distribution Download Url with Custom + Distribution Url When User Passes a Url + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + + * Adding Spotless check to previous PR + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + +* __Support unordered non-overlapping intervals (#2103) (#2172)__ + + [Matt Weber](mailto:matt@mattweber.org) - Fri, 18 Feb 2022 11:52:52 -0500 + + This commit exposes Intervals.unorderedNoOverlaps (LUCENE-8828). + + (#2103 backport) + Signed-off-by: Matt Weber <matt@mattweber.org> + + +* __Add regexp interval source (#1917) (#2069)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Wed, 16 Feb 2022 14:46:35 -0500 + + * Add regexp interval source + Add a regexp interval source provider so people can use regular + expressions + inside of intervals queries. + Signed-off-by: Matt Weber <matt@mattweber.org> + + * Fixes + + - register regexp interval in SearchModule + - use fully-qualified name for lucene RegExp + - get rid of unnecessary variable + Signed-off-by: Matt Weber <matt@mattweber.org> + (cherry picked from commit b9420d8f70dfc168b9d44f736850af4ef7306a99) + Co-authored-by: Matt Weber <matt@mattweber.org> + + +* __Add proxy username and password settings for Azure repository (#2098) (#2108)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Wed, 16 Feb 2022 12:01:51 -0500 + + Added username/password proxy settings for Azure repository. + Security + settings: + - azure.client.*.proxy.username - Proxy user name + - azure.client.*.proxy.password - Proxy user password + Signed-off-by: Andrey Pleskach <ples@aiven.io> + (cherry picked from commit 62361ceafce4abb735567066d1c4865ca6d7136f) + Co-authored-by: Andrey Pleskach <ples@aiven.io> + + +* __Support first and last parameter for missing bucket ordering in composite aggregation (#1942) (#2049)__ + + [Peng Huo](mailto:penghuo@gmail.com) - Tue, 15 Feb 2022 14:07:35 -0800 + + Support for "first" and "last" parameters for missing bucket ordering in + composite aggregation. + By default, if order is asc, missing_bucket at first, + if order is desc, missing_bucket at last. If + missing_order is "first" or + "last", regardless order, missing_bucket is at first or last respectively. + Signed-off-by: Peng Huo <penghuo@gmail.com> + + +* __Mapping update for “date_range” field type is not idempotent (#2094) (#2106)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Tue, 15 Feb 2022 11:44:17 -0600 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + (cherry picked from commit 6b6f03368f49f5f8001d6d0ed85cd9af7bab76f6) + Co-authored-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Fix integration tests failure (#2067) (#2090)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Fri, 11 Feb 2022 11:07:46 -0500 + + Fixed integration tests failure on Linux with Kernel 5.16.x + Signed-off-by: Andrey Pleskach <ples@aiven.io> + (cherry picked from commit 27ed6fc82c7db7a3a741499f0dbd7722fa053f9d) + Co-authored-by: Andrey Pleskach <ples@aiven.io> + + +* __Backport/backport 2048,2074 to 1.x (#2085)__ + + [Ankit Jain](mailto:jain.ankitk@gmail.com) - Fri, 11 Feb 2022 09:36:21 -0500 + + * Stabilizing org.opensearch.cluster.routing.MovePrimaryFirstTests.test… + (#2048) + + * Stabilizing + org.opensearch.cluster.routing.MovePrimaryFirstTests.testClusterGreenAfterPartialRelocation + + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Removing unused import + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Making code more readable + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + (cherry picked from commit 343b82fe24525bbab01ef5a0d9bb8917068c71bf) + + * Added timeout to ensureGreen() for testClusterGreenAfterPartialRelocation + (#2074) + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + (cherry picked from commit f0984eb409d44e8b68deb1c262bf81accc300acb) + + +* __Removing lingering transportclient (#1955) (#2088)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Thu, 10 Feb 2022 17:21:12 -0800 + + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + (cherry picked from commit 781156471a1827b1b66445f716c7567f714dda86) + Co-authored-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __Prioritize primary shard movement during shard allocation (#1445) (#2079)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Thu, 10 Feb 2022 13:48:38 -0500 + + When some node or set of nodes is excluded (based on some cluster setting) + BalancedShardsAllocator iterates over them in breadth first order picking 1 + shard from + each node and repeating the process until all shards are balanced. + Since shards from + each node are picked randomly it's possible the p and r of + shard1 is relocated first + leaving behind both p and r of shard2. If the + excluded nodes were to go down the + cluster becomes red. + This commit introduces a new setting + "cluster.routing.allocation.move.primary_first" + that prioritizes the p of both + shard1 and shard2 first so the cluster does not become + red if the excluded + nodes were to go down before relocating other shards. Note that + with this + setting enabled performance of this change is a direct function of number + of + indices, shards, replicas, and nodes. The larger the indices, replicas, and + distribution scale, the slower the allocation becomes. This should be used with + care. + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + (cherry picked from commit 6eb8f6f307567892bbabbe37aff7cd42be486df0) + Co-authored-by: Ankit Jain <jain.ankitk@gmail.com> + + +* __Adding workflow to auto delete backport merged branches from backport workflow (#2050) (#2065)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Tue, 8 Feb 2022 12:27:45 -0800 + + Signed-off-by: Vacha Shah <vachshah@amazon.com> + (cherry picked from commit 9c9e218ae697b65e410304825cac81ccdf355e66) + Co-authored-by: Vacha <vachshah@amazon.com> + + +* __Another attempt to fix o.o.transport.netty4.OpenSearchLoggingHandlerIT fails w/ stack overflow (#2051) (#2055)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Mon, 7 Feb 2022 16:11:06 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + (cherry picked from commit 1e5d98329eaa76d1aea19306242e6fa74b840b75) + Co-authored-by: Andriy Redko <andriy.redko@aiven.io> + + +* __added backport for 1.2.5 to 1.x branch (#2057)__ + + [Abhinav Gupta](mailto:guptabhi123@gmail.com) - Mon, 7 Feb 2022 13:33:27 -0500 + + Signed-off-by: Abhinav Gupta <abhng@amazon.com> + + +* __[Backport] Introduce FS Health HEALTHY threshold to fail stuck node (#1269)__ + + [Bukhtawar Khan](mailto:bukhtawa@amazon.com) - Mon, 7 Feb 2022 12:48:03 -0500 + + * Introduce FS Health HEALTHY threshold to fail stuck node (#1167) + This will cause the leader stuck on IO during publication to step down and + eventually trigger a leader election. + * Issue Description + * The publication of cluster state is time bound to 30s by a + cluster.publish.timeout settings. If this time is reached before the new + cluster state is committed, then the cluster state change is rejected and the + leader considers itself to have failed. It stands down and starts trying to + elect a new master. + There is a bug in leader that when it tries to publish the new cluster state + it first tries acquire a lock to flush the new state under a mutex to disk. The + same lock is used to cancel the publication on timeout. Below is the state of + the timeout scheduler meant to cancel the publication. So essentially if the + flushing of cluster state is stuck on IO, so will the cancellation of the + publication since both of them share the same mutex. So leader will not step + down and effectively block the cluster from making progress. + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up settings + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up tests + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up tests + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up tests + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + +* __[Backport] Handle shard over allocation during partial zone/rack or independent … (#1268)__ + + [Bukhtawar Khan](mailto:bukhtawa@amazon.com) - Mon, 7 Feb 2022 09:58:10 -0500 + + * Handle shard over allocation during partial zone/rack or independent node + failures (#1149) + The changes ensure that in the event of a partial zone failure, the surviving + nodes in the minority zone don't get overloaded with shards, this is governed + by a skewness limit. + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up imports + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up imports + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up imports + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up check style + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + +* __Add Version.V_1_2_5 constant__ + + [Nicholas Walter Knize](mailto:nknize@apache.org) - Fri, 4 Feb 2022 18:29:46 -0600 + + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + +* __add 1.2.5 to bwcVersions__ + + [Nicholas Walter Knize](mailto:nknize@apache.org) - Fri, 4 Feb 2022 18:29:35 -0600 + + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + +* __Revert "Upgrading Shadow plugin to 7.1.2 (#2033) (#2037)" (#2047)__ + + [Sarat Vemulapalli](mailto:vemulapallisarat@gmail.com) - Wed, 2 Feb 2022 19:40:51 -0800 + + This reverts commit 8725061c15fac70a81d144ed2d79b09f5e1a2f7f. + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __Fix AssertionError message (#2044) (#2045)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Wed, 2 Feb 2022 21:05:15 -0500 + + Signed-off-by: Lukáš Vlček <lukas.vlcek@aiven.io> + (cherry picked from commit 270c59f523acbb3af73ab56dbcfe754e619fdca9) + Co-authored-by: Lukáš Vlček <lukas.vlcek@aiven.io> + + +* __Upgrading Shadow plugin to 7.1.2 (#2033) (#2037)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Wed, 2 Feb 2022 14:52:31 -0800 + + Shadow plugin is used for publishing jars + and this upgrades Log4J dependency + for build. + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + (cherry picked from commit 1f9517c4caee48eda6eee77f603d815af1fd7770) + Co-authored-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __[FEATURE] Add OPENSEARCH_JAVA_HOME env to override JAVA_HOME (#2040)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Wed, 2 Feb 2022 12:16:50 -0800 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __build: introduce support for reproducible builds (#1995) (#2038)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Wed, 2 Feb 2022 14:21:34 -0500 + + Reproducible builds is an initiative to create an independently-verifiable path + from source to binary code [1]. This can be done by: + - Make all archive tasks in gradle reproducible by ignoring timestamp on files + [2] + - Preserve the order in side the archives [2] + - Ensure GlobalBuildInfoPlugin.java use [SOURCE_DATE_EPOCH] when available + + [SOURCE_DATE_EPOCH]: https://reproducible-builds.org/docs/source-date-epoch/ + [1]: https://reproducible-builds.org/ + [2]: + https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives + + Signed-off-by: Leonidas Spyropoulos <artafinde@gmail.com> + (cherry picked from commit 6da253b8fff9a9d9cbbf65807efa7aeaddc9c9d3) + Co-authored-by: Leonidas Spyropoulos <artafinde@gmail.com> + + +* __[1x] Deprecate index.merge.policy.max_merge_at_once_explicit (#1981) (#1984)__ + + [Nick Knize](mailto:nknize@apache.org) - Wed, 2 Feb 2022 11:48:00 -0600 + + max_merge_at_once_explicit is removed in lucene 9 so the index setting is + + deprecated for removal in the next major release. + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + +* __[Deprecate] Setting explicit version on analysis component (#1978) (#1985)__ + + [Nick Knize](mailto:nknize@apache.org) - Wed, 2 Feb 2022 12:28:44 -0500 + + Lucene 9 removes the ability to define an explicit version on an analysis + + component. The version parameter is deprecated at parse time and a warning is + + issued to the user through the deprecation logger. + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + +* __[BUG] Docker distribution builds are failing. Switching to http://vault.centos.org (#2024) (#2030)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Tue, 1 Feb 2022 14:16:50 -0600 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __[Backport] Enabling Sort Optimization to make use of Lucene (#1989)__ + + [Rishikesh Pasham](mailto:62345295+Rishikesh1159@users.noreply.github.com) - Mon, 31 Jan 2022 10:48:13 -0600 + + * Backport Enabling Sort Optimization to make use of Lucene + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + + * Backport Enabling Sort Optimization to make use of Lucene and small change in + a method call signature + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + + +* __Upgrading Jackson-Databind version (#1982) (#1987)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Sun, 30 Jan 2022 16:32:14 -0800 + + * Upgrading Jackson-Databind version + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + + * Adding jackson-databind version using getProperty method + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + (cherry picked from commit 1568407c362b2534366048379f1bd93f2d164d89) + Co-authored-by: Rishikesh Pasham + <62345295+Rishikesh1159@users.noreply.github.com> + + +* __Update bundled JDK distribution to 17.0.2+8 (#2007) (#2009)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Sat, 29 Jan 2022 09:45:19 -0800 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Linked the formatting setting file (#1860) (#1961)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Thu, 27 Jan 2022 12:24:34 -0800 + + Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> + (cherry picked from commit cfc9ec292dea2169495deffe6d1e25b654e5e35e) + Co-authored-by: Owais Kazi <owaiskazi19@gmail.com> + + +* __Add hook to execute logic before Integ test task starts (#1969) (#1971)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Wed, 26 Jan 2022 17:42:45 -0600 + + Add hook to execute custom logic before the integ test starts. + This is + required for a workaround to enable the jacoco code coverage for Integ Tests. + Signed-off-by: Ankit Kala <ankikala@amazon.com> + + +* __Fixing typo in TESTING.md (#1849) (#1959)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Wed, 26 Jan 2022 17:41:33 -0600 + + Fixes some grammar and link typos found in TESTING.md. + Signed-off-by: Vacha Shah <vachshah@amazon.com> + + +* __Add max_expansions option to wildcard interval (#1916) (#1979)__ + + [Matt Weber](mailto:matt@mattweber.org) - Wed, 26 Jan 2022 16:08:34 -0600 + + Add support for setting the max expansions on a wildcard interval. + The default + value is still 128 and the max value is bounded by + `BooleanQuery.getMaxClauseCount()`. + Signed-off-by: Matt Weber <matt@mattweber.org> + + +* __Update protobuf-java to 3.19.3 (#1945) (#1949)__ + + [Tianli Feng](mailto:ftl94@live.com) - Fri, 21 Jan 2022 08:52:05 -0800 + + * Update protobuf-java to 3.19.3 + Signed-off-by: Tianli Feng <ftl94@live.com> + + * Exclude some API usage violations in the package com.google.protobuf for + thirdPartyAudit task to pass + Signed-off-by: Tianli Feng <ftl94@live.com> + + +* __Timeout fix backport to 1.x (#1953)__ + + [Suraj Singh](mailto:79435743+dreamer-89@users.noreply.github.com) - Thu, 20 Jan 2022 20:53:43 -0600 + + * [Bug] Wait for outstanding requests to complete (#1925) + Signed-off-by: Suraj Singh <surajrider@gmail.com> + + * [BUG] Wait for outstanding requests to complete in LastSuccessfulSett… + (#1939) + + * [BUG] Wait for outstanding requests to complete in + LastSuccessfulSettingsUpdate test + Signed-off-by: Suraj Singh <surajrider@gmail.com> + + * [BUG] Wait for outstanding requests to complete in + LastSuccessfulSettingsUpdate test + Signed-off-by: Suraj Singh <surajrider@gmail.com> + + +* __Update Netty to 4.1.73.Final (#1936) (#1937)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Wed, 19 Jan 2022 00:00:42 -0500 + + efs/remotes/origin/1.3 + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Modernize and consolidate JDKs usage across all stages of the build. Use JDK-17 as bundled JDK distribution to run tests (#1922)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Tue, 18 Jan 2022 10:51:53 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Expand SearchPlugin javadocs. (#1909) (#1923)__ + + [Matt Weber](mailto:matt@mattweber.org) - Tue, 18 Jan 2022 09:48:52 -0600 + + Add and clarify some search plugin point documentation. + Signed-off-by: Matt Weber <matt@mattweber.org> + + +* __Make SortBuilders pluggable (#1856) (#1915)__ + + [Matt Weber](mailto:matt@mattweber.org) - Mon, 17 Jan 2022 12:28:22 -0500 + + Add the ability for plugin authors to add custom sort builders. + Signed-off-by: Matt Weber <matt@mattweber.org> + + +* __Refactor LegacyESVersion tests from Version tests (#1662) (#1663)__ + + [Nick Knize](mailto:nknize@apache.org) - Mon, 17 Jan 2022 12:27:56 -0500 + + In preparation for removing all LegacyESVersion support by 3.0; this commit + + largely refactors the LegacyESVersion test logic from the OpenSearch Version + + test logic into an independent test class. This PR also updates + Version.fromString + to ensure a proper legacy version is returned when major is + > 3 (to support + legacy yaml test and build scripts). + Note that bwc w/ legacy versions are still supported so some cross + compatibility + testing is retained in the Version test class. + + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + +* __Fixing org.opensearch.common.network.InetAddressesTests.testForStringIPv6WithScopeIdInput (#1913) (#1914)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Sat, 15 Jan 2022 10:14:17 -0600 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __[BUG] Serialization bugs can cause node drops (#1885) (#1911)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Fri, 14 Jan 2022 14:23:25 -0600 + + This commit restructures InboundHandler to ensure all data + is consumed over + the wire. + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Fix o.o.transport.netty4.OpenSearchLoggingHandlerIT stack overflow test failure (#1900) (#1906)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Fri, 14 Jan 2022 12:38:18 -0600 + + Attempt to fix o.o.transport.netty4.OpenSearchLoggingHandlerIT fails w/ stack + overflow by + hardening test expectation patterns in regex patterns + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Replace JCenter with Maven Central. (#1057) (#1892)__ + + [Marc Handalian](mailto:handalm@amazon.com) - Wed, 12 Jan 2022 17:03:42 -0800 + + On February 3 2021, JFrog + [announced](https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/) + the shutdown of JCenter. Later on April 27 2021, an update was provided that + the repository will only be read only and new package and versions are no + longer accepted on JCenter. This means we should no longer use JCenter for our + central artifacts repository. + This change replaces JCenter with Maven Central as per the Gradle + recommendation - https://blog.gradle.org/jcenter-shutdown + Signed-off-by: Rabi Panda <adnapibar@gmail.com> + Signed-off-by: Marc Handalian + <handalm@amazon.com> + Co-authored-by: Rabi Panda <adnapibar@gmail.com> + + +* __Update FIPS API libraries of Bouncy Castle (#1853) (#1886)__ + + [Tianli Feng](mailto:ftl94@live.com) - Wed, 12 Jan 2022 09:37:05 -0500 + + * Update bc-fips to 1.0.2.1 + Signed-off-by: Tianli Feng <ftl94@live.com> + + * Update bcpg-fips to 1.0.5.1 + Signed-off-by: Tianli Feng <ftl94@live.com> + + * Update bctls-fips to 1.0.12.2 + Signed-off-by: Tianli Feng <ftl94@live.com> + + * Use the unified bouncycastle version for bcpkix-jdk15on in HDFS testing + fixture + Signed-off-by: Tianli Feng <ftl94@live.com> + + +* __[1.x] Remove remaining Flavor Serialization (#1751) (#1757)__ + + [Nick Knize](mailto:nknize@apache.org) - Thu, 6 Jan 2022 11:11:31 -0800 + + * [Remove] Remaining Flavor Serialization (#1751) + This commit removes unnecessary serialization of unused flavor variable in + build + metadata from V_1_3_0+ + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + * change flavor version check to V_1_3_0 + This commit changes the flavor serialization check in Build from V_2_0_0 to + V_1_3_0. + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + +* __Update junit to 4.13.1 (#1837) (#1842)__ + + [Ashish Agrawal](mailto:ashisagr@amazon.com) - Wed, 5 Jan 2022 08:15:56 -0500 + + * Update junit to 4.13.1 + Signed-off-by: Ashish Agrawal <ashisagr@amazon.com> + + * update junit to 4.13.2 + Signed-off-by: Ashish Agrawal <ashisagr@amazon.com> + + * update SHA1 file + Signed-off-by: Ashish Agrawal <ashisagr@amazon.com> + + +* __Upgrading bouncycastle to 1.70 (#1832) (#1834)__ + + [Sarat Vemulapalli](mailto:vemulapallisarat@gmail.com) - Tue, 4 Jan 2022 11:57:01 -0800 + + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __Updatting Netty to 4.1.72.Final (#1831) (#1835)__ + + [Sarat Vemulapalli](mailto:vemulapallisarat@gmail.com) - Tue, 4 Jan 2022 11:56:39 -0800 + + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __Intermittent java.lang.Exception: Suite timeout exceeded (>= 1200000 msec) (#1827)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Wed, 29 Dec 2021 13:23:49 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Execution failed for task ':test:fixtures:azure/s3/hdfs/gcs-fixture:composeDown' (#1824) (#1825)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Wed, 29 Dec 2021 11:28:51 -0600 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Update to log4j 2.17.1 (#1820) (#1822)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Tue, 28 Dec 2021 17:57:26 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __RestIntegTestTask fails because of missed log4j-core dependency (#1815) (#1818)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Tue, 28 Dec 2021 17:08:37 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Gradle clean failing after a failed gradle check, folders created by Docker under 'root' user (#1726) (#1775)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Thu, 23 Dec 2021 17:42:09 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __[plugin] repository-azure: add configuration settings for connect/write/response/read timeouts (#1789) (#1802)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Thu, 23 Dec 2021 12:26:27 -0600 + + * [plugin] repository-azure: add configuration settings for + connect/write/response/read timeouts + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + * Addressing code review comments: renaming connectionXxx to connectXxx + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + * Addressing code review comments: adding timeout comment + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Add bwc version 1.2.4 (#1797)__ + + [Rabi Panda](mailto:adnapibar@gmail.com) - Thu, 23 Dec 2021 10:19:15 -0500 + + Signed-off-by: Rabi Panda <adnapibar@gmail.com> + + +* __Use try-with-resources with MockLogAppender (#1595) (#1784)__ + + [Andrew Ross](mailto:andrross@amazon.com) - Tue, 21 Dec 2021 20:03:11 -0800 + + I previously added a helper that started a MockLogAppender to ensure it + was never added to a Logger before it was started. I subsequently found + the opposite case in RolloverIT.java where the appender was stopped + before it was closed, therefore creating a race where a concurrently + running test in the same JVM could cause a logging failure. This seems + like a really easy mistake to make when writing a test or introduce when + refactoring a test. I've made a change to use try-with-resources to + ensure that proper setup and teardown is done. This should make it much + harder to introduce this particular test bug in the future. Unfortunately, + it did involve touching a lot of files. The changes here are purely structural + to leverage try-with-resources; no testing logic has been changed. + + Signed-off-by: Andrew Ross <andrross@amazon.com> + + +* __Ignore file order in test assertion (#1755) (#1782)__ + + [Andrew Ross](mailto:andrross@amazon.com) - Mon, 20 Dec 2021 19:35:36 -0600 + + This unit test asserts that a SHA file for a groovy dependency gets + created. + However, a SHA file for javaparser-core also gets created in + the same + directory. For some reason, builds were failing on my machine + because + `Files::list` was returning the javaparser-core file first. I + don't believe + there are any ordering guarantees with that API, so I + relaxed the assertion to + not depend on ordering. + + Signed-off-by: Andrew Ross <andrross@amazon.com> + + +* __Fixing allocation filters to persist existing state on settings update (#1718) (#1780)__ + + [Ankit Jain](mailto:jain.ankitk@gmail.com) - Mon, 20 Dec 2021 18:31:53 -0500 + + * Fixing allocation filters to persist existing state on settings update + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Adding test for filter settings update + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Adding more tests and review comments + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Adding assertion and unit test for operation type mismatch + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Updating test names + + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + +* __Update to log4j 2.17.0 (#1771) (#1773)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Sat, 18 Dec 2021 11:33:16 -0800 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Updating .gitattributes for additional file types (#1727) (#1766)__ + + [Sarat Vemulapalli](mailto:vemulapallisarat@gmail.com) - Fri, 17 Dec 2021 15:51:12 -0800 + + * Updating .gitattributes for additional types + + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __Better JDK-18 EA (and beyond) support of SecurityManager (#1750) (#1753)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Fri, 17 Dec 2021 16:08:30 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Add version 1.2.3. (#1759)__ + + [Daniel Doubrovkine (dB.)](mailto:dblock@dblock.org) - Fri, 17 Dec 2021 09:14:45 -0800 + + Signed-off-by: dblock <dblock@dblock.org> + + +* __[plugin] repository-azure is not working properly hangs on basic operations (#1740)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Thu, 16 Dec 2021 15:01:50 -0500 + + * [plugin] repository-azure is not working properly hangs on basic operations + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + * Added tests cases and TODO items, addressing code review comments + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Adding 1.2.2 (#1731) (#1736)__ + + [Sarat Vemulapalli](mailto:vemulapallisarat@gmail.com) - Wed, 15 Dec 2021 14:16:16 -0500 + + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __Upgrade to log4j 2.16.0 (#1721) (#1723)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Tue, 14 Dec 2021 12:19:35 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Support JDK 18 EA builds (#1714)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Tue, 14 Dec 2021 06:47:00 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Fixing .gitattributes for binary content, removing *.class files (#1717) (#1720)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Mon, 13 Dec 2021 16:11:25 -0800 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Upgrade to logj4 2.15.0 (#1705)__ + + [Andrew Ross](mailto:andrross@amazon.com) - Fri, 10 Dec 2021 16:35:18 -0500 + + Signed-off-by: Andrew Ross <andrross@amazon.com> + + +* __Add version 1.2.1. (#1701) (#1702)__ + + [Daniel Doubrovkine (dB.)](mailto:dblock@dblock.org) - Fri, 10 Dec 2021 15:36:19 -0500 + + Signed-off-by: dblock <dblock@dblock.org> + + +* __Move Gradle wrapper and precommit checks into OpenSearch repo. (#1664) (#1678)__ + + [Daniel Doubrovkine (dB.)](mailto:dblock@dblock.org) - Wed, 8 Dec 2021 11:45:55 -0500 + + * Move Gradle checks into OpenSearch repo. + Signed-off-by: dblock <dblock@amazon.com> + + * Use working-directory for gradle wrapper validation. + Signed-off-by: dblock <dblock@amazon.com> + + * Use https://github.com/gradle/wrapper-validation-action. + Signed-off-by: dblock <dblock@amazon.com> + + +* __Moving DCO to workflows (#1458) (#1666)__ + + [Daniel Doubrovkine (dB.)](mailto:dblock@dblock.org) - Wed, 8 Dec 2021 07:59:34 -0500 + + Signed-off-by: CEHENKLE <henkle@amazon.com> + Co-authored-by: CEHENKLE <henkle@amazon.com> + + +* __Start MockLogAppender before adding to static context (#1587) (#1659)__ + + [Andrew Ross](mailto:andrross@amazon.com) - Mon, 6 Dec 2021 16:45:49 -0500 + + I observed a test failure with the message + 'Attempted to append to non-started appender mock' from an assertion in + `OpenSearchTestCase::after`. I believe this indicates that a + MockLogAppender + (which is named "mock") was added as an appender to the + static logging context + and some other test in the same JVM happened to + cause a logging statement to + hit that appender and cause an error, which + then caused an unrelated test to + fail (because they share static state + with the logger). Almost all usages of + MockLogAppender start it + immediately after creation. I found a few that did + not and fixed those. + I also made a static helper in MockLogAppender to start + it upon + creation. + Signed-off-by: Andrew Ross <andrross@amazon.com> + + +* __Revert "Support Gradle 7 (#1609) (#1622)" (#1657)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Mon, 6 Dec 2021 10:47:35 -0500 + + This reverts commit 93bd32b14270be0da8a6b5eef8eeabfce7eb2b58. + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Added .gitattributes to manage end-of-line checks for Windows/*nix systems (#1638) (#1655)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Mon, 6 Dec 2021 08:08:01 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Support Gradle 7 (#1609) (#1622)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Fri, 3 Dec 2021 15:53:57 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Renaming Slave terminology to Replica in 1.x branch (backporting) (#1645)__ + + [Rishikesh Pasham](mailto:62345295+Rishikesh1159@users.noreply.github.com) - Fri, 3 Dec 2021 15:52:51 -0500 + + Signed-off-by: Rishikesh Pasham <rishireddy1159@gmail.com> + + +* __Upgrading commons-codec in hdfs-fixture and cleaning up dependencies in repository-hdfs (#1603) (#1621)__ + + [Vacha](mailto:vachshah@amazon.com) - Tue, 30 Nov 2021 17:17:21 -0500 + + Signed-off-by: Vacha <vachshah@amazon.com> + + +* __Rename field_masking_span to span_field_masking (#1606) (#1623)__ + + [Xue Zhou](mailto:85715413+xuezhou25@users.noreply.github.com) - Mon, 29 Nov 2021 23:18:13 -0500 + + * Rename field_masking_span to span_field_masking + Signed-off-by: Xue Zhou <xuezhou@amazon.com> + + * Update SearchModuleTests.java + Signed-off-by: Xue Zhou <xuezhou@amazon.com> + + * Rename field_masking_span to span_field_masking + Signed-off-by: Xue Zhou <xuezhou@amazon.com> + + +* __Upgrade dependency (#1571) (#1594)__ + + [Vacha](mailto:vachshah@amazon.com) - Mon, 29 Nov 2021 14:48:33 -0500 + + * Upgrading guava, commons-io and apache-ant dependencies. + Signed-off-by: Vacha <vachshah@amazon.com> + + * Adding failureaccess since guava needs it. + Signed-off-by: Vacha <vachshah@amazon.com> + + +* __Lower build requirement from Java 14+ to Java 11+ (#940) (#1608)__ + + [Marc Handalian](mailto:handalm@amazon.com) - Tue, 23 Nov 2021 21:41:59 -0500 + + * Lower build requirement from Java 14+ to Java 11+ + Avoid use of -Werror -Xlint:all, which may change significantly across + java + releases (new warnings could be added). Instead, just list the + warnings + individually. + Workaround JDK 11 compiler bug (JDK-8209058) that only impacts test fixture + code in the build itself. + Signed-off-by: Robert Muir <rmuir@apache.org> + + * Disable warning around -source 7 -release 7 for java version checker + The java version checker triggers some default warnings because it + targets + java7: + + ``` + Task :distribution:tools:java-version-checker:compileJava FAILED + warning: [options] source value 7 is obsolete and will be removed in a future release + warning: [options] target value 7 is obsolete and will be removed in a future release + warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. + + error: warnings found and -Werror specified + ``` + + * Suppress this warning explicitly for this module. + Signed-off-by: Robert Muir <rmuir@apache.org> + + * more java14 -> java11 cleanup + Signed-off-by: Robert Muir <rmuir@apache.org> + Co-authored-by: Robert Muir <rmuir@apache.org> + Signed-off-by: Marc Handalian + <handalm@amazon.com> + Co-authored-by: Daniel Doubrovkine (dB.) <dblock@dblock.org> + Co-authored-by: + Robert Muir <rmuir@apache.org> + + +* __Giving informative error messages for double slashes in API call URLs- [ BACKPORT-1.x ] (#1601)__ + + [Megha Sai Kavikondala](mailto:kavmegha@amazon.com) - Tue, 23 Nov 2021 13:34:31 -0500 + + * Integration test that checks for settings upgrade (#1482) + + * Made changes. + Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + + * Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + Changes made by deleting the TestSettingsIT file and adding new lines in + FullClusterRestartSettingsUpgradeIT.java + Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + + * Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + Informative error messages related to empty index name.[Backport] + + +* __Enable RestHighLevel-Client to set parameter require_alias for bulk index and reindex requests (#1604)__ + + [Jan Baudisch](mailto:jan.baudisch.de@gmail.com) - Tue, 23 Nov 2021 10:20:07 -0500 + + Signed-off-by: Jan Baudisch <jan.baudisch.libri@gmail.com> + Co-authored-by: Jan Baudisch <jan.baudisch.libri@gmail.com> + + +* __Upgrading gson to 2.8.9 (#1541). (#1545)__ + + [Vacha](mailto:vachshah@amazon.com) - Fri, 19 Nov 2021 16:52:38 -0500 + + Signed-off-by: Vacha <vachshah@amazon.com> + + +* __[repository-azure] Update to the latest Azure Storage SDK v12, remove privileged runnable wrapper in favor of access helper (#1521) (#1538)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Thu, 11 Nov 2021 14:05:47 -0800 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Integration test that checks for settings upgrade (#1482) (#1524)__ + + [Megha Sai Kavikondala](mailto:kavmegha@amazon.com) - Thu, 11 Nov 2021 12:55:11 -0800 + + * Made changes. + Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + + * Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + Changes made by deleting the TestSettingsIT file and adding new lines in + FullClusterRestartSettingsUpgradeIT.java + Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + + +* __Added logic to allow {dot} files on startup (#1437) (#1516)__ + + [Ryan Bogan](mailto:10944539+ryanbogan@users.noreply.github.com) - Thu, 11 Nov 2021 11:02:03 -0800 + + * Added logic to allow {dot} files on startup + Signed-off-by: Ryan Bogan <rbogan@amazon.com> + + * Ensures that only plugin directories are returned by findPluginDirs() + Signed-off-by: Ryan Bogan <rbogan@amazon.com> + + * Prevents . files from being returned as plugins + Signed-off-by: Ryan Bogan <rbogan@amazon.com> + + +* __Add staged version 1.1.1 (#1509)__ + + [Nick Knize](mailto:nknize@apache.org) - Thu, 4 Nov 2021 14:46:57 -0500 + + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + From b9f04405d6dfabcc2b8e87a86d4f83b003b3ffe7 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Thu, 17 Mar 2022 18:13:27 -0500 Subject: [PATCH 09/46] [Remove] types from CreateIndexRequest and companion Builder's mapping method (#2498) Removes the type variable as input to CreateIndexRequest.mapping(Object...) along with the CreateIndexRequestBuilder helper class. This also refactors the method name to setMapping for consistency with other methods (e.g., setSettings). Signed-off-by: Nicholas Walter Knize --- .../common/QueryStringWithAnalyzersIT.java | 2 +- .../common/HighlighterWithAnalyzersTests.java | 9 +-- .../script/expression/MoreExpressionIT.java | 12 ++-- .../percolator/PercolatorQuerySearchIT.java | 39 +++++------- .../PercolatorQuerySearchTests.java | 2 +- .../index/mapper/size/SizeMappingIT.java | 3 +- .../admin/indices/create/ShrinkIndexIT.java | 3 +- .../admin/indices/create/SplitIndexIT.java | 9 ++- .../action/search/TransportSearchIT.java | 2 +- .../action/termvectors/GetTermVectorsIT.java | 30 ++++----- .../opensearch/aliases/IndexAliasesIT.java | 24 +++---- .../coordination/RareClusterStateIT.java | 4 +- .../document/DocumentActionsIT.java | 2 +- .../org/opensearch/document/ShardInfoIT.java | 2 +- .../opensearch/explain/ExplainActionIT.java | 6 +- .../java/org/opensearch/get/GetActionIT.java | 4 +- .../index/suggest/stats/SuggestStatsIT.java | 4 +- .../indices/IndicesRequestCacheIT.java | 20 +++--- .../indices/analyze/AnalyzeActionIT.java | 6 +- .../breaker/CircuitBreakerServiceIT.java | 3 +- .../recovery/IndexPrimaryRelocationIT.java | 2 +- .../indices/stats/IndexStatsIT.java | 4 +- .../template/SimpleIndexTemplateIT.java | 4 +- .../recovery/TruncatedRecoveryIT.java | 2 +- .../AggregationsIntegrationIT.java | 2 +- .../search/aggregations/MetadataIT.java | 2 +- .../search/aggregations/MissingValueIT.java | 4 +- .../bucket/AdjacencyMatrixIT.java | 2 +- .../aggregations/bucket/DateHistogramIT.java | 16 ++--- .../bucket/DateHistogramOffsetIT.java | 2 +- .../aggregations/bucket/DateRangeIT.java | 8 +-- .../bucket/DiversifiedSamplerIT.java | 4 +- .../aggregations/bucket/DoubleTermsIT.java | 6 +- .../search/aggregations/bucket/FilterIT.java | 2 +- .../search/aggregations/bucket/FiltersIT.java | 2 +- .../aggregations/bucket/GeoDistanceIT.java | 6 +- .../aggregations/bucket/GeoHashGridIT.java | 4 +- .../aggregations/bucket/HistogramIT.java | 10 +-- .../search/aggregations/bucket/IpRangeIT.java | 2 +- .../search/aggregations/bucket/IpTermsIT.java | 6 +- .../aggregations/bucket/LongTermsIT.java | 4 +- .../aggregations/bucket/MinDocCountIT.java | 2 +- .../aggregations/bucket/NaNSortingIT.java | 2 +- .../search/aggregations/bucket/NestedIT.java | 10 +-- .../search/aggregations/bucket/RangeIT.java | 8 +-- .../search/aggregations/bucket/SamplerIT.java | 4 +- .../aggregations/bucket/ShardReduceIT.java | 3 +- .../SignificantTermsSignificanceScoreIT.java | 11 ++-- .../bucket/TermsDocCountErrorIT.java | 10 +-- .../bucket/TermsShardMinDocCountIT.java | 5 +- .../bucket/terms/StringTermsIT.java | 34 ++-------- .../aggregations/metrics/CardinalityIT.java | 2 +- .../aggregations/metrics/ExtendedStatsIT.java | 2 +- .../metrics/HDRPercentileRanksIT.java | 2 +- .../metrics/HDRPercentilesIT.java | 2 +- .../metrics/MedianAbsoluteDeviationIT.java | 4 +- .../metrics/ScriptedMetricIT.java | 4 +- .../search/aggregations/metrics/StatsIT.java | 2 +- .../search/aggregations/metrics/SumIT.java | 7 +-- .../metrics/TDigestPercentileRanksIT.java | 2 +- .../metrics/TDigestPercentilesIT.java | 2 +- .../aggregations/metrics/TopHitsIT.java | 6 +- .../aggregations/metrics/ValueCountIT.java | 2 +- .../aggregations/pipeline/AvgBucketIT.java | 4 +- .../pipeline/DateDerivativeIT.java | 2 +- .../aggregations/pipeline/DerivativeIT.java | 4 +- .../pipeline/ExtendedStatsBucketIT.java | 4 +- .../aggregations/pipeline/MaxBucketIT.java | 4 +- .../aggregations/pipeline/MinBucketIT.java | 4 +- .../pipeline/PercentilesBucketIT.java | 4 +- .../aggregations/pipeline/StatsBucketIT.java | 4 +- .../aggregations/pipeline/SumBucketIT.java | 4 +- .../search/basic/SearchWhileRelocatingIT.java | 2 +- .../basic/TransportSearchFailuresIT.java | 2 +- .../search/fetch/subphase/InnerHitsIT.java | 12 ++-- .../highlight/HighlighterSearchIT.java | 63 +++++++------------ .../search/fieldcaps/FieldCapabilitiesIT.java | 4 +- .../search/fields/SearchFieldsIT.java | 7 +-- .../functionscore/RandomScoreFunctionIT.java | 3 +- .../opensearch/search/geo/GeoPolygonIT.java | 3 +- .../search/geo/GeoShapeIntegrationIT.java | 6 +- .../geo/LegacyGeoShapeIntegrationIT.java | 18 +----- .../search/morelikethis/MoreLikeThisIT.java | 21 ++----- .../search/nested/SimpleNestedIT.java | 4 +- .../aggregation/AggregationProfilerIT.java | 2 +- .../search/query/MultiMatchQueryIT.java | 2 +- .../search/query/ScriptScoreQueryIT.java | 8 +-- .../search/query/SearchQueryIT.java | 48 +++++++------- .../scriptfilter/ScriptQuerySearchIT.java | 2 +- .../search/scroll/SearchScrollIT.java | 4 +- .../search/searchafter/SearchAfterIT.java | 17 +++-- .../search/simple/SimpleSearchIT.java | 6 +- .../opensearch/search/sort/FieldSortIT.java | 44 ++++++------- .../search/sort/GeoDistanceSortBuilderIT.java | 11 ++-- .../search/source/MetadataFetchingIT.java | 2 +- .../search/suggest/SuggestSearchIT.java | 14 ++--- .../java/org/opensearch/update/UpdateIT.java | 2 +- .../validate/SimpleValidateQueryIT.java | 8 +-- .../create/CreateIndexRequestBuilder.java | 4 +- .../metadata/MetadataMappingServiceTests.java | 12 ++-- .../FieldStatsProviderRefreshTests.java | 2 +- .../index/mapper/UpdateMappingTests.java | 2 +- .../query/CommonTermsQueryParserTests.java | 3 +- .../bucket/ShardSizeTestCase.java | 2 +- .../metrics/AbstractGeoTestCase.java | 13 ++-- .../search/geo/GeoShapeQueryTests.java | 22 ++----- .../SharedSignificantTermsTestMethods.java | 2 +- .../metrics/AbstractNumericTestCase.java | 2 +- .../test/OpenSearchSingleNodeTestCase.java | 4 +- 109 files changed, 343 insertions(+), 480 deletions(-) diff --git a/modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java b/modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java index 02c3bdfd70ec2..8c2f83bf83d85 100644 --- a/modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java +++ b/modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java @@ -73,7 +73,7 @@ public void testCustomWordDelimiterQueryString() { .put("analysis.filter.custom_word_delimiter.split_on_numerics", "false") .put("analysis.filter.custom_word_delimiter.stem_english_possessive", "false") ) - .addMapping("type1", "field1", "type=text,analyzer=my_analyzer", "field2", "type=text,analyzer=my_analyzer") + .setMapping("field1", "type=text,analyzer=my_analyzer", "field2", "type=text,analyzer=my_analyzer") ); client().prepareIndex("test").setId("1").setSource("field1", "foo bar baz", "field2", "not needed").get(); diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java index a8dd2d2578541..57c959a4f0b65 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java @@ -149,8 +149,7 @@ public void testMultiPhraseCutoff() throws IOException { * query. We cut off and extract terms if there are more than 16 terms in the query */ assertAcked( - prepareCreate("test").addMapping( - "test", + prepareCreate("test").setMapping( "body", "type=text,analyzer=custom_analyzer," + "search_analyzer=custom_analyzer,term_vector=with_positions_offsets" ) @@ -225,8 +224,7 @@ public void testSynonyms() throws IOException { assertAcked( prepareCreate("test").setSettings(builder.build()) - .addMapping( - "type1", + .setMapping( "field1", "type=text,term_vector=with_positions_offsets,search_analyzer=synonym," + "analyzer=standard,index_options=offsets" ) @@ -335,8 +333,7 @@ public void testPhrasePrefix() throws IOException { assertAcked( prepareCreate("second_test_index").setSettings(builder.build()) - .addMapping( - "doc", + .setMapping( "field4", "type=text,term_vector=with_positions_offsets,analyzer=synonym", "field3", diff --git a/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java b/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java index 450e70c3c8938..952b00dda608c 100644 --- a/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java +++ b/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java @@ -158,7 +158,7 @@ public void testScore() throws Exception { } public void testDateMethods() throws Exception { - OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "date0", "type=date", "date1", "type=date")); + OpenSearchAssertions.assertAcked(prepareCreate("test").setMapping("date0", "type=date", "date1", "type=date")); ensureGreen("test"); indexRandom( true, @@ -188,7 +188,7 @@ public void testDateMethods() throws Exception { } public void testDateObjectMethods() throws Exception { - OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "date0", "type=date", "date1", "type=date")); + OpenSearchAssertions.assertAcked(prepareCreate("test").setMapping("date0", "type=date", "date1", "type=date")); ensureGreen("test"); indexRandom( true, @@ -219,7 +219,7 @@ public void testDateObjectMethods() throws Exception { public void testMultiValueMethods() throws Exception { OpenSearchAssertions.assertAcked( - prepareCreate("test").addMapping("doc", "double0", "type=double", "double1", "type=double", "double2", "type=double") + prepareCreate("test").setMapping("double0", "type=double", "double1", "type=double", "double2", "type=double") ); ensureGreen("test"); @@ -322,7 +322,7 @@ public void testMultiValueMethods() throws Exception { } public void testInvalidDateMethodCall() throws Exception { - OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "double", "type=double")); + OpenSearchAssertions.assertAcked(prepareCreate("test").setMapping("double", "type=double")); ensureGreen("test"); indexRandom(true, client().prepareIndex("test").setId("1").setSource("double", "178000000.0")); try { @@ -343,7 +343,7 @@ public void testInvalidDateMethodCall() throws Exception { } public void testSparseField() throws Exception { - OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "x", "type=long", "y", "type=long")); + OpenSearchAssertions.assertAcked(prepareCreate("test").setMapping("x", "type=long", "y", "type=long")); ensureGreen("test"); indexRandom( true, @@ -528,7 +528,7 @@ public void testSpecialValueVariable() throws Exception { public void testStringSpecialValueVariable() throws Exception { // i.e. expression script for term aggregations, which is not allowed - assertAcked(client().admin().indices().prepareCreate("test").addMapping("doc", "text", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("text", "type=keyword").get()); ensureGreen("test"); indexRandom( true, diff --git a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java index 11fc61d6c6d99..f78b74e272ebf 100644 --- a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java @@ -101,7 +101,7 @@ public void testPercolatorQuery() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") ); client().prepareIndex("test") @@ -183,8 +183,7 @@ public void testPercolatorRangeQueries() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping( - "type", + .setMapping( "field1", "type=long", "field2", @@ -315,17 +314,7 @@ public void testPercolatorGeoQueries() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping( - "type", - "id", - "type=keyword", - "field1", - "type=geo_point", - "field2", - "type=geo_shape", - "query", - "type=percolator" - ) + .setMapping("id", "type=keyword", "field1", "type=geo_point", "field2", "type=geo_shape", "query", "type=percolator") ); client().prepareIndex("test") @@ -380,7 +369,7 @@ public void testPercolatorQueryExistingDocument() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") ); client().prepareIndex("test") @@ -438,7 +427,7 @@ public void testPercolatorQueryExistingDocumentSourceDisabled() throws Exception client().admin() .indices() .prepareCreate("test") - .addMapping("type", "_source", "enabled=false", "field1", "type=keyword", "query", "type=percolator") + .setMapping("_source", "enabled=false", "field1", "type=keyword", "query", "type=percolator") ); client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject()).get(); @@ -459,7 +448,7 @@ public void testPercolatorSpecificQueries() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", "type=text", "field2", "type=text", "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", "type=text", "field2", "type=text", "query", "type=percolator") ); client().prepareIndex("test") @@ -565,7 +554,7 @@ public void testPercolatorQueryWithHighlighting() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", fieldMapping.toString(), "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", fieldMapping.toString(), "query", "type=percolator") ); client().prepareIndex("test") .setId("1") @@ -810,7 +799,7 @@ public void testTakePositionOffsetGapIntoAccount() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "field", "type=text,position_increment_gap=5", "query", "type=percolator") + .setMapping("field", "type=text,position_increment_gap=5", "query", "type=percolator") ); client().prepareIndex("test") .setId("1") @@ -832,13 +821,13 @@ public void testTakePositionOffsetGapIntoAccount() throws Exception { public void testManyPercolatorFields() throws Exception { String queryFieldName = randomAlphaOfLength(8); assertAcked( - client().admin().indices().prepareCreate("test1").addMapping("type", queryFieldName, "type=percolator", "field", "type=keyword") + client().admin().indices().prepareCreate("test1").setMapping(queryFieldName, "type=percolator", "field", "type=keyword") ); assertAcked( client().admin() .indices() .prepareCreate("test2") - .addMapping("type", queryFieldName, "type=percolator", "second_query_field", "type=percolator", "field", "type=keyword") + .setMapping(queryFieldName, "type=percolator", "second_query_field", "type=percolator", "field", "type=keyword") ); assertAcked( client().admin() @@ -867,7 +856,7 @@ public void testManyPercolatorFields() throws Exception { public void testWithMultiplePercolatorFields() throws Exception { String queryFieldName = randomAlphaOfLength(8); assertAcked( - client().admin().indices().prepareCreate("test1").addMapping("type", queryFieldName, "type=percolator", "field", "type=keyword") + client().admin().indices().prepareCreate("test1").setMapping(queryFieldName, "type=percolator", "field", "type=keyword") ); assertAcked( client().admin() @@ -1130,7 +1119,7 @@ public void testPercolateQueryWithNestedDocuments() throws Exception { } public void testPercolatorQueryViaMultiSearch() throws Exception { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "field1", "type=text", "query", "type=percolator")); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field1", "type=text", "query", "type=percolator")); client().prepareIndex("test") .setId("1") @@ -1248,7 +1237,7 @@ public void testDisallowExpensiveQueries() throws IOException { client().admin() .indices() .prepareCreate("test") - .addMapping("_doc", "id", "type=keyword", "field1", "type=keyword", "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", "type=keyword", "query", "type=percolator") ); client().prepareIndex("test") @@ -1298,7 +1287,7 @@ public void testDisallowExpensiveQueries() throws IOException { public void testWrappedWithConstantScore() throws Exception { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("_doc", "d", "type=date", "q", "type=percolator")); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("d", "type=date", "q", "type=percolator")); client().prepareIndex("test") .setId("1") diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java index d3da99ffbc102..1d77c9d472864 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java @@ -96,7 +96,7 @@ protected Map, Object>> pluginScripts() { } public void testPercolateScriptQuery() throws IOException { - client().admin().indices().prepareCreate("index").addMapping("type", "query", "type=percolator").get(); + client().admin().indices().prepareCreate("index").setMapping("query", "type=percolator").get(); client().prepareIndex("index") .setId("1") .setSource( diff --git a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java index 375222cd2af44..3a430331167f6 100644 --- a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java +++ b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java @@ -36,7 +36,6 @@ import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentType; -import org.opensearch.index.mapper.MapperService; import org.opensearch.plugin.mapper.MapperSizePlugin; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchIntegTestCase; @@ -122,7 +121,7 @@ private void assertSizeMappingEnabled(String index, boolean enabled) throws IOEx } public void testBasic() throws Exception { - assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, "_size", "enabled=true")); + assertAcked(prepareCreate("test").setMapping("_size", "enabled=true")); final String source = "{\"f\":10}"; indexRandom(true, client().prepareIndex("test").setId("1").setSource(source, XContentType.JSON)); GetResponse getResponse = client().prepareGet("test", "1").setStoredFields("_size").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java index ef5c56c50ed83..e8a6c68a41076 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java @@ -71,7 +71,6 @@ import org.opensearch.index.Index; import org.opensearch.index.IndexService; import org.opensearch.index.engine.SegmentsStats; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.TermsQueryBuilder; import org.opensearch.index.seqno.SeqNoStats; import org.opensearch.index.shard.IndexShard; @@ -527,7 +526,7 @@ public void testCreateShrinkWithIndexSort() throws Exception { .put("sort.order", "desc") .put("number_of_shards", 8) .put("number_of_replicas", 0) - ).addMapping(MapperService.SINGLE_MAPPING_NAME, "id", "type=keyword,doc_values=true").get(); + ).setMapping("id", "type=keyword,doc_values=true").get(); for (int i = 0; i < 20; i++) { client().prepareIndex("source") .setId(Integer.toString(i)) diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java index 42b1d5f4a757f..89e11984621da 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java @@ -65,7 +65,6 @@ import org.opensearch.index.Index; import org.opensearch.index.IndexService; import org.opensearch.index.engine.SegmentsStats; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.TermsQueryBuilder; import org.opensearch.index.seqno.SeqNoStats; import org.opensearch.index.shard.IndexShard; @@ -136,12 +135,12 @@ private void splitToN(int sourceShards, int firstSplitShards, int secondSplitSha int numRoutingShards = MetadataCreateIndexService.calculateNumRoutingShards(secondSplitShards, Version.CURRENT) - 1; settings.put("index.routing_partition_size", randomIntBetween(1, numRoutingShards)); if (useNested) { - createInitialIndex.addMapping(MapperService.SINGLE_MAPPING_NAME, "_routing", "required=true", "nested1", "type=nested"); + createInitialIndex.setMapping("_routing", "required=true", "nested1", "type=nested"); } else { - createInitialIndex.addMapping(MapperService.SINGLE_MAPPING_NAME, "_routing", "required=true"); + createInitialIndex.setMapping("_routing", "required=true"); } } else if (useNested) { - createInitialIndex.addMapping(MapperService.SINGLE_MAPPING_NAME, "nested1", "type=nested"); + createInitialIndex.setMapping("nested1", "type=nested"); } logger.info("use routing {} use mixed routing {} use nested {}", useRouting, useMixedRouting, useNested); createInitialIndex.setSettings(settings).get(); @@ -523,7 +522,7 @@ public void testCreateSplitWithIndexSort() throws Exception { .put("sort.order", "desc") .put("number_of_shards", 2) .put("number_of_replicas", 0) - ).addMapping(MapperService.SINGLE_MAPPING_NAME, "id", "type=keyword,doc_values=true").get(); + ).setMapping("id", "type=keyword,doc_values=true").get(); for (int i = 0; i < 20; i++) { client().prepareIndex("source") .setId(Integer.toString(i)) diff --git a/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java index c7985d972de5e..a356d273f7060 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java @@ -348,7 +348,7 @@ public void testSearchIdle() throws Exception { .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 5)) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numOfReplicas) .put(IndexSettings.INDEX_SEARCH_IDLE_AFTER.getKey(), TimeValue.timeValueMillis(randomIntBetween(50, 500))); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("_doc", "created_date", "type=date,format=yyyy-MM-dd")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("created_date", "type=date,format=yyyy-MM-dd")); ensureGreen("test"); assertBusy(() -> { for (String node : internalCluster().nodesInclude("test")) { diff --git a/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java b/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java index 8ab6450ead2af..b5e60f44983f5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java @@ -161,8 +161,7 @@ public void testNotIndexedField() throws Exception { // must be of type string and indexed. assertAcked( prepareCreate("test").addAlias(new Alias("alias")) - .addMapping( - "type1", + .setMapping( "field0", "type=integer,", // no tvs "field1", @@ -548,10 +547,8 @@ private void checkBrownFoxTermVector(Fields fields, String fieldName, boolean wi public void testDuelWithAndWithoutTermVectors() throws IOException, ExecutionException, InterruptedException { // setup indices String[] indexNames = new String[] { "with_tv", "without_tv" }; - assertAcked( - prepareCreate(indexNames[0]).addMapping("type1", "field1", "type=text,term_vector=with_positions_offsets,analyzer=keyword") - ); - assertAcked(prepareCreate(indexNames[1]).addMapping("type1", "field1", "type=text,term_vector=no,analyzer=keyword")); + assertAcked(prepareCreate(indexNames[0]).setMapping("field1", "type=text,term_vector=with_positions_offsets,analyzer=keyword")); + assertAcked(prepareCreate(indexNames[1]).setMapping("field1", "type=text,term_vector=no,analyzer=keyword")); ensureGreen(); // index documents with and without term vectors @@ -656,9 +653,7 @@ public void testSimpleWildCards() throws IOException { public void testArtificialVsExisting() throws ExecutionException, InterruptedException, IOException { // setup indices Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "standard"); - assertAcked( - prepareCreate("test").setSettings(settings).addMapping("type1", "field1", "type=text,term_vector=with_positions_offsets") - ); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("field1", "type=text,term_vector=with_positions_offsets")); ensureGreen(); // index documents existing document @@ -704,7 +699,7 @@ public void testArtificialVsExisting() throws ExecutionException, InterruptedExc public void testArtificialNoDoc() throws IOException { // setup indices Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "standard"); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", "field1", "type=text")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("field1", "type=text")); ensureGreen(); // request tvs from artificial document @@ -929,7 +924,7 @@ public void testTermVectorsWithVersion() { public void testFilterLength() throws ExecutionException, InterruptedException, IOException { logger.info("Setting up the index ..."); Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "keyword"); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", "tags", "type=text")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("tags", "type=text")); int numTerms = scaledRandomIntBetween(10, 50); logger.info("Indexing one document with tags of increasing length ..."); @@ -962,7 +957,7 @@ public void testFilterLength() throws ExecutionException, InterruptedException, public void testFilterTermFreq() throws ExecutionException, InterruptedException, IOException { logger.info("Setting up the index ..."); Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "keyword"); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", "tags", "type=text")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("tags", "type=text")); logger.info("Indexing one document with tags of increasing frequencies ..."); int numTerms = scaledRandomIntBetween(10, 50); @@ -1000,7 +995,7 @@ public void testFilterDocFreq() throws ExecutionException, InterruptedException, .put(indexSettings()) .put("index.analysis.analyzer", "keyword") .put("index.number_of_shards", 1); // no dfs - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", "tags", "type=text")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("tags", "type=text")); int numDocs = scaledRandomIntBetween(10, 50); // as many terms as there are docs logger.info("Indexing {} documents with tags of increasing dfs ...", numDocs); @@ -1030,9 +1025,7 @@ public void testFilterDocFreq() throws ExecutionException, InterruptedException, public void testArtificialDocWithPreference() throws InterruptedException, IOException { // setup indices Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "standard"); - assertAcked( - prepareCreate("test").setSettings(settings).addMapping("type1", "field1", "type=text,term_vector=with_positions_offsets") - ); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("field1", "type=text,term_vector=with_positions_offsets")); ensureGreen(); // index document @@ -1076,8 +1069,7 @@ public void testWithKeywordAndNormalizer() throws IOException, ExecutionExceptio .putList("index.analysis.normalizer.my_normalizer.filter", "lowercase"); assertAcked( prepareCreate(indexNames[0]).setSettings(builder.build()) - .addMapping( - "type1", + .setMapping( "field1", "type=text,term_vector=with_positions_offsets,analyzer=my_analyzer", "field2", @@ -1086,7 +1078,7 @@ public void testWithKeywordAndNormalizer() throws IOException, ExecutionExceptio ); assertAcked( prepareCreate(indexNames[1]).setSettings(builder.build()) - .addMapping("type1", "field1", "type=keyword,normalizer=my_normalizer", "field2", "type=keyword") + .setMapping("field1", "type=keyword,normalizer=my_normalizer", "field2", "type=keyword") ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java b/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java index 2d01e4c031538..ff64a2cd90cb8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java @@ -226,7 +226,7 @@ public void testFailedFilter() throws Exception { public void testFilteringAliases() throws Exception { logger.info("--> creating index [test]"); - assertAcked(prepareCreate("test").addMapping("type", "user", "type=text")); + assertAcked(prepareCreate("test").setMapping("user", "type=text")); ensureGreen(); @@ -260,7 +260,7 @@ public void testEmptyFilter() throws Exception { public void testSearchingFilteringAliasesSingleIndex() throws Exception { logger.info("--> creating index [test]"); - assertAcked(prepareCreate("test").addMapping("type1", "id", "type=text", "name", "type=text,fielddata=true")); + assertAcked(prepareCreate("test").setMapping("id", "type=text", "name", "type=text,fielddata=true")); ensureGreen(); @@ -363,9 +363,9 @@ public void testSearchingFilteringAliasesSingleIndex() throws Exception { public void testSearchingFilteringAliasesTwoIndices() throws Exception { logger.info("--> creating index [test1]"); - assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=text")); + assertAcked(prepareCreate("test1").setMapping("name", "type=text")); logger.info("--> creating index [test2]"); - assertAcked(prepareCreate("test2").addMapping("type1", "name", "type=text")); + assertAcked(prepareCreate("test2").setMapping("name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -593,8 +593,8 @@ public void testSearchingFilteringAliasesMultipleIndices() throws Exception { public void testDeletingByQueryFilteringAliases() throws Exception { logger.info("--> creating index [test1] and [test2"); - assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=text")); - assertAcked(prepareCreate("test2").addMapping("type1", "name", "type=text")); + assertAcked(prepareCreate("test1").setMapping("name", "type=text")); + assertAcked(prepareCreate("test2").setMapping("name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -648,8 +648,8 @@ public void testDeletingByQueryFilteringAliases() throws Exception { public void testDeleteAliases() throws Exception { logger.info("--> creating index [test1] and [test2]"); - assertAcked(prepareCreate("test1").addMapping("type", "name", "type=text")); - assertAcked(prepareCreate("test2").addMapping("type", "name", "type=text")); + assertAcked(prepareCreate("test1").setMapping("name", "type=text")); + assertAcked(prepareCreate("test2").setMapping("name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -780,7 +780,7 @@ public void run() { public void testSameAlias() throws Exception { logger.info("--> creating index [test]"); - assertAcked(prepareCreate("test").addMapping("type", "name", "type=text")); + assertAcked(prepareCreate("test").setMapping("name", "type=text")); ensureGreen(); logger.info("--> creating alias1 "); @@ -1073,7 +1073,7 @@ public void testGetAllAliasesWorks() { public void testCreateIndexWithAliases() throws Exception { assertAcked( - prepareCreate("test").addMapping("type", "field", "type=text") + prepareCreate("test").setMapping("field", "type=text") .addAlias(new Alias("alias1")) .addAlias(new Alias("alias2").filter(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("field")))) .addAlias(new Alias("alias3").indexRouting("index").searchRouting("search")) @@ -1103,7 +1103,7 @@ public void testCreateIndexWithAliasesInSource() throws Exception { public void testCreateIndexWithAliasesSource() throws Exception { assertAcked( - prepareCreate("test").addMapping("type", "field", "type=text") + prepareCreate("test").setMapping("field", "type=text") .setAliases( "{\n" + " \"alias1\" : {},\n" @@ -1180,7 +1180,7 @@ public void testAddAliasWithFilterNoMapping() throws Exception { } public void testAliasFilterWithNowInRangeFilterAndQuery() throws Exception { - assertAcked(prepareCreate("my-index").addMapping("my-type", "timestamp", "type=date")); + assertAcked(prepareCreate("my-index").setMapping("timestamp", "type=date")); assertAliasesVersionIncreases( "my-index", () -> assertAcked( diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java index 3060b5c23fe75..6f4c6fca77196 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java @@ -176,9 +176,7 @@ public void testDeleteCreateInOneBulk() throws Exception { internalCluster().startMasterOnlyNode(); String dataNode = internalCluster().startDataOnlyNode(); assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes("2").get().isTimedOut()); - prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping(MapperService.SINGLE_MAPPING_NAME) - .get(); + prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)).get(); ensureGreen("test"); // block none master node. diff --git a/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java b/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java index f3693be3b7227..1e40cc14bbb36 100644 --- a/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java @@ -69,7 +69,7 @@ */ public class DocumentActionsIT extends OpenSearchIntegTestCase { protected void createIndex() { - OpenSearchAssertions.assertAcked(prepareCreate(getConcreteIndexName()).addMapping("type1", "name", "type=keyword,store=true")); + OpenSearchAssertions.assertAcked(prepareCreate(getConcreteIndexName()).setMapping("name", "type=keyword,store=true")); } protected String getConcreteIndexName() { diff --git a/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java b/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java index be1335bd56ba9..5f217548794db 100644 --- a/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java @@ -125,7 +125,7 @@ private void prepareIndex(int numberOfPrimaryShards, boolean routingRequired) th Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfPrimaryShards) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numCopies - 1) - ).addMapping("type", "_routing", "required=" + routingRequired).get() + ).setMapping("_routing", "required=" + routingRequired).get() ); for (int i = 0; i < numberOfPrimaryShards; i++) { ensureActiveShardCopies(i, numNodes); diff --git a/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java b/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java index 78069970c1a60..53da0309aa602 100644 --- a/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java @@ -115,7 +115,7 @@ public void testSimple() throws Exception { public void testExplainWithFields() throws Exception { assertAcked( - prepareCreate("test").addMapping("test", "obj1.field1", "type=keyword,store=true", "obj1.field2", "type=keyword,store=true") + prepareCreate("test").setMapping("obj1.field1", "type=keyword,store=true", "obj1.field2", "type=keyword,store=true") .addAlias(new Alias("alias")) ); ensureGreen("test"); @@ -212,7 +212,7 @@ public void testExplainWithSource() throws Exception { public void testExplainWithFilteredAlias() { assertAcked( - prepareCreate("test").addMapping("test", "field2", "type=text") + prepareCreate("test").setMapping("field2", "type=text") .addAlias(new Alias("alias1").filter(QueryBuilders.termQuery("field2", "value2"))) ); ensureGreen("test"); @@ -231,7 +231,7 @@ public void testExplainWithFilteredAliasFetchSource() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("test", "field2", "type=text") + .setMapping("field2", "type=text") .addAlias(new Alias("alias1").filter(QueryBuilders.termQuery("field2", "value2"))) ); ensureGreen("test"); diff --git a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java index a09778582b604..2f811d4a901bf 100644 --- a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java @@ -84,7 +84,7 @@ protected Collection> nodePlugins() { public void testSimpleGet() { assertAcked( - prepareCreate("test").addMapping("type1", "field1", "type=keyword,store=true", "field2", "type=keyword,store=true") + prepareCreate("test").setMapping("field1", "type=keyword,store=true", "field2", "type=keyword,store=true") .setSettings(Settings.builder().put("index.refresh_interval", -1)) .addAlias(new Alias("alias").writeIndex(randomFrom(true, false, null))) ); @@ -234,7 +234,7 @@ static String indexOrAlias() { public void testSimpleMultiGet() throws Exception { assertAcked( prepareCreate("test").addAlias(new Alias("alias").writeIndex(randomFrom(true, false, null))) - .addMapping("type1", "field", "type=keyword,store=true") + .setMapping("field", "type=keyword,store=true") .setSettings(Settings.builder().put("index.refresh_interval", -1)) ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/suggest/stats/SuggestStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/index/suggest/stats/SuggestStatsIT.java index 1137a3038fd18..9940b1eb13a52 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/suggest/stats/SuggestStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/suggest/stats/SuggestStatsIT.java @@ -79,12 +79,12 @@ public void testSimpleStats() throws Exception { assertAcked( prepareCreate("test1").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, shardsIdx1).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("type", "f", "type=text") + ).setMapping("f", "type=text") ); assertAcked( prepareCreate("test2").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, shardsIdx2).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("type", "f", "type=text") + ).setMapping("f", "type=text") ); assertThat(shardsIdx1 + shardsIdx2, equalTo(numAssignedShards("test1", "test2"))); assertThat(numAssignedShards("test1", "test2"), greaterThanOrEqualTo(2)); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java index 18940cba80799..12fee85288bc2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java @@ -73,7 +73,7 @@ public void testCacheAggs() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "f", "type=date") + .setMapping("f", "type=date") .setSettings(Settings.builder().put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)) .get() ); @@ -137,7 +137,7 @@ public void testQueryRewrite() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "s", "type=date") + .setMapping("s", "type=date") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) @@ -208,7 +208,7 @@ public void testQueryRewriteMissingValues() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "s", "type=date") + .setMapping("s", "type=date") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) @@ -274,7 +274,7 @@ public void testQueryRewriteDates() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "d", "type=date") + .setMapping("d", "type=date") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) @@ -345,9 +345,9 @@ public void testQueryRewriteDatesWithNow() throws Exception { .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .build(); - assertAcked(client.admin().indices().prepareCreate("index-1").addMapping("type", "d", "type=date").setSettings(settings).get()); - assertAcked(client.admin().indices().prepareCreate("index-2").addMapping("type", "d", "type=date").setSettings(settings).get()); - assertAcked(client.admin().indices().prepareCreate("index-3").addMapping("type", "d", "type=date").setSettings(settings).get()); + assertAcked(client.admin().indices().prepareCreate("index-1").setMapping("d", "type=date").setSettings(settings).get()); + assertAcked(client.admin().indices().prepareCreate("index-2").setMapping("d", "type=date").setSettings(settings).get()); + assertAcked(client.admin().indices().prepareCreate("index-3").setMapping("d", "type=date").setSettings(settings).get()); ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC); DateFormatter formatter = DateFormatter.forPattern("strict_date_optional_time"); indexRandom( @@ -426,7 +426,7 @@ public void testCanCache() throws Exception { .put("index.number_of_routing_shards", 2) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .build(); - assertAcked(client.admin().indices().prepareCreate("index").addMapping("type", "s", "type=date").setSettings(settings).get()); + assertAcked(client.admin().indices().prepareCreate("index").setMapping("s", "type=date").setSettings(settings).get()); indexRandom( true, client.prepareIndex("index").setId("1").setRouting("1").setSource("s", "2016-03-19"), @@ -529,7 +529,7 @@ public void testCacheWithFilteredAlias() { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "created_at", "type=date") + .setMapping("created_at", "type=date") .setSettings(settings) .addAlias(new Alias("last_week").filter(QueryBuilders.rangeQuery("created_at").gte("now-7d/d"))) .get() @@ -578,7 +578,7 @@ public void testProfileDisableCache() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("_doc", "k", "type=keyword") + .setMapping("k", "type=keyword") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java index 7218495898677..1d25051eefe44 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java @@ -99,7 +99,7 @@ public void testSimpleAnalyzerTests() throws Exception { } public void testAnalyzeNumericField() throws IOException { - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("test", "long", "type=long", "double", "type=double")); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping("long", "type=long", "double", "type=double")); ensureGreen("test"); expectThrows( @@ -413,7 +413,7 @@ public void testCustomTokenFilterInRequest() throws Exception { } public void testAnalyzeKeywordField() throws IOException { - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("test", "keyword", "type=keyword")); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping("keyword", "type=keyword")); ensureGreen("test"); AnalyzeAction.Response analyzeResponse = client().admin().indices().prepareAnalyze(indexOrAlias(), "ABC").setField("keyword").get(); @@ -435,7 +435,7 @@ public void testAnalyzeNormalizedKeywordField() throws IOException { .put("index.analysis.normalizer.my_normalizer.type", "custom") .putList("index.analysis.normalizer.my_normalizer.filter", "lowercase") ) - .addMapping("test", "keyword", "type=keyword,normalizer=my_normalizer") + .setMapping("keyword", "type=keyword,normalizer=my_normalizer") ); ensureGreen("test"); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/memory/breaker/CircuitBreakerServiceIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/memory/breaker/CircuitBreakerServiceIT.java index e9bb9f5a90477..2dc6b2085b866 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/memory/breaker/CircuitBreakerServiceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/memory/breaker/CircuitBreakerServiceIT.java @@ -142,8 +142,7 @@ public void testMemoryBreaker() throws Exception { return; } assertAcked( - prepareCreate("cb-test", 1, Settings.builder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))).addMapping( - "type", + prepareCreate("cb-test", 1, Settings.builder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))).setMapping( "test", "type=text,fielddata=true" ) diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java index 7fd2466647272..08cf33a342c65 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java @@ -62,7 +62,7 @@ public void testPrimaryRelocationWhileIndexing() throws Exception { .indices() .prepareCreate("test") .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)) - .addMapping("type", "field", "type=text") + .setMapping("field", "type=text") .get(); ensureGreen("test"); AtomicInteger numAutoGenDocs = new AtomicInteger(); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java index a24f55be3f010..be8a1ad4f0c61 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java @@ -148,7 +148,7 @@ public void testFieldDataStats() { .indices() .prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_shards", 2)) - .addMapping("type", "field", "type=text,fielddata=true", "field2", "type=text,fielddata=true") + .setMapping("field", "type=text,fielddata=true", "field2", "type=text,fielddata=true") .get() ); ensureGreen(); @@ -270,7 +270,7 @@ public void testClearAllCaches() throws Exception { .indices() .prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_replicas", 0).put("index.number_of_shards", 2)) - .addMapping("type", "field", "type=text,fielddata=true") + .setMapping("field", "type=text,fielddata=true") .get() ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java index 6065db46d8ee2..090cf81de60a3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java @@ -624,7 +624,7 @@ public void testIndexTemplateWithAliasesInSource() { ) .get(); - assertAcked(prepareCreate("test_index").addMapping("_doc")); + assertAcked(prepareCreate("test_index")); ensureGreen(); GetAliasesResponse getAliasesResponse = client().admin().indices().prepareGetAliases().setIndices("test_index").get(); @@ -663,7 +663,7 @@ public void testIndexTemplateWithAliasesSource() { ) .get(); - assertAcked(prepareCreate("test_index").addMapping("_doc")); + assertAcked(prepareCreate("test_index")); ensureGreen(); GetAliasesResponse getAliasesResponse = client().admin().indices().prepareGetAliases().setIndices("test_index").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java b/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java index 71da9168c6205..1708454faf7b3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java @@ -108,7 +108,7 @@ public void testCancelRecoveryAndResume() throws Exception { // create the index and prevent allocation on any other nodes than the lucky one // we have no replicas so far and make sure that we allocate the primary on the lucky node assertAcked( - prepareCreate("test").addMapping("type1", "field1", "type=text", "the_id", "type=text") + prepareCreate("test").setMapping("field1", "type=text", "the_id", "type=text") .setSettings( Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/AggregationsIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/AggregationsIntegrationIT.java index 303b84151cf3e..6778765599fe9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/AggregationsIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/AggregationsIntegrationIT.java @@ -52,7 +52,7 @@ public class AggregationsIntegrationIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "f", "type=keyword").get()); + assertAcked(prepareCreate("index").setMapping("f", "type=keyword").get()); numDocs = randomIntBetween(1, 20); List docs = new ArrayList<>(); for (int i = 0; i < numDocs; ++i) { diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MetadataIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MetadataIT.java index c00152a54bd37..f210af7c10fb3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MetadataIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MetadataIT.java @@ -53,7 +53,7 @@ public class MetadataIT extends OpenSearchIntegTestCase { public void testMetadataSetOnAggregationResult() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "name", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("name", "type=keyword").get()); IndexRequestBuilder[] builders = new IndexRequestBuilder[randomInt(30)]; for (int i = 0; i < builders.length; i++) { String name = "name_" + randomIntBetween(1, 10); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MissingValueIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MissingValueIT.java index 9135ca0f0a364..7d3f06760882d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MissingValueIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MissingValueIT.java @@ -67,9 +67,7 @@ protected int maximumNumberOfShards() { @Override protected void setupSuiteScopeCluster() throws Exception { - assertAcked( - prepareCreate("idx").addMapping("type", "date", "type=date", "location", "type=geo_point", "str", "type=keyword").get() - ); + assertAcked(prepareCreate("idx").setMapping("date", "type=date", "location", "type=geo_point", "str", "type=keyword").get()); indexRandom( true, client().prepareIndex("idx").setId("1").setSource(), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/AdjacencyMatrixIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/AdjacencyMatrixIT.java index 5d54359152816..af3cc85ed40c0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/AdjacencyMatrixIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/AdjacencyMatrixIT.java @@ -117,7 +117,7 @@ public void setupSuiteScopeCluster() throws Exception { builders.add(client().prepareIndex("idx").setId("" + i).setSource(source)); } } - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramIT.java index 2c095857089e1..782bcde39ce8d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramIT.java @@ -144,7 +144,7 @@ private IndexRequestBuilder indexDoc(int month, int day, int value) throws Excep public void setupSuiteScopeCluster() throws Exception { createIndex("idx", "idx_unmapped"); // TODO: would be nice to have more random data here - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping("value", "type=integer")); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( @@ -188,7 +188,7 @@ private void getMultiSortDocs(List builders) throws IOExcep addExpectedBucket(date(1, 6), 1, 5, 1); addExpectedBucket(date(1, 7), 1, 5, 1); - assertAcked(client().admin().indices().prepareCreate("sort_idx").addMapping("type", "date", "type=date").get()); + assertAcked(client().admin().indices().prepareCreate("sort_idx").setMapping("date", "type=date").get()); for (int i = 1; i <= 3; i++) { builders.add( client().prepareIndex("sort_idx") @@ -1038,7 +1038,7 @@ public void testEmptyAggregation() throws Exception { } public void testSingleValueWithTimeZone() throws Exception { - prepareCreate("idx2").addMapping("type", "date", "type=date").get(); + prepareCreate("idx2").setMapping("date", "type=date").get(); IndexRequestBuilder[] reqs = new IndexRequestBuilder[5]; ZonedDateTime date = date("2014-03-11T00:00:00+00:00"); for (int i = 0; i < reqs.length; i++) { @@ -1394,7 +1394,7 @@ public void testIssue6965() { } public void testDSTBoundaryIssue9491() throws InterruptedException, ExecutionException { - assertAcked(client().admin().indices().prepareCreate("test9491").addMapping("type", "d", "type=date").get()); + assertAcked(client().admin().indices().prepareCreate("test9491").setMapping("d", "type=date").get()); indexRandom( true, client().prepareIndex("test9491").setSource("d", "2014-10-08T13:00:00Z"), @@ -1417,7 +1417,7 @@ public void testDSTBoundaryIssue9491() throws InterruptedException, ExecutionExc } public void testIssue8209() throws InterruptedException, ExecutionException { - assertAcked(client().admin().indices().prepareCreate("test8209").addMapping("type", "d", "type=date").get()); + assertAcked(client().admin().indices().prepareCreate("test8209").setMapping("d", "type=date").get()); indexRandom( true, client().prepareIndex("test8209").setSource("d", "2014-01-01T00:00:00Z"), @@ -1498,7 +1498,7 @@ public void testFormatIndexUnmapped() throws InterruptedException, ExecutionExce */ public void testRewriteTimeZone_EpochMillisFormat() throws InterruptedException, ExecutionException { String index = "test31392"; - assertAcked(client().admin().indices().prepareCreate(index).addMapping("type", "d", "type=date,format=epoch_millis").get()); + assertAcked(client().admin().indices().prepareCreate(index).setMapping("d", "type=date,format=epoch_millis").get()); indexRandom(true, client().prepareIndex(index).setSource("d", "1477954800000")); ensureSearchable(index); SearchResponse response = client().prepareSearch(index) @@ -1608,7 +1608,7 @@ public void testDSTEndTransition() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=date") + prepareCreate("cache_test_idx").setMapping("d", "type=date") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); @@ -1828,7 +1828,7 @@ private ZonedDateTime key(Histogram.Bucket bucket) { * timeZones. */ public void testDateNanosHistogram() throws Exception { - assertAcked(prepareCreate("nanos").addMapping("_doc", "date", "type=date_nanos").get()); + assertAcked(prepareCreate("nanos").setMapping("date", "type=date_nanos").get()); indexRandom(true, client().prepareIndex("nanos").setId("1").setSource("date", "2000-01-01")); indexRandom(true, client().prepareIndex("nanos").setId("2").setSource("date", "2000-01-02")); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramOffsetIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramOffsetIT.java index 2505cb48245c3..19e5bdb8916b8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramOffsetIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramOffsetIT.java @@ -72,7 +72,7 @@ private ZonedDateTime date(String date) { @Before public void beforeEachTest() throws IOException { - prepareCreate("idx2").addMapping("type", "date", "type=date").get(); + prepareCreate("idx2").setMapping("date", "type=date").get(); } @After diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateRangeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateRangeIT.java index 7a28df00980cc..470ee6a4d2cea 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateRangeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateRangeIT.java @@ -125,7 +125,7 @@ public void setupSuiteScopeCluster() throws Exception { for (int i = docs.size(); i < numDocs; ++i) { docs.add(indexDoc(randomIntBetween(6, 10), randomIntBetween(1, 20), randomInt(100))); } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping("value", "type=integer")); for (int i = 0; i < 2; i++) { docs.add( client().prepareIndex("empty_bucket_idx") @@ -913,7 +913,7 @@ public void testNoRangesInQuery() { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "date", "type=date") + prepareCreate("cache_test_idx").setMapping("date", "type=date") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); @@ -1070,7 +1070,7 @@ public void testScriptCaching() throws Exception { */ public void testRangeWithFormatStringValue() throws Exception { String indexName = "dateformat_test_idx"; - assertAcked(prepareCreate(indexName).addMapping("type", "date", "type=date,format=strict_hour_minute_second")); + assertAcked(prepareCreate(indexName).setMapping("date", "type=date,format=strict_hour_minute_second")); indexRandom( true, client().prepareIndex(indexName).setId("1").setSource(jsonBuilder().startObject().field("date", "00:16:40").endObject()), @@ -1132,7 +1132,7 @@ public void testRangeWithFormatStringValue() throws Exception { */ public void testRangeWithFormatNumericValue() throws Exception { String indexName = "dateformat_numeric_test_idx"; - assertAcked(prepareCreate(indexName).addMapping("type", "date", "type=date,format=epoch_second")); + assertAcked(prepareCreate(indexName).setMapping("date", "type=date,format=epoch_second")); indexRandom( true, client().prepareIndex(indexName).setId("1").setSource(jsonBuilder().startObject().field("date", 1002).endObject()), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java index aa4bb671d14e8..5b01e7573908c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java @@ -78,14 +78,14 @@ public void setupSuiteScopeCluster() throws Exception { assertAcked( prepareCreate("test").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("book", "author", "type=keyword", "name", "type=keyword", "genre", "type=keyword", "price", "type=float") + ).setMapping("author", "type=keyword", "name", "type=keyword", "genre", "type=keyword", "price", "type=float") ); createIndex("idx_unmapped"); // idx_unmapped_author is same as main index but missing author field assertAcked( prepareCreate("idx_unmapped_author").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("book", "name", "type=keyword", "genre", "type=keyword", "price", "type=float") + ).setMapping("name", "type=keyword", "genre", "type=keyword", "price", "type=float") ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DoubleTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DoubleTermsIT.java index 6c6e6ccc679e8..3093c7490a2a5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DoubleTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DoubleTermsIT.java @@ -178,7 +178,7 @@ public void setupSuiteScopeCluster() throws Exception { } createIndex("idx_unmapped"); - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") @@ -238,7 +238,7 @@ private void getMultiSortDocs(List builders) throws IOExcep bucketProps.put("sum_d", 1d); expectedMultiSortBuckets.put((Double) bucketProps.get("_term"), bucketProps); - assertAcked(prepareCreate("sort_idx").addMapping("multi_sort_type", SINGLE_VALUED_FIELD_NAME, "type=double")); + assertAcked(prepareCreate("sort_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=double")); for (int i = 1; i <= 3; i++) { builders.add( client().prepareIndex("sort_idx") @@ -980,7 +980,7 @@ public void testOtherDocCount() { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=float") + prepareCreate("cache_test_idx").setMapping("d", "type=float") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterIT.java index b938db8891d7b..0845db4f332d7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterIT.java @@ -90,7 +90,7 @@ public void setupSuiteScopeCluster() throws Exception { builders.add(client().prepareIndex("idx").setId("" + i).setSource(source)); } } - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FiltersIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FiltersIT.java index 0b895f32a1259..a64fe61b29b8a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FiltersIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FiltersIT.java @@ -109,7 +109,7 @@ public void setupSuiteScopeCluster() throws Exception { builders.add(client().prepareIndex("idx").setId("" + i).setSource(source)); } } - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java index a2d6533ae0afb..603a141abcaec 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java @@ -93,9 +93,9 @@ private IndexRequestBuilder indexCity(String idx, String name, String... latLons @Override public void setupSuiteScopeCluster() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - prepareCreate("idx").setSettings(settings).addMapping("type", "location", "type=geo_point", "city", "type=keyword").get(); + prepareCreate("idx").setSettings(settings).setMapping("location", "type=geo_point", "city", "type=keyword").get(); - prepareCreate("idx-multi").addMapping("type", "location", "type=geo_point", "city", "type=keyword").get(); + prepareCreate("idx-multi").setMapping("location", "type=geo_point", "city", "type=keyword").get(); createIndex("idx_unmapped"); @@ -138,7 +138,7 @@ public void setupSuiteScopeCluster() throws Exception { cities.add(indexCity("idx-multi", cityName)); } indexRandom(true, cities); - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer", "location", "type=geo_point").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer", "location", "type=geo_point").get(); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java index c7c21c203af61..56d918feef9d8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java @@ -101,7 +101,7 @@ public void setupSuiteScopeCluster() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - assertAcked(prepareCreate("idx").setSettings(settings).addMapping("type", "location", "type=geo_point", "city", "type=keyword")); + assertAcked(prepareCreate("idx").setSettings(settings).setMapping("location", "type=geo_point", "city", "type=keyword")); List cities = new ArrayList<>(); Random random = random(); @@ -126,7 +126,7 @@ public void setupSuiteScopeCluster() throws Exception { indexRandom(true, cities); assertAcked( - prepareCreate("multi_valued_idx").setSettings(settings).addMapping("type", "location", "type=geo_point", "city", "type=keyword") + prepareCreate("multi_valued_idx").setSettings(settings).setMapping("location", "type=geo_point", "city", "type=keyword") ); cities = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/HistogramIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/HistogramIT.java index fbdcc6b878943..dae788abe0d10 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/HistogramIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/HistogramIT.java @@ -180,7 +180,7 @@ public void setupSuiteScopeCluster() throws Exception { getMultiSortDocs(builders); - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") @@ -211,7 +211,7 @@ private void getMultiSortDocs(List builders) throws IOExcep addExpectedBucket(6, 1, 5, 1); addExpectedBucket(7, 1, 5, 1); - assertAcked(client().admin().indices().prepareCreate("sort_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=double").get()); + assertAcked(client().admin().indices().prepareCreate("sort_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=double").get()); for (int i = 1; i <= 3; i++) { builders.add( client().prepareIndex("sort_idx") @@ -1124,7 +1124,7 @@ public void testExeptionOnNegativerInterval() { } public void testDecimalIntervalAndOffset() throws Exception { - assertAcked(prepareCreate("decimal_values").addMapping("type", "d", "type=float").get()); + assertAcked(prepareCreate("decimal_values").setMapping("d", "type=float").get()); indexRandom( true, client().prepareIndex("decimal_values").setId("1").setSource("d", -0.6), @@ -1151,7 +1151,7 @@ public void testDecimalIntervalAndOffset() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=float") + prepareCreate("cache_test_idx").setMapping("d", "type=float") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); @@ -1349,7 +1349,7 @@ public void testInvalidBounds() { } public void testHardBounds() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "d", "type=double").get()); + assertAcked(prepareCreate("test").setMapping("d", "type=double").get()); indexRandom( true, client().prepareIndex("test").setId("1").setSource("d", -0.6), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpRangeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpRangeIT.java index b768631225b90..f8f666aaa3c1b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpRangeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpRangeIT.java @@ -70,7 +70,7 @@ protected Collection> nodePlugins() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "ip", "type=ip", "ips", "type=ip")); + assertAcked(prepareCreate("idx").setMapping("ip", "type=ip", "ips", "type=ip")); waitForRelocation(ClusterHealthStatus.GREEN); indexRandom( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpTermsIT.java index 53ff70dd240d1..cff51e74fdbd0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpTermsIT.java @@ -76,7 +76,7 @@ protected Map, Object>> pluginScripts() { } public void testScriptValue() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "ip", "type=ip")); + assertAcked(prepareCreate("index").setMapping("ip", "type=ip")); indexRandom( true, client().prepareIndex("index").setId("1").setSource("ip", "192.168.1.7"), @@ -104,7 +104,7 @@ public void testScriptValue() throws Exception { } public void testScriptValues() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "ip", "type=ip")); + assertAcked(prepareCreate("index").setMapping("ip", "type=ip")); indexRandom( true, client().prepareIndex("index").setId("1").setSource("ip", "192.168.1.7"), @@ -132,7 +132,7 @@ public void testScriptValues() throws Exception { } public void testMissingValue() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "ip", "type=ip")); + assertAcked(prepareCreate("index").setMapping("ip", "type=ip")); indexRandom( true, client().prepareIndex("index").setId("1").setSource("ip", "192.168.1.7"), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/LongTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/LongTermsIT.java index 115b30643ff21..87968bd2117c6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/LongTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/LongTermsIT.java @@ -164,7 +164,7 @@ public void setupSuiteScopeCluster() throws Exception { indexRandom(true, highCardBuilders); createIndex("idx_unmapped"); - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( @@ -928,7 +928,7 @@ public void testOtherDocCount() { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MinDocCountIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MinDocCountIT.java index 47cddbf856090..08e696245209e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MinDocCountIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MinDocCountIT.java @@ -117,7 +117,7 @@ protected Map, Object>> pluginScripts() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "s", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("s", "type=keyword").get()); cardinality = randomIntBetween(8, 30); final List indexRequests = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NaNSortingIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NaNSortingIT.java index f03a3bdeb1716..3a3e02c577096 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NaNSortingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NaNSortingIT.java @@ -132,7 +132,7 @@ public String sortKey() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "string_value", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("string_value", "type=keyword").get()); final int numDocs = randomIntBetween(2, 10); for (int i = 0; i < numDocs; ++i) { final long value = randomInt(5); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java index 969a48b514f1a..fcde2f628ecd7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java @@ -96,7 +96,7 @@ public class NestedIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "nested", "type=nested", "incorrect", "type=object")); + assertAcked(prepareCreate("idx").setMapping("nested", "type=nested", "incorrect", "type=object")); ensureGreen("idx"); List builders = new ArrayList<>(); @@ -126,7 +126,7 @@ public void setupSuiteScopeCluster() throws Exception { builders.add(client().prepareIndex("idx").setId("" + i + 1).setSource(source)); } - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer", "nested", "type=nested").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer", "nested", "type=nested").get(); ensureGreen("empty_bucket_idx"); for (int i = 0; i < 2; i++) { builders.add( @@ -539,7 +539,7 @@ public void testParentFilterResolvedCorrectly() throws Exception { public void testNestedSameDocIdProcessedMultipleTime() throws Exception { assertAcked( prepareCreate("idx4").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping("product", "categories", "type=keyword", "name", "type=text", "property", "type=nested") + .setMapping("categories", "type=keyword", "name", "type=text", "property", "type=nested") ); ensureGreen("idx4"); @@ -808,7 +808,7 @@ public void testExtractInnerHitBuildersWithDuplicateHitName() throws Exception { assertAcked( prepareCreate("idxduplicatehitnames").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("product", "categories", "type=keyword", "name", "type=text", "property", "type=nested") + ).setMapping("categories", "type=keyword", "name", "type=text", "property", "type=nested") ); ensureGreen("idxduplicatehitnames"); @@ -832,7 +832,7 @@ public void testExtractInnerHitBuildersWithDuplicatePath() throws Exception { assertAcked( prepareCreate("idxnullhitnames").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("product", "categories", "type=keyword", "name", "type=text", "property", "type=nested") + ).setMapping("categories", "type=keyword", "name", "type=text", "property", "type=nested") ); ensureGreen("idxnullhitnames"); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/RangeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/RangeIT.java index bfbfc53ed7e76..c46d6dcd847e1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/RangeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/RangeIT.java @@ -136,7 +136,7 @@ public void setupSuiteScopeCluster() throws Exception { ); } createIndex("idx_unmapped"); - prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") @@ -152,8 +152,8 @@ public void setupSuiteScopeCluster() throws Exception { // Create two indices and add the field 'route_length_miles' as an alias in // one, and a concrete field in the other. - prepareCreate("old_index").addMapping("_doc", "distance", "type=double", "route_length_miles", "type=alias,path=distance").get(); - prepareCreate("new_index").addMapping("_doc", "route_length_miles", "type=double").get(); + prepareCreate("old_index").setMapping("distance", "type=double", "route_length_miles", "type=alias,path=distance").get(); + prepareCreate("new_index").setMapping("route_length_miles", "type=double").get(); builders.add(client().prepareIndex("old_index").setSource("distance", 42.0)); builders.add(client().prepareIndex("old_index").setSource("distance", 50.5)); @@ -931,7 +931,7 @@ public void testEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "i", "type=integer") + prepareCreate("cache_test_idx").setMapping("i", "type=integer") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java index 94204b6519374..0bfeff9297ce8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java @@ -77,14 +77,14 @@ public void setupSuiteScopeCluster() throws Exception { assertAcked( prepareCreate("test").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("book", "author", "type=keyword", "name", "type=text", "genre", "type=keyword", "price", "type=float") + ).setMapping("author", "type=keyword", "name", "type=text", "genre", "type=keyword", "price", "type=float") ); createIndex("idx_unmapped"); // idx_unmapped_author is same as main index but missing author field assertAcked( prepareCreate("idx_unmapped_author").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("book", "name", "type=text", "genre", "type=keyword", "price", "type=float") + ).setMapping("name", "type=text", "genre", "type=keyword", "price", "type=float") ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ShardReduceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ShardReduceIT.java index 2300e42b84bbc..7352dc7170a21 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ShardReduceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ShardReduceIT.java @@ -94,8 +94,7 @@ private IndexRequestBuilder indexDoc(String date, int value) throws Exception { @Override public void setupSuiteScopeCluster() throws Exception { assertAcked( - prepareCreate("idx").addMapping( - "type", + prepareCreate("idx").setMapping( "nested", "type=nested", "ip", diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java index cbcc9c396fc06..9c334df1d806b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java @@ -40,7 +40,6 @@ import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryBuilders; import org.opensearch.plugins.Plugin; @@ -215,7 +214,7 @@ public void testPopularTermManyDeletedDocs() throws Exception { String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}"; assertAcked( prepareCreate(INDEX_NAME).setSettings(settings, XContentType.JSON) - .addMapping("_doc", "text", "type=keyword", CLASS_FIELD, "type=keyword") + .setMapping("text", "type=keyword", CLASS_FIELD, "type=keyword") ); String[] cat1v1 = { "constant", "one" }; String[] cat1v2 = { "constant", "uno" }; @@ -453,7 +452,7 @@ public void testSubAggregations() throws Exception { private void indexEqualTestData() throws ExecutionException, InterruptedException { assertAcked( prepareCreate("test").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping("_doc", "text", "type=text,fielddata=true", "class", "type=keyword") + .setMapping("text", "type=text,fielddata=true", "class", "type=keyword") ); createIndex("idx_unmapped"); @@ -545,9 +544,7 @@ private void indexRandomFrequencies01(String type) throws ExecutionException, In if (type.equals("text")) { textMappings += ",fielddata=true"; } - assertAcked( - prepareCreate(INDEX_NAME).addMapping(MapperService.SINGLE_MAPPING_NAME, TEXT_FIELD, textMappings, CLASS_FIELD, "type=keyword") - ); + assertAcked(prepareCreate(INDEX_NAME).setMapping(TEXT_FIELD, textMappings, CLASS_FIELD, "type=keyword")); String[] gb = { "0", "1" }; List indexRequestBuilderList = new ArrayList<>(); for (int i = 0; i < randomInt(20); i++) { @@ -575,7 +572,7 @@ public void testReduceFromSeveralShards() throws IOException, ExecutionException */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsDocCountErrorIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsDocCountErrorIT.java index 9b941860177bb..3d76b994ebac3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsDocCountErrorIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsDocCountErrorIT.java @@ -74,7 +74,7 @@ public static String randomExecutionHint() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", STRING_FIELD_NAME, "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping(STRING_FIELD_NAME, "type=keyword").get()); List builders = new ArrayList<>(); int numDocs = between(10, 200); int numUniqueTerms = between(2, numDocs / 2); @@ -92,7 +92,7 @@ public void setupSuiteScopeCluster() throws Exception { ); } assertAcked( - prepareCreate("idx_single_shard").addMapping("type", STRING_FIELD_NAME, "type=keyword") + prepareCreate("idx_single_shard").setMapping(STRING_FIELD_NAME, "type=keyword") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) ); for (int i = 0; i < numDocs; i++) { @@ -125,7 +125,7 @@ public void setupSuiteScopeCluster() throws Exception { ); } assertAcked( - prepareCreate("idx_fixed_docs_0").addMapping("type", STRING_FIELD_NAME, "type=keyword") + prepareCreate("idx_fixed_docs_0").setMapping(STRING_FIELD_NAME, "type=keyword") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) ); Map shard0DocsPerTerm = new HashMap<>(); @@ -151,7 +151,7 @@ public void setupSuiteScopeCluster() throws Exception { } assertAcked( - prepareCreate("idx_fixed_docs_1").addMapping("type", STRING_FIELD_NAME, "type=keyword") + prepareCreate("idx_fixed_docs_1").setMapping(STRING_FIELD_NAME, "type=keyword") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) ); Map shard1DocsPerTerm = new HashMap<>(); @@ -177,7 +177,7 @@ public void setupSuiteScopeCluster() throws Exception { } assertAcked( - prepareCreate("idx_fixed_docs_2").addMapping("type", STRING_FIELD_NAME, "type=keyword") + prepareCreate("idx_fixed_docs_2").setMapping(STRING_FIELD_NAME, "type=keyword") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) ); Map shard2DocsPerTerm = new HashMap<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java index af006210326d8..852c3760751b3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java @@ -35,7 +35,6 @@ import org.opensearch.action.search.SearchResponse; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.QueryBuilders; import org.opensearch.search.aggregations.BucketOrder; import org.opensearch.search.aggregations.bucket.filter.InternalFilter; @@ -73,7 +72,7 @@ public void testShardMinDocCountSignificantTermsTest() throws Exception { } assertAcked( prepareCreate(index).setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping(MapperService.SINGLE_MAPPING_NAME, "text", textMappings) + .setMapping("text", textMappings) ); List indexBuilders = new ArrayList<>(); @@ -142,7 +141,7 @@ public void testShardMinDocCountTermsTest() throws Exception { } assertAcked( prepareCreate(index).setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping(MapperService.SINGLE_MAPPING_NAME, "text", termMappings) + .setMapping("text", termMappings) ); List indexBuilders = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/terms/StringTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/terms/StringTermsIT.java index 252ffeb4ca0e7..3190bcb72fcbb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/terms/StringTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/terms/StringTermsIT.java @@ -157,15 +157,7 @@ public void setupSuiteScopeCluster() throws Exception { client().admin() .indices() .prepareCreate("idx") - .addMapping( - "type", - SINGLE_VALUED_FIELD_NAME, - "type=keyword", - MULTI_VALUED_FIELD_NAME, - "type=keyword", - "tag", - "type=keyword" - ) + .setMapping(SINGLE_VALUED_FIELD_NAME, "type=keyword", MULTI_VALUED_FIELD_NAME, "type=keyword", "tag", "type=keyword") .get() ); List builders = new ArrayList<>(); @@ -193,15 +185,7 @@ public void setupSuiteScopeCluster() throws Exception { client().admin() .indices() .prepareCreate("high_card_idx") - .addMapping( - "type", - SINGLE_VALUED_FIELD_NAME, - "type=keyword", - MULTI_VALUED_FIELD_NAME, - "type=keyword", - "tag", - "type=keyword" - ) + .setMapping(SINGLE_VALUED_FIELD_NAME, "type=keyword", MULTI_VALUED_FIELD_NAME, "type=keyword", "tag", "type=keyword") .get() ); for (int i = 0; i < 100; i++) { @@ -218,7 +202,7 @@ public void setupSuiteScopeCluster() throws Exception { ) ); } - prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( @@ -281,15 +265,7 @@ private void getMultiSortDocs(List builders) throws IOExcep client().admin() .indices() .prepareCreate("sort_idx") - .addMapping( - "type", - SINGLE_VALUED_FIELD_NAME, - "type=keyword", - MULTI_VALUED_FIELD_NAME, - "type=keyword", - "tag", - "type=keyword" - ) + .setMapping(SINGLE_VALUED_FIELD_NAME, "type=keyword", MULTI_VALUED_FIELD_NAME, "type=keyword", "tag", "type=keyword") .get() ); for (int i = 1; i <= 3; i++) { @@ -1262,7 +1238,7 @@ public void testOtherDocCount() { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=keyword") + prepareCreate("cache_test_idx").setMapping("d", "type=keyword") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java index 7996e2bee44c1..147f451c14de8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java @@ -491,7 +491,7 @@ public void testAsSubAgg() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ExtendedStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ExtendedStatsIT.java index 9549aad5399b5..cd0a649659c6e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ExtendedStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ExtendedStatsIT.java @@ -869,7 +869,7 @@ private void checkUpperLowerBounds(ExtendedStats stats, double sigma) { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksIT.java index 7aa602fff2ee8..20fc6aaee20c9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksIT.java @@ -585,7 +585,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentilesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentilesIT.java index 68f8cf6da575a..2660dbe0a88ed 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentilesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentilesIT.java @@ -554,7 +554,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java index 79f1809fc2f3a..226b4dbca18d9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java @@ -137,7 +137,7 @@ public void setupSuiteScopeCluster() throws Exception { indexRandom(true, builders); - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { @@ -516,7 +516,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java index beacf7aa1ccec..27dbc56cf3b79 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java @@ -310,7 +310,7 @@ public void setupSuiteScopeCluster() throws Exception { // "1". then each test will have // to check that this bucket exists with the appropriate sub // aggregations. - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( @@ -1183,7 +1183,7 @@ public void testScriptCaching() throws Exception { Script ndRandom = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "return Math.random()", Collections.emptyMap()); assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/StatsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/StatsIT.java index 27fc26a114cc4..debdde8e13fe7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/StatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/StatsIT.java @@ -258,7 +258,7 @@ private void assertShardExecutionState(SearchResponse response, int expectedFail */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/SumIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/SumIT.java index e9b8c91090695..fe236f04c19e8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/SumIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/SumIT.java @@ -79,8 +79,7 @@ public void setupSuiteScopeCluster() throws Exception { // Create two indices and add the field 'route_length_miles' as an alias in // one, and a concrete field in the other. - prepareCreate("old_index").addMapping( - "_doc", + prepareCreate("old_index").setMapping( "transit_mode", "type=keyword", "distance", @@ -88,7 +87,7 @@ public void setupSuiteScopeCluster() throws Exception { "route_length_miles", "type=alias,path=distance" ).get(); - prepareCreate("new_index").addMapping("_doc", "transit_mode", "type=keyword", "route_length_miles", "type=double").get(); + prepareCreate("new_index").setMapping("transit_mode", "type=keyword", "route_length_miles", "type=double").get(); List builders = new ArrayList<>(); builders.add(client().prepareIndex("old_index").setSource("transit_mode", "train", "distance", 42.0)); @@ -236,7 +235,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksIT.java index 8b28261f7f00b..adf027222d7d9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksIT.java @@ -497,7 +497,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesIT.java index 2da6ac3f9e586..fda15f9b90ea2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesIT.java @@ -469,7 +469,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java index 53a3cd4da5446..c3240c5eef7c5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java @@ -135,8 +135,8 @@ public static String randomExecutionHint() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", TERMS_AGGS_FIELD, "type=keyword")); - assertAcked(prepareCreate("field-collapsing").addMapping("type", "group", "type=keyword")); + assertAcked(prepareCreate("idx").setMapping(TERMS_AGGS_FIELD, "type=keyword")); + assertAcked(prepareCreate("field-collapsing").setMapping("group", "type=keyword")); createIndex("empty"); assertAcked( prepareCreate("articles").setMapping( @@ -1143,7 +1143,7 @@ public void testNoStoredFields() throws Exception { public void testScriptCaching() throws Exception { try { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings( Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1) ) diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ValueCountIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ValueCountIT.java index 6d3fe1ed3f190..82e667bccc576 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ValueCountIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ValueCountIT.java @@ -238,7 +238,7 @@ public void testMultiValuedScriptWithParams() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/AvgBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/AvgBucketIT.java index 590587185b80e..6cd16a47e98d2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/AvgBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/AvgBucketIT.java @@ -71,7 +71,7 @@ public class AvgBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -100,7 +100,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DateDerivativeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DateDerivativeIT.java index d7f16b25a46e8..2c7890fb7b1cb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DateDerivativeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DateDerivativeIT.java @@ -103,7 +103,7 @@ public void setupSuiteScopeCluster() throws Exception { createIndex("idx"); createIndex("idx_unmapped"); // TODO: would be nice to have more random data here - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DerivativeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DerivativeIT.java index cff655e040124..c03ed8277a3b4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DerivativeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DerivativeIT.java @@ -140,7 +140,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts_empty = new Long[] { 1L, 1L, 2L, 0L, 2L, 2L, 0L, 0L, 0L, 3L, 2L, 1L }; firstDerivValueCounts_empty = new Double[] { null, 0d, 1d, -2d, 2d, 0d, -2d, 0d, 0d, 3d, -1d, -1d }; - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < valueCounts_empty.length; i++) { for (int docs = 0; docs < valueCounts_empty[i]; docs++) { builders.add(client().prepareIndex("empty_bucket_idx").setSource(newDocBuilder(i))); @@ -154,7 +154,7 @@ public void setupSuiteScopeCluster() throws Exception { firstDerivValueCounts_empty_rnd = new Double[numBuckets_empty_rnd]; firstDerivValueCounts_empty_rnd[0] = null; - assertAcked(prepareCreate("empty_bucket_idx_rnd").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx_rnd").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < numBuckets_empty_rnd; i++) { valueCounts_empty_rnd[i] = (long) randomIntBetween(1, 10); // make approximately half of the buckets empty diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java index 4400181eb2226..85fe794b05fc6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java @@ -74,7 +74,7 @@ public class ExtendedStatsBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped", "idx_gappy"); numDocs = randomIntBetween(6, 20); @@ -113,7 +113,7 @@ public void setupSuiteScopeCluster() throws Exception { ); } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java index 0d63e6d719610..22890620d6b15 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java @@ -85,7 +85,7 @@ public class MaxBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -114,7 +114,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MinBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MinBucketIT.java index 33cc350f10ff1..b3929943f0d02 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MinBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MinBucketIT.java @@ -71,7 +71,7 @@ public class MinBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -100,7 +100,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/PercentilesBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/PercentilesBucketIT.java index 6728c9f888aeb..1da079781dc63 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/PercentilesBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/PercentilesBucketIT.java @@ -75,7 +75,7 @@ public class PercentilesBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -104,7 +104,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/StatsBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/StatsBucketIT.java index 90b0aba10e40a..e9f34f6aa65d9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/StatsBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/StatsBucketIT.java @@ -71,7 +71,7 @@ public class StatsBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -100,7 +100,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/SumBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/SumBucketIT.java index 873c43d8b0f4c..5bd962017c247 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/SumBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/SumBucketIT.java @@ -71,7 +71,7 @@ public class SumBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -100,7 +100,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWhileRelocatingIT.java b/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWhileRelocatingIT.java index fedb6b18d93fb..c184d876dcb33 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWhileRelocatingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWhileRelocatingIT.java @@ -65,7 +65,7 @@ private void testSearchAndRelocateConcurrently(final int numberOfReplicas) throw .indices() .prepareCreate("test") .setSettings(Settings.builder().put("index.number_of_shards", numShards).put("index.number_of_replicas", numberOfReplicas)) - .addMapping("type", "loc", "type=geo_point", "test", "type=text") + .setMapping("loc", "type=geo_point", "test", "type=text") .get(); ensureGreen(); List indexBuilders = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportSearchFailuresIT.java b/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportSearchFailuresIT.java index 7982d9f5781fc..34b202cc09cf7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportSearchFailuresIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportSearchFailuresIT.java @@ -65,7 +65,7 @@ protected int maximumNumberOfReplicas() { public void testFailedSearchWithWrongQuery() throws Exception { logger.info("Start Testing failed search with wrong query"); - assertAcked(prepareCreate("test", 1).addMapping("type", "foo", "type=geo_point")); + assertAcked(prepareCreate("test", 1).setMapping("foo", "type=geo_point")); NumShards test = getNumShards("test"); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java index e28ef3c00a485..837e1e7e23ddf 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java @@ -242,7 +242,7 @@ public void testSimpleNested() throws Exception { } public void testRandomNested() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "field1", "type=nested", "field2", "type=nested")); + assertAcked(prepareCreate("idx").setMapping("field1", "type=nested", "field2", "type=nested")); int numDocs = scaledRandomIntBetween(25, 100); List requestBuilders = new ArrayList<>(); @@ -538,7 +538,7 @@ public void testNestedMultipleLayers() throws Exception { // Issue #9723 public void testNestedDefinedAsObject() throws Exception { - assertAcked(prepareCreate("articles").addMapping("article", "comments", "type=nested", "title", "type=text")); + assertAcked(prepareCreate("articles").setMapping("comments", "type=nested", "title", "type=text")); List requests = new ArrayList<>(); requests.add( @@ -852,7 +852,7 @@ public void testMatchesQueriesNestedInnerHits() throws Exception { } public void testNestedSource() throws Exception { - assertAcked(prepareCreate("index1").addMapping("message", "comments", "type=nested")); + assertAcked(prepareCreate("index1").setMapping("comments", "type=nested")); client().prepareIndex("index1") .setId("1") .setSource( @@ -947,7 +947,7 @@ public void testNestedSource() throws Exception { } public void testInnerHitsWithIgnoreUnmapped() throws Exception { - assertAcked(prepareCreate("index1").addMapping("_doc", "nested_type", "type=nested")); + assertAcked(prepareCreate("index1").setMapping("nested_type", "type=nested")); createIndex("index2"); client().prepareIndex("index1").setId("1").setSource("nested_type", Collections.singletonMap("key", "value")).get(); client().prepareIndex("index2").setId("3").setSource("key", "value").get(); @@ -967,7 +967,7 @@ public void testInnerHitsWithIgnoreUnmapped() throws Exception { } public void testUseMaxDocInsteadOfSize() throws Exception { - assertAcked(prepareCreate("index2").addMapping("type", "nested", "type=nested")); + assertAcked(prepareCreate("index2").setMapping("nested", "type=nested")); client().admin() .indices() .prepareUpdateSettings("index2") @@ -990,7 +990,7 @@ public void testUseMaxDocInsteadOfSize() throws Exception { } public void testTooHighResultWindow() throws Exception { - assertAcked(prepareCreate("index2").addMapping("type", "nested", "type=nested")); + assertAcked(prepareCreate("index2").setMapping("nested", "type=nested")); client().prepareIndex("index2") .setId("1") .setSource( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java index 74c2922ebf328..193a48cf0daa6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java @@ -332,9 +332,7 @@ public void testHighlightingWhenFieldsAreNotStoredThereIsNoSource() throws IOExc // see #3486 public void testHighTermFrequencyDoc() throws IOException { - assertAcked( - prepareCreate("test").addMapping("test", "name", "type=text,term_vector=with_positions_offsets,store=" + randomBoolean()) - ); + assertAcked(prepareCreate("test").setMapping("name", "type=text,term_vector=with_positions_offsets,store=" + randomBoolean())); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 6000; i++) { builder.append("abc").append(" "); @@ -350,8 +348,7 @@ public void testHighTermFrequencyDoc() throws IOException { public void testEnsureNoNegativeOffsets() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "no_long_term", "type=text,term_vector=with_positions_offsets", "long_term", @@ -620,8 +617,7 @@ public void testSourceLookupHighlightingUsingPostingsHighlighter() throws Except public void testHighlightIssue1994() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "title", "type=text,store=false", "titleTV", @@ -697,8 +693,7 @@ public void testGlobalHighlightingSettingsOverriddenAtFieldLevel() { // Issue #5175 public void testHighlightingOnWildcardFields() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "field-postings", "type=text,index_options=offsets", "field-fvh", @@ -1277,7 +1272,7 @@ public XContentBuilder type1TermVectorMapping() throws IOException { } public void testSameContent() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets")); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=with_positions_offsets")); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < 5; i++) { @@ -1305,7 +1300,7 @@ public void testSameContent() throws Exception { } public void testFastVectorHighlighterOffsetParameter() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets").get()); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=with_positions_offsets").get()); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < 5; i++) { @@ -1327,7 +1322,7 @@ public void testFastVectorHighlighterOffsetParameter() throws Exception { } public void testEscapeHtml() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true")); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true")); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < indexRequestBuilders.length; i++) { @@ -1348,7 +1343,7 @@ public void testEscapeHtml() throws Exception { } public void testEscapeHtmlVector() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets")); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=with_positions_offsets")); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < 5; i++) { @@ -1547,7 +1542,7 @@ public void testMultiMapperNoVectorFromSource() throws Exception { } public void testFastVectorHighlighterShouldFailIfNoTermVectors() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=no")); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=no")); ensureGreen(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -1584,9 +1579,7 @@ public void testFastVectorHighlighterShouldFailIfNoTermVectors() throws Exceptio } public void testDisableFastVectorHighlighter() throws Exception { - assertAcked( - prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets,analyzer=classic") - ); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=with_positions_offsets,analyzer=classic")); ensureGreen(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -1645,7 +1638,7 @@ public void testDisableFastVectorHighlighter() throws Exception { } public void testFSHHighlightAllMvFragments() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "tags", "type=text,term_vector=with_positions_offsets")); + assertAcked(prepareCreate("test").setMapping("tags", "type=text,term_vector=with_positions_offsets")); ensureGreen(); client().prepareIndex("test") .setId("1") @@ -1737,7 +1730,7 @@ public void testCommonTermsTermVector() throws IOException { } public void testPlainHighlightDifferentFragmenter() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "tags", "type=text")); + assertAcked(prepareCreate("test").setMapping("tags", "type=text")); ensureGreen(); client().prepareIndex("test") .setId("1") @@ -1824,8 +1817,7 @@ public void testPlainHighlighterMultipleFields() { public void testFastVectorHighlighterMultipleFields() { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "field1", "type=text,term_vector=with_positions_offsets", "field2", @@ -1849,7 +1841,7 @@ public void testFastVectorHighlighterMultipleFields() { } public void testMissingStoredField() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "highlight_field", "type=text,store=true")); + assertAcked(prepareCreate("test").setMapping("highlight_field", "type=text,store=true")); ensureGreen(); client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("field", "highlight").endObject()).get(); refresh(); @@ -1869,8 +1861,7 @@ public void testMissingStoredField() throws Exception { // Issue #3211 public void testNumericHighlighting() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "test", + prepareCreate("test").setMapping( "text", "type=text", "byte", @@ -1911,7 +1902,7 @@ public void testResetTwice() throws Exception { assertAcked( prepareCreate("test").setSettings( Settings.builder().put(indexSettings()).put("analysis.analyzer.my_analyzer.type", "mock_whitespace").build() - ).addMapping("type", "text", "type=text,analyzer=my_analyzer") + ).setMapping("text", "type=text,analyzer=my_analyzer") ); ensureGreen(); client().prepareIndex("test").setId("1").setSource("text", "opensearch test").get(); @@ -1927,8 +1918,7 @@ public void testResetTwice() throws Exception { public void testHighlightUsesHighlightQuery() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets" ) @@ -1974,8 +1964,7 @@ private static String randomStoreField() { public void testHighlightNoMatchSize() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets" ) @@ -2085,8 +2074,7 @@ public void testHighlightNoMatchSize() throws IOException { public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets" ) @@ -2181,8 +2169,7 @@ public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException { public void testHighlightNoMatchSizeNumberOfFragments() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets" ) @@ -2506,7 +2493,7 @@ public void testPostingsHighlighterOrderByScore() throws Exception { } public void testPostingsHighlighterEscapeHtml() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text," + randomStoreField() + "index_options=offsets")); + assertAcked(prepareCreate("test").setMapping("title", "type=text," + randomStoreField() + "index_options=offsets")); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < 5; i++) { @@ -3342,7 +3329,7 @@ public void testHighlightQueryRewriteDatesWithNow() throws Exception { client().admin() .indices() .prepareCreate("index-1") - .addMapping("type", "d", "type=date", "field", "type=text,store=true,term_vector=with_positions_offsets") + .setMapping("d", "type=date", "field", "type=text,store=true,term_vector=with_positions_offsets") .setSettings(Settings.builder().put("index.number_of_replicas", 0).put("index.number_of_shards", 2)) .get() ); @@ -3461,9 +3448,7 @@ public void testWithNestedQuery() throws Exception { public void testWithNormalizer() throws Exception { Builder builder = Settings.builder().put(indexSettings()).putList("index.analysis.normalizer.my_normalizer.filter", "lowercase"); - assertAcked( - prepareCreate("test").setSettings(builder.build()).addMapping("doc", "keyword", "type=keyword,normalizer=my_normalizer") - ); + assertAcked(prepareCreate("test").setSettings(builder.build()).setMapping("keyword", "type=keyword,normalizer=my_normalizer")); ensureGreen(); client().prepareIndex("test") @@ -3485,7 +3470,7 @@ public void testWithNormalizer() throws Exception { } public void testDisableHighlightIdField() throws Exception { - assertAcked(prepareCreate("test").addMapping("doc", "keyword", "type=keyword")); + assertAcked(prepareCreate("test").setMapping("keyword", "type=keyword")); ensureGreen(); client().prepareIndex("test") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java index aed2975ed3234..dacf388e2faa0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java @@ -222,8 +222,8 @@ public void testWithIndexAlias() { } public void testWithIndexFilter() throws InterruptedException { - assertAcked(prepareCreate("index-1").addMapping("_doc", "timestamp", "type=date", "field1", "type=keyword")); - assertAcked(prepareCreate("index-2").addMapping("_doc", "timestamp", "type=date", "field1", "type=long")); + assertAcked(prepareCreate("index-1").setMapping("timestamp", "type=date", "field1", "type=keyword")); + assertAcked(prepareCreate("index-2").setMapping("timestamp", "type=date", "field1", "type=long")); List reqs = new ArrayList<>(); reqs.add(client().prepareIndex("index-1").setSource("timestamp", "2015-07-08")); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java index 46d47d838f68b..25782f8dc18db 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java @@ -444,7 +444,7 @@ public void testScriptFieldWithNanos() throws Exception { } public void testIdBasedScriptFields() throws Exception { - prepareCreate("test").addMapping("type1", "num1", "type=long").get(); + prepareCreate("test").setMapping("num1", "type=long").get(); int numDocs = randomIntBetween(1, 30); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[numDocs]; @@ -839,7 +839,7 @@ public void testGetFieldsComplexField() throws Exception { // see #8203 public void testSingleValueFieldDatatField() throws ExecutionException, InterruptedException { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "test_field", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("test_field", "type=keyword").get()); indexRandom(true, client().prepareIndex("test").setId("1").setSource("test_field", "foobar")); refresh(); SearchResponse searchResponse = client().prepareSearch("test") @@ -1114,8 +1114,7 @@ public void testDocValueFields() throws Exception { public void testScriptFields() throws Exception { assertAcked( - prepareCreate("index").addMapping( - "type", + prepareCreate("index").setMapping( "s", "type=keyword", "l", diff --git a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/RandomScoreFunctionIT.java b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/RandomScoreFunctionIT.java index 670f5e65eb575..0701e96b71f38 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/RandomScoreFunctionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/RandomScoreFunctionIT.java @@ -168,8 +168,7 @@ public void testConsistentHitsWithSameSeed() throws Exception { public void testScoreAccessWithinScript() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type", + prepareCreate("test").setMapping( "body", "type=text", "index", diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java index c2d75b6aa55af..d0b017732b270 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java @@ -66,8 +66,7 @@ protected void setupSuiteScopeCluster() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); assertAcked( - prepareCreate("test").setSettings(settings) - .addMapping("type1", "location", "type=geo_point", "alias", "type=alias,path=location") + prepareCreate("test").setSettings(settings).setMapping("location", "type=geo_point", "alias", "type=alias,path=location") ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java index 7315155e39520..89eb6038d8110 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java @@ -136,9 +136,7 @@ public void testOrientationPersistence() throws Exception { */ public void testIgnoreMalformed() throws Exception { // create index - assertAcked( - client().admin().indices().prepareCreate("test").addMapping("geometry", "shape", "type=geo_shape,ignore_malformed=true").get() - ); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape,ignore_malformed=true").get()); ensureGreen(); // test self crossing ccw poly not crossing dateline @@ -188,7 +186,7 @@ public void testIgnoreMalformed() throws Exception { public void testMappingUpdate() throws Exception { // create index - assertAcked(client().admin().indices().prepareCreate("test").addMapping("geometry", "shape", "type=geo_shape").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape").get()); ensureGreen(); String update = "{\n" diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java index 28b00acd21479..61af97d46e7f3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java @@ -131,11 +131,7 @@ public void testOrientationPersistence() throws Exception { public void testIgnoreMalformed() throws Exception { // create index assertAcked( - client().admin() - .indices() - .prepareCreate("test") - .addMapping("geometry", "shape", "type=geo_shape,tree=quadtree,ignore_malformed=true") - .get() + client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape,tree=quadtree,ignore_malformed=true").get() ); ensureGreen(); @@ -226,11 +222,7 @@ public void testIndexShapeRouting() throws Exception { public void testLegacyCircle() throws Exception { // create index assertAcked( - client().admin() - .indices() - .prepareCreate("test") - .addMapping("geometry", "shape", "type=geo_shape,strategy=recursive,tree=geohash") - .get() + client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape,strategy=recursive,tree=geohash").get() ); ensureGreen(); @@ -255,11 +247,7 @@ public void testDisallowExpensiveQueries() throws InterruptedException, IOExcept try { // create index assertAcked( - client().admin() - .indices() - .prepareCreate("test") - .addMapping("_doc", "shape", "type=geo_shape,strategy=recursive,tree=geohash") - .get() + client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape,strategy=recursive,tree=geohash").get() ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java b/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java index 69b2e655dd0ad..b3253b036bda6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java @@ -42,7 +42,6 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.MoreLikeThisQueryBuilder; import org.opensearch.index.query.MoreLikeThisQueryBuilder.Item; import org.opensearch.index.query.QueryBuilder; @@ -183,7 +182,7 @@ public void testMoreLikeThisForZeroTokensInOneOfTheAnalyzedFields() throws Excep public void testSimpleMoreLikeOnLongField() throws Exception { logger.info("Creating index test"); - assertAcked(prepareCreate("test").addMapping("type1", "some_long", "type=long")); + assertAcked(prepareCreate("test").setMapping("some_long", "type=long")); logger.info("Running Cluster Health"); assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN)); @@ -598,7 +597,7 @@ public void testSimpleMoreLikeThisIds() throws Exception { public void testMoreLikeThisMultiValueFields() throws Exception { logger.info("Creating the index ..."); assertAcked( - prepareCreate("test").addMapping("type1", "text", "type=text,analyzer=keyword") + prepareCreate("test").setMapping("text", "type=text,analyzer=keyword") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1)) ); ensureGreen(); @@ -632,7 +631,7 @@ public void testMoreLikeThisMultiValueFields() throws Exception { public void testMinimumShouldMatch() throws ExecutionException, InterruptedException { logger.info("Creating the index ..."); assertAcked( - prepareCreate("test").addMapping("type1", "text", "type=text,analyzer=whitespace") + prepareCreate("test").setMapping("text", "type=text,analyzer=whitespace") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1)) ); ensureGreen(); @@ -693,15 +692,7 @@ public void testMoreLikeThisArtificialDocs() throws Exception { public void testMoreLikeThisMalformedArtificialDocs() throws Exception { logger.info("Creating the index ..."); - assertAcked( - prepareCreate("test").addMapping( - MapperService.SINGLE_MAPPING_NAME, - "text", - "type=text,analyzer=whitespace", - "date", - "type=date" - ) - ); + assertAcked(prepareCreate("test").setMapping("text", "type=text,analyzer=whitespace", "date", "type=date")); ensureGreen("test"); logger.info("Creating an index with a single document ..."); @@ -790,9 +781,7 @@ public void testMoreLikeThisUnlike() throws ExecutionException, InterruptedExcep } public void testSelectFields() throws IOException, ExecutionException, InterruptedException { - assertAcked( - prepareCreate("test").addMapping("type1", "text", "type=text,analyzer=whitespace", "text1", "type=text,analyzer=whitespace") - ); + assertAcked(prepareCreate("test").setMapping("text", "type=text,analyzer=whitespace", "text1", "type=text,analyzer=whitespace")); ensureGreen("test"); indexRandom( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java index e3c1abff5d206..d2d23cd47fc01 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java @@ -73,7 +73,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { public void testSimpleNested() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "nested1", "type=nested")); + assertAcked(prepareCreate("test").setMapping("nested1", "type=nested")); ensureGreen(); // check on no data, see it works @@ -1597,7 +1597,7 @@ public void testCheckFixedBitSetCache() throws Exception { if (loadFixedBitSeLazily) { settingsBuilder.put("index.load_fixed_bitset_filters_eagerly", false); } - assertAcked(prepareCreate("test").setSettings(settingsBuilder).addMapping("type")); + assertAcked(prepareCreate("test").setSettings(settingsBuilder)); client().prepareIndex("test").setId("0").setSource("field", "value").get(); client().prepareIndex("test").setId("1").setSource("field", "value").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java index 7d63db78e205a..f3d1a479f1b46 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java @@ -108,7 +108,7 @@ protected void setupSuiteScopeCluster() throws Exception { .indices() .prepareCreate("idx") .setSettings(org.opensearch.common.collect.Map.of("number_of_shards", 1, "number_of_replicas", 0)) - .addMapping("type", STRING_FIELD, "type=keyword", NUMBER_FIELD, "type=integer", TAG_FIELD, "type=keyword") + .setMapping(STRING_FIELD, "type=keyword", NUMBER_FIELD, "type=integer", TAG_FIELD, "type=keyword") .get() ); List builders = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java index 66b42fe266887..d87bbfb1fb69c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java @@ -1015,7 +1015,7 @@ public void testFuzzyFieldLevelBoosting() throws InterruptedException, Execution CreateIndexRequestBuilder builder = prepareCreate(idx).setSettings( Settings.builder().put(indexSettings()).put(SETTING_NUMBER_OF_SHARDS, 3).put(SETTING_NUMBER_OF_REPLICAS, 0) ); - assertAcked(builder.addMapping("type", "title", "type=text", "body", "type=text")); + assertAcked(builder.setMapping("title", "type=text", "body", "type=text")); ensureGreen(); List builders = new ArrayList<>(); builders.add(client().prepareIndex(idx).setId("1").setSource("title", "foo", "body", "bar")); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/ScriptScoreQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/ScriptScoreQueryIT.java index 59f9e020df0d9..d736365a6e236 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/ScriptScoreQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/ScriptScoreQueryIT.java @@ -88,7 +88,7 @@ protected Map, Object>> pluginScripts() { // 2) score is calculated based on a script with params // 3) min score applied public void testScriptScore() { - assertAcked(prepareCreate("test-index").addMapping("_doc", "field1", "type=text", "field2", "type=double")); + assertAcked(prepareCreate("test-index").setMapping("field1", "type=text", "field2", "type=double")); int docCount = 10; for (int i = 1; i <= docCount; i++) { client().prepareIndex("test-index").setId("" + i).setSource("field1", "text" + (i % 2), "field2", i).get(); @@ -114,7 +114,7 @@ public void testScriptScore() { } public void testScriptScoreBoolQuery() { - assertAcked(prepareCreate("test-index").addMapping("_doc", "field1", "type=text", "field2", "type=double")); + assertAcked(prepareCreate("test-index").setMapping("field1", "type=text", "field2", "type=double")); int docCount = 10; for (int i = 1; i <= docCount; i++) { client().prepareIndex("test-index").setId("" + i).setSource("field1", "text" + i, "field2", i).get(); @@ -136,7 +136,7 @@ public void testScriptScoreBoolQuery() { public void testRewrittenQuery() { assertAcked( prepareCreate("test-index2").setSettings(Settings.builder().put("index.number_of_shards", 1)) - .addMapping("_doc", "field1", "type=date", "field2", "type=double") + .setMapping("field1", "type=date", "field2", "type=double") ); client().prepareIndex("test-index2").setId("1").setSource("field1", "2019-09-01", "field2", 1).get(); client().prepareIndex("test-index2").setId("2").setSource("field1", "2019-10-01", "field2", 2).get(); @@ -154,7 +154,7 @@ public void testRewrittenQuery() { public void testDisallowExpensiveQueries() { try { - assertAcked(prepareCreate("test-index").addMapping("_doc", "field1", "type=text", "field2", "type=double")); + assertAcked(prepareCreate("test-index").setMapping("field1", "type=text", "field2", "type=double")); int docCount = 10; for (int i = 1; i <= docCount; i++) { client().prepareIndex("test-index").setId("" + i).setSource("field1", "text" + (i % 2), "field2", i).get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java index fa2d79ecb2017..fed5561c1df64 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java @@ -211,7 +211,7 @@ public void testIssue3177() { } public void testIndexOptions() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=text,index_options=docs")); + assertAcked(prepareCreate("test").setMapping("field1", "type=text,index_options=docs")); indexRandom( true, client().prepareIndex("test").setId("1").setSource("field1", "quick brown fox", "field2", "quick brown fox"), @@ -337,7 +337,7 @@ public void testCommonTermsQuery() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type1", "field1", "type=text,analyzer=whitespace") + .setMapping("field1", "type=text,analyzer=whitespace") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1)) .get(); indexRandom( @@ -479,7 +479,7 @@ public void testLowercaseExpandedTerms() { public void testDateRangeInQueryString() { // the mapping needs to be provided upfront otherwise we are not sure how many failures we get back // as with dynamic mappings some shards might be lacking behind and parse a different query - assertAcked(prepareCreate("test").addMapping("type", "past", "type=date", "future", "type=date")); + assertAcked(prepareCreate("test").setMapping("past", "type=date", "future", "type=date")); ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC); String aMonthAgo = DateTimeFormatter.ISO_LOCAL_DATE.format(now.minusMonths(1)); @@ -505,7 +505,7 @@ public void testDateRangeInQueryString() { public void testDateRangeInQueryStringWithTimeZone_7880() { // the mapping needs to be provided upfront otherwise we are not sure how many failures we get back // as with dynamic mappings some shards might be lacking behind and parse a different query - assertAcked(prepareCreate("test").addMapping("type", "past", "type=date")); + assertAcked(prepareCreate("test").setMapping("past", "type=date")); ZoneId timeZone = randomZone(); String now = DateFormatter.forPattern("strict_date_optional_time").format(Instant.now().atZone(timeZone)); @@ -523,7 +523,7 @@ public void testDateRangeInQueryStringWithTimeZone_7880() { public void testDateRangeInQueryStringWithTimeZone_10477() { // the mapping needs to be provided upfront otherwise we are not sure how many failures we get back // as with dynamic mappings some shards might be lacking behind and parse a different query - assertAcked(prepareCreate("test").addMapping("type", "past", "type=date")); + assertAcked(prepareCreate("test").setMapping("past", "type=date")); client().prepareIndex("test").setId("1").setSource("past", "2015-04-05T23:00:00+0000").get(); client().prepareIndex("test").setId("2").setSource("past", "2015-04-06T00:00:00+0000").get(); @@ -732,7 +732,7 @@ public void testFiltersWithCustomCacheKey() throws Exception { } public void testMatchQueryNumeric() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "long", "type=long", "double", "type=double")); + assertAcked(prepareCreate("test").setMapping("long", "type=long", "double", "type=double")); indexRandom( true, @@ -752,7 +752,7 @@ public void testMatchQueryNumeric() throws Exception { } public void testMatchQueryFuzzy() throws Exception { - assertAcked(prepareCreate("test").addMapping("_doc", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); indexRandom( true, @@ -846,9 +846,7 @@ public void testMultiMatchQuery() throws Exception { } public void testMatchQueryZeroTermsQuery() { - assertAcked( - prepareCreate("test").addMapping("type1", "field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic") - ); + assertAcked(prepareCreate("test").setMapping("field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic")); client().prepareIndex("test").setId("1").setSource("field1", "value1").get(); client().prepareIndex("test").setId("2").setSource("field1", "value2").get(); refresh(); @@ -869,9 +867,7 @@ public void testMatchQueryZeroTermsQuery() { } public void testMultiMatchQueryZeroTermsQuery() { - assertAcked( - prepareCreate("test").addMapping("type1", "field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic") - ); + assertAcked(prepareCreate("test").setMapping("field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic")); client().prepareIndex("test").setId("1").setSource("field1", "value1", "field2", "value2").get(); client().prepareIndex("test").setId("2").setSource("field1", "value3", "field2", "value4").get(); refresh(); @@ -1039,7 +1035,7 @@ public void testSpecialRangeSyntaxInQueryString() { } public void testEmptytermsQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "term", "type=text")); + assertAcked(prepareCreate("test").setMapping("term", "type=text")); indexRandom( true, @@ -1059,7 +1055,7 @@ public void testEmptytermsQuery() throws Exception { } public void testTermsQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "str", "type=text", "lng", "type=long", "dbl", "type=double")); + assertAcked(prepareCreate("test").setMapping("str", "type=text", "lng", "type=long", "dbl", "type=double")); indexRandom( true, @@ -1117,7 +1113,7 @@ public void testTermsQuery() throws Exception { } public void testTermsLookupFilter() throws Exception { - assertAcked(prepareCreate("lookup").addMapping("type", "terms", "type=text", "other", "type=text")); + assertAcked(prepareCreate("lookup").setMapping("terms", "type=text", "other", "type=text")); assertAcked( prepareCreate("lookup2").setMapping( jsonBuilder().startObject() @@ -1133,8 +1129,8 @@ public void testTermsLookupFilter() throws Exception { .endObject() ) ); - assertAcked(prepareCreate("lookup3").addMapping("type", "_source", "enabled=false", "terms", "type=text")); - assertAcked(prepareCreate("test").addMapping("type", "term", "type=text")); + assertAcked(prepareCreate("lookup3").setMapping("_source", "enabled=false", "terms", "type=text")); + assertAcked(prepareCreate("test").setMapping("term", "type=text")); indexRandom( true, @@ -1283,8 +1279,7 @@ public void testBasicQueryById() throws Exception { public void testNumericTermsAndRanges() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "num_byte", "type=byte", "num_short", @@ -1400,8 +1395,7 @@ public void testNumericTermsAndRanges() throws Exception { public void testNumericRangeFilter_2826() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "num_byte", "type=byte", "num_short", @@ -1780,7 +1774,7 @@ public void testDateProvidedAsNumber() throws InterruptedException { } public void testRangeQueryWithTimeZone() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "date", "type=date", "num", "type=integer")); + assertAcked(prepareCreate("test").setMapping("date", "type=date", "num", "type=integer")); indexRandom( true, @@ -1955,7 +1949,7 @@ public void testQueryStringParserCache() throws Exception { } public void testRangeQueryRangeFields_24744() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "int_range", "type=integer_range")); + assertAcked(prepareCreate("test").setMapping("int_range", "type=integer_range")); client().prepareIndex("test") .setId("1") @@ -2064,7 +2058,7 @@ public void testWildcardQueryNormalizationOnKeywordField() { .put("index.analysis.normalizer.lowercase_normalizer.type", "custom") .putList("index.analysis.normalizer.lowercase_normalizer.filter", "lowercase") .build() - ).addMapping("_doc", "field1", "type=keyword,normalizer=lowercase_normalizer") + ).setMapping("field1", "type=keyword,normalizer=lowercase_normalizer") ); client().prepareIndex("test").setId("1").setSource("field1", "Bbb Aaa").get(); refresh(); @@ -2091,7 +2085,7 @@ public void testWildcardQueryNormalizationOnTextField() { .put("index.analysis.analyzer.lowercase_analyzer.tokenizer", "standard") .putList("index.analysis.analyzer.lowercase_analyzer.filter", "lowercase") .build() - ).addMapping("_doc", "field1", "type=text,analyzer=lowercase_analyzer") + ).setMapping("field1", "type=text,analyzer=lowercase_analyzer") ); client().prepareIndex("test").setId("1").setSource("field1", "Bbb Aaa").get(); refresh(); @@ -2119,7 +2113,7 @@ public void testWildcardQueryNormalizationKeywordSpecialCharacters() { .put("index.analysis.normalizer.no_wildcard.type", "custom") .put("index.analysis.normalizer.no_wildcard.char_filter", "no_wildcard") .build() - ).addMapping("_doc", "field", "type=keyword,normalizer=no_wildcard") + ).setMapping("field", "type=keyword,normalizer=no_wildcard") ); client().prepareIndex("test").setId("1").setSource("field", "label-1").get(); refresh(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java index 3bc9eb5b25261..5e45fd8d0ad2a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java @@ -240,7 +240,7 @@ public void testCustomScriptBoost() throws Exception { public void testDisallowExpensiveQueries() { try { - assertAcked(prepareCreate("test-index").addMapping("_doc", "num1", "type=double")); + assertAcked(prepareCreate("test-index").setMapping("num1", "type=double")); int docCount = 10; for (int i = 1; i <= docCount; i++) { client().prepareIndex("test-index").setId("" + i).setSource("num1", i).get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/scroll/SearchScrollIT.java b/server/src/internalClusterTest/java/org/opensearch/search/scroll/SearchScrollIT.java index 5c56671384868..3818566e2eb11 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/scroll/SearchScrollIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/scroll/SearchScrollIT.java @@ -541,7 +541,7 @@ public void testStringSortMissingAscTerminates() throws Exception { assertAcked( prepareCreate("test").setSettings( Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("test", "no_field", "type=keyword", "some_field", "type=keyword") + ).setMapping("no_field", "type=keyword", "some_field", "type=keyword") ); client().prepareIndex("test").setId("1").setSource("some_field", "test").get(); refresh(); @@ -718,7 +718,7 @@ public void testScrollRewrittenToMatchNoDocs() { .indices() .prepareCreate("test") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards)) - .addMapping("_doc", "created_date", "type=date,format=yyyy-MM-dd") + .setMapping("created_date", "type=date,format=yyyy-MM-dd") ); client().prepareIndex("test").setId("1").setSource("created_date", "2020-01-01").get(); client().prepareIndex("test").setId("2").setSource("created_date", "2020-01-02").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java b/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java index aae6c1dec48b3..926e21294ffc8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java @@ -59,13 +59,10 @@ public class SearchAfterIT extends OpenSearchIntegTestCase { private static final String INDEX_NAME = "test"; - private static final String TYPE_NAME = "type1"; private static final int NUM_DOCS = 100; public void testsShouldFail() throws Exception { - assertAcked( - client().admin().indices().prepareCreate("test").addMapping("type1", "field1", "type=long", "field2", "type=keyword").get() - ); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field1", "type=long", "field2", "type=keyword").get()); ensureGreen(); indexRandom(true, client().prepareIndex("test").setId("0").setSource("field1", 0, "field2", "toto")); { @@ -159,7 +156,7 @@ public void testsShouldFail() throws Exception { } public void testWithNullStrings() throws InterruptedException { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type1", "field2", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field2", "type=keyword").get()); ensureGreen(); indexRandom( true, @@ -219,7 +216,7 @@ public void testWithSimpleTypes() throws Exception { if (reqSize == 0) { reqSize = 1; } - assertSearchFromWithSortValues(INDEX_NAME, TYPE_NAME, documents, reqSize); + assertSearchFromWithSortValues(INDEX_NAME, documents, reqSize); } private static class ListComparator implements Comparator { @@ -250,10 +247,10 @@ public int compare(List o1, List o2) { private ListComparator LST_COMPARATOR = new ListComparator(); - private void assertSearchFromWithSortValues(String indexName, String typeName, List documents, int reqSize) throws Exception { + private void assertSearchFromWithSortValues(String indexName, List documents, int reqSize) throws Exception { int numFields = documents.get(0).size(); { - createIndexMappingsFromObjectType(indexName, typeName, documents.get(0)); + createIndexMappingsFromObjectType(indexName, documents.get(0)); List requests = new ArrayList<>(); for (int i = 0; i < documents.size(); i++) { XContentBuilder builder = jsonBuilder(); @@ -289,7 +286,7 @@ private void assertSearchFromWithSortValues(String indexName, String typeName, L } } - private void createIndexMappingsFromObjectType(String indexName, String typeName, List types) { + private void createIndexMappingsFromObjectType(String indexName, List types) { CreateIndexRequestBuilder indexRequestBuilder = client().admin().indices().prepareCreate(indexName); List mappings = new ArrayList<>(); int numFields = types.size(); @@ -323,7 +320,7 @@ private void createIndexMappingsFromObjectType(String indexName, String typeName fail("Can't match type [" + type + "]"); } } - indexRequestBuilder.addMapping(typeName, mappings.toArray(new String[0])).get(); + indexRequestBuilder.setMapping(mappings.toArray(new String[0])).get(); ensureGreen(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java index 0652b38228ec5..7382d4e157bc4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java @@ -295,7 +295,7 @@ public void testSimpleTerminateAfterCount() throws Exception { public void testSimpleIndexSortEarlyTerminate() throws Exception { prepareCreate("test").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0).put("index.sort.field", "rank") - ).addMapping(MapperService.SINGLE_MAPPING_NAME, "rank", "type=integer").get(); + ).setMapping("rank", "type=integer").get(); ensureGreen(); int max = randomIntBetween(3, 29); List docbuilders = new ArrayList<>(max); @@ -498,7 +498,7 @@ public void testTooLargeRescoreOkByDynamicResultWindowSetting() throws Exception } public void testQueryNumericFieldWithRegex() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "num", "type=integer")); + assertAcked(prepareCreate("idx").setMapping("num", "type=integer")); ensureGreen("idx"); try { @@ -510,7 +510,7 @@ public void testQueryNumericFieldWithRegex() throws Exception { } public void testTermQueryBigInt() throws Exception { - prepareCreate("idx").addMapping("type", "field", "type=keyword").get(); + prepareCreate("idx").setMapping("field", "type=keyword").get(); ensureGreen("idx"); client().prepareIndex("idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java index 3d1d407b386e1..4bf4cd138cbd1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java @@ -137,7 +137,7 @@ public void testIssue8226() { final boolean useMapping = randomBoolean(); for (int i = 0; i < numIndices; i++) { if (useMapping) { - assertAcked(prepareCreate("test_" + i).addAlias(new Alias("test")).addMapping("foo", "entry", "type=long")); + assertAcked(prepareCreate("test_" + i).addAlias(new Alias("test")).setMapping("entry", "type=long")); } else { assertAcked(prepareCreate("test_" + i).addAlias(new Alias("test"))); } @@ -243,7 +243,7 @@ public void testIssue6614() throws ExecutionException, InterruptedException { } public void testTrackScores() throws Exception { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type1", "svalue", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("svalue", "type=keyword").get()); ensureGreen(); index( "test", @@ -354,7 +354,7 @@ public void testRandomSorting() throws IOException, InterruptedException, Execut } public void test3078() { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "field", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field", "type=keyword").get()); ensureGreen(); for (int i = 1; i < 101; i++) { @@ -492,7 +492,7 @@ public void testScoreSortDirectionWithFunctionScore() throws Exception { } public void testIssue2986() { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("post", "field1", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field1", "type=keyword").get()); client().prepareIndex("test").setId("1").setSource("{\"field1\":\"value1\"}", XContentType.JSON).get(); client().prepareIndex("test").setId("2").setSource("{\"field1\":\"value2\"}", XContentType.JSON).get(); @@ -516,7 +516,7 @@ public void testIssue2991() { } catch (Exception e) { // ignore } - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("tag", "type=keyword").get()); ensureGreen(); client().prepareIndex("test").setId("1").setSource("tag", "alpha").get(); refresh(); @@ -1610,11 +1610,11 @@ public void testSortDuelBetweenSingleShardAndMultiShardIndex() throws Exception assertAcked( prepareCreate("test1").setSettings( Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(2, maximumNumberOfShards())) - ).addMapping("type", sortField, "type=long").get() + ).setMapping(sortField, "type=long").get() ); assertAcked( prepareCreate("test2").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) - .addMapping("type", sortField, "type=long") + .setMapping(sortField, "type=long") .get() ); @@ -1650,7 +1650,7 @@ public void testCustomFormat() throws Exception { // Use an ip field, which uses different internal/external // representations of values, to make sure values are both correctly // rendered and parsed (search_after) - assertAcked(prepareCreate("test").addMapping("type", "ip", "type=ip")); + assertAcked(prepareCreate("test").setMapping("ip", "type=ip")); indexRandom( true, client().prepareIndex("test").setId("1").setSource("ip", "192.168.1.7"), @@ -1671,7 +1671,7 @@ public void testCustomFormat() throws Exception { } public void testScriptFieldSort() throws Exception { - assertAcked(prepareCreate("test").addMapping("t", "keyword", "type=keyword", "number", "type=integer")); + assertAcked(prepareCreate("test").setMapping("keyword", "type=keyword", "number", "type=integer")); ensureGreen(); final int numDocs = randomIntBetween(10, 20); IndexRequestBuilder[] indexReqs = new IndexRequestBuilder[numDocs]; @@ -1721,10 +1721,8 @@ public void testScriptFieldSort() throws Exception { public void testFieldAlias() throws Exception { // Create two indices and add the field 'route_length_miles' as an alias in // one, and a concrete field in the other. - assertAcked( - prepareCreate("old_index").addMapping("_doc", "distance", "type=double", "route_length_miles", "type=alias,path=distance") - ); - assertAcked(prepareCreate("new_index").addMapping("_doc", "route_length_miles", "type=double")); + assertAcked(prepareCreate("old_index").setMapping("distance", "type=double", "route_length_miles", "type=alias,path=distance")); + assertAcked(prepareCreate("new_index").setMapping("route_length_miles", "type=double")); ensureGreen("old_index", "new_index"); List builders = new ArrayList<>(); @@ -1749,10 +1747,8 @@ public void testFieldAlias() throws Exception { public void testFieldAliasesWithMissingValues() throws Exception { // Create two indices and add the field 'route_length_miles' as an alias in // one, and a concrete field in the other. - assertAcked( - prepareCreate("old_index").addMapping("_doc", "distance", "type=double", "route_length_miles", "type=alias,path=distance") - ); - assertAcked(prepareCreate("new_index").addMapping("_doc", "route_length_miles", "type=double")); + assertAcked(prepareCreate("old_index").setMapping("distance", "type=double", "route_length_miles", "type=alias,path=distance")); + assertAcked(prepareCreate("new_index").setMapping("route_length_miles", "type=double")); ensureGreen("old_index", "new_index"); List builders = new ArrayList<>(); @@ -1775,9 +1771,9 @@ public void testFieldAliasesWithMissingValues() throws Exception { } public void testCastNumericType() throws Exception { - assertAcked(prepareCreate("index_double").addMapping("_doc", "field", "type=double")); - assertAcked(prepareCreate("index_long").addMapping("_doc", "field", "type=long")); - assertAcked(prepareCreate("index_float").addMapping("_doc", "field", "type=float")); + assertAcked(prepareCreate("index_double").setMapping("field", "type=double")); + assertAcked(prepareCreate("index_long").setMapping("field", "type=long")); + assertAcked(prepareCreate("index_float").setMapping("field", "type=float")); ensureGreen("index_double", "index_long", "index_float"); List builders = new ArrayList<>(); @@ -1821,8 +1817,8 @@ public void testCastNumericType() throws Exception { } public void testCastDate() throws Exception { - assertAcked(prepareCreate("index_date").addMapping("_doc", "field", "type=date")); - assertAcked(prepareCreate("index_date_nanos").addMapping("_doc", "field", "type=date_nanos")); + assertAcked(prepareCreate("index_date").setMapping("field", "type=date")); + assertAcked(prepareCreate("index_date_nanos").setMapping("field", "type=date_nanos")); ensureGreen("index_date", "index_date_nanos"); List builders = new ArrayList<>(); @@ -1937,7 +1933,7 @@ public void testCastDate() throws Exception { } public void testCastNumericTypeExceptions() throws Exception { - assertAcked(prepareCreate("index").addMapping("_doc", "keyword", "type=keyword", "ip", "type=ip")); + assertAcked(prepareCreate("index").setMapping("keyword", "type=keyword", "ip", "type=ip")); ensureGreen("index"); for (String invalidField : new String[] { "keyword", "ip" }) { for (String numericType : new String[] { "long", "double", "date", "date_nanos" }) { @@ -1957,7 +1953,7 @@ public void testCastNumericTypeExceptions() throws Exception { public void testLongSortOptimizationCorrectResults() { assertAcked( prepareCreate("test1").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 2)) - .addMapping("_doc", "long_field", "type=long") + .setMapping("long_field", "type=long") .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java index c283444666f0b..aebd83592e793 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java @@ -83,7 +83,7 @@ public void testManyToManyGeoPoints() throws ExecutionException, InterruptedExce */ Version version = randomBoolean() ? Version.CURRENT : VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point")); + assertAcked(prepareCreate("index").setSettings(settings).setMapping(LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); GeoPoint[] d1Points = { new GeoPoint(3, 2), new GeoPoint(4, 1) }; createShuffeldJSONArray(d1Builder, d1Points); @@ -174,7 +174,7 @@ public void testSingeToManyAvgMedian() throws ExecutionException, InterruptedExc */ Version version = randomBoolean() ? Version.CURRENT : VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point")); + assertAcked(prepareCreate("index").setSettings(settings).setMapping(LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); GeoPoint[] d1Points = { new GeoPoint(0, 1), new GeoPoint(0, 4), new GeoPoint(0, 10) }; createShuffeldJSONArray(d1Builder, d1Points); @@ -248,7 +248,7 @@ public void testManyToManyGeoPointsWithDifferentFormats() throws ExecutionExcept */ Version version = randomBoolean() ? Version.CURRENT : VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point")); + assertAcked(prepareCreate("index").setSettings(settings).setMapping(LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); GeoPoint[] d1Points = { new GeoPoint(2.5, 1), new GeoPoint(2.75, 2), new GeoPoint(3, 3), new GeoPoint(3.25, 4) }; createShuffeldJSONArray(d1Builder, d1Points); @@ -306,7 +306,7 @@ public void testManyToManyGeoPointsWithDifferentFormats() throws ExecutionExcept } public void testSinglePointGeoDistanceSort() throws ExecutionException, InterruptedException, IOException { - assertAcked(prepareCreate("index").addMapping("type", LOCATION_FIELD, "type=geo_point")); + assertAcked(prepareCreate("index").setMapping(LOCATION_FIELD, "type=geo_point")); indexRandom( true, client().prepareIndex("index") @@ -382,8 +382,7 @@ private static void checkCorrectSortOrderForGeoSort(SearchResponse searchRespons public void testCrossIndexIgnoreUnmapped() throws Exception { assertAcked( - prepareCreate("test1").addMapping("type", "str_field", "type=keyword", "long_field", "type=long", "double_field", "type=double") - .get() + prepareCreate("test1").setMapping("str_field", "type=keyword", "long_field", "type=long", "double_field", "type=double").get() ); assertAcked(prepareCreate("test2").get()); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/source/MetadataFetchingIT.java b/server/src/internalClusterTest/java/org/opensearch/search/source/MetadataFetchingIT.java index 758d749f0be8e..4f6dd89285bee 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/source/MetadataFetchingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/source/MetadataFetchingIT.java @@ -69,7 +69,7 @@ public void testSimple() { } public void testInnerHits() { - assertAcked(prepareCreate("test").addMapping("_doc", "nested", "type=nested")); + assertAcked(prepareCreate("test").setMapping("nested", "type=nested")); ensureGreen(); client().prepareIndex("test").setId("1").setSource("field", "value", "nested", Collections.singletonMap("title", "foo")).get(); refresh(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java index cd3921d91a3ed..07e58db836740 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java @@ -97,7 +97,7 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase { // see #3196 public void testSuggestAcrossMultipleIndices() throws IOException { - assertAcked(prepareCreate("test").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); ensureGreen(); index("test", "type1", "1", "text", "abcd"); @@ -111,7 +111,7 @@ public void testSuggestAcrossMultipleIndices() throws IOException { .text("abcd"); logger.info("--> run suggestions with one index"); searchSuggest("test", termSuggest); - assertAcked(prepareCreate("test_1").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test_1").setMapping("text", "type=text")); ensureGreen(); index("test_1", "type1", "1", "text", "ab cd"); @@ -342,7 +342,7 @@ public void testUnmappedField() throws IOException, InterruptedException, Execut } public void testSimple() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); ensureGreen(); index("test", "type1", "1", "text", "abcd"); @@ -367,7 +367,7 @@ public void testSimple() throws Exception { } public void testEmpty() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); ensureGreen(); index("test", "type1", "1", "text", "bar"); @@ -386,7 +386,7 @@ public void testEmpty() throws Exception { } public void testEmptyIndex() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); ensureGreen(); // use SuggestMode.ALWAYS, otherwise the results can vary between requests. @@ -412,7 +412,7 @@ public void testEmptyIndex() throws Exception { } public void testWithMultipleCommands() throws Exception { - assertAcked(prepareCreate("test").addMapping("typ1", "field1", "type=text", "field2", "type=text")); + assertAcked(prepareCreate("test").setMapping("field1", "type=text", "field2", "type=text")); ensureGreen(); index("test", "typ1", "1", "field1", "prefix_abcd", "field2", "prefix_efgh"); @@ -516,7 +516,7 @@ public void testSizeAndSort() throws Exception { // see #2817 public void testStopwordsOnlyPhraseSuggest() throws IOException { assertAcked( - prepareCreate("test").addMapping("typ1", "body", "type=text,analyzer=stopwd") + prepareCreate("test").setMapping("body", "type=text,analyzer=stopwd") .setSettings( Settings.builder() .put("index.analysis.analyzer.stopwd.tokenizer", "standard") diff --git a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java index c6ec91a6ab078..16b0e8829b1a7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java @@ -542,7 +542,7 @@ public void testUpdateRequestWithScriptAndShouldUpsertDoc() throws Exception { } public void testContextVariables() throws Exception { - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1")); + assertAcked(prepareCreate("test").addAlias(new Alias("alias"))); ensureGreen(); // Index some documents diff --git a/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java index a97c4a0d13f12..86a51e7367ade 100644 --- a/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java @@ -297,7 +297,7 @@ public void testExplainNoQuery() { public void testExplainFilteredAlias() { assertAcked( - prepareCreate("test").addMapping("test", "field", "type=text") + prepareCreate("test").setMapping("field", "type=text") .addAlias(new Alias("alias").filter(QueryBuilders.termQuery("field", "value1"))) ); ensureGreen(); @@ -318,7 +318,7 @@ public void testExplainWithRewriteValidateQuery() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping(MapperService.SINGLE_MAPPING_NAME, "field", "type=text,analyzer=whitespace") + .setMapping("field", "type=text,analyzer=whitespace") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1)) .get(); client().prepareIndex("test").setId("1").setSource("field", "quick lazy huge brown pidgin").get(); @@ -380,7 +380,7 @@ public void testExplainWithRewriteValidateQueryAllShards() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping(MapperService.SINGLE_MAPPING_NAME, "field", "type=text,analyzer=whitespace") + .setMapping("field", "type=text,analyzer=whitespace") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 2).put("index.number_of_routing_shards", 2)) .get(); // We are relying on specific routing behaviors for the result to be right, so @@ -484,7 +484,7 @@ public void testExplainTermsQueryWithLookup() throws Exception { client().admin() .indices() .prepareCreate("twitter") - .addMapping("_doc", "user", "type=integer", "followers", "type=integer") + .setMapping("user", "type=integer", "followers", "type=integer") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 2).put("index.number_of_routing_shards", 2)) .get(); client().prepareIndex("twitter").setId("1").setSource("followers", new int[] { 1, 2, 3 }).get(); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java index ac80b3eb6a155..cc99f63c6a844 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java @@ -141,10 +141,8 @@ public CreateIndexRequestBuilder setMapping(Map source) { /** * A specialized simplified mapping source method, takes the form of simple properties definition: * ("field1", "type=string,store=true"). - * @deprecated types are being removed */ - @Deprecated - public CreateIndexRequestBuilder addMapping(String type, String... source) { + public CreateIndexRequestBuilder setMapping(String... source) { request.simpleMapping(source); return this; } diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataMappingServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataMappingServiceTests.java index 94bf162303127..5388c0a866c5f 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataMappingServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataMappingServiceTests.java @@ -39,7 +39,6 @@ import org.opensearch.common.compress.CompressedXContent; import org.opensearch.index.Index; import org.opensearch.index.IndexService; -import org.opensearch.index.mapper.MapperService; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchSingleNodeTestCase; import org.opensearch.test.InternalSettingsPlugin; @@ -58,10 +57,7 @@ protected Collection> getPlugins() { } public void testMappingClusterStateUpdateDoesntChangeExistingIndices() throws Exception { - final IndexService indexService = createIndex( - "test", - client().admin().indices().prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME) - ); + final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").setMapping()); final CompressedXContent currentMapping = indexService.mapperService().documentMapper().mappingSource(); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); @@ -86,7 +82,7 @@ public void testMappingClusterStateUpdateDoesntChangeExistingIndices() throws Ex } public void testClusterStateIsNotChangedWithIdenticalMappings() throws Exception { - createIndex("test", client().admin().indices().prepareCreate("test").addMapping("type")); + createIndex("test", client().admin().indices().prepareCreate("test")); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); @@ -106,7 +102,7 @@ public void testClusterStateIsNotChangedWithIdenticalMappings() throws Exception } public void testMappingVersion() throws Exception { - final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").addMapping("type")); + final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test")); final long previousVersion = indexService.getMetadata().getMappingVersion(); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); @@ -122,7 +118,7 @@ public void testMappingVersion() throws Exception { } public void testMappingVersionUnchanged() throws Exception { - final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").addMapping("type")); + final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").setMapping()); final long previousVersion = indexService.getMetadata().getMappingVersion(); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); diff --git a/server/src/test/java/org/opensearch/index/fieldstats/FieldStatsProviderRefreshTests.java b/server/src/test/java/org/opensearch/index/fieldstats/FieldStatsProviderRefreshTests.java index d7cf873e133df..35c16c9954622 100644 --- a/server/src/test/java/org/opensearch/index/fieldstats/FieldStatsProviderRefreshTests.java +++ b/server/src/test/java/org/opensearch/index/fieldstats/FieldStatsProviderRefreshTests.java @@ -55,7 +55,7 @@ public void testQueryRewriteOnRefresh() throws Exception { client().admin() .indices() .prepareCreate("index") - .addMapping("type", "s", "type=text") + .setMapping("s", "type=text") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) diff --git a/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java b/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java index 80fd4edc6ac78..0349307ad20ea 100644 --- a/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java @@ -259,7 +259,7 @@ public void testRejectFieldDefinedTwice() throws IOException { } public void testMappingVersion() { - createIndex("test", client().admin().indices().prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME)); + createIndex("test", client().admin().indices().prepareCreate("test")); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); { final long previousVersion = clusterService.state().metadata().index("test").getMappingVersion(); diff --git a/server/src/test/java/org/opensearch/index/query/CommonTermsQueryParserTests.java b/server/src/test/java/org/opensearch/index/query/CommonTermsQueryParserTests.java index 1dcda74308f45..61ef0c746995a 100644 --- a/server/src/test/java/org/opensearch/index/query/CommonTermsQueryParserTests.java +++ b/server/src/test/java/org/opensearch/index/query/CommonTermsQueryParserTests.java @@ -38,8 +38,7 @@ public class CommonTermsQueryParserTests extends OpenSearchSingleNodeTestCase { public void testWhenParsedQueryIsNullNoNullPointerExceptionIsThrown() { final String index = "test-index"; - final String type = "test-type"; - client().admin().indices().prepareCreate(index).addMapping(type, "name", "type=text,analyzer=stop").execute().actionGet(); + client().admin().indices().prepareCreate(index).setMapping("name", "type=text,analyzer=stop").execute().actionGet(); ensureGreen(); CommonTermsQueryBuilder commonTermsQueryBuilder = new CommonTermsQueryBuilder("name", "the").queryName("query-name"); diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/ShardSizeTestCase.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/ShardSizeTestCase.java index bf16f70d400fc..d6981d1c34652 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/ShardSizeTestCase.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/ShardSizeTestCase.java @@ -55,7 +55,7 @@ protected int numberOfShards() { } protected void createIdx(String keyFieldMapping) { - assertAcked(prepareCreate("idx").addMapping("type", "key", keyFieldMapping)); + assertAcked(prepareCreate("idx").setMapping("key", keyFieldMapping)); } protected static String routing1; // routing key to shard 1 diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/AbstractGeoTestCase.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/AbstractGeoTestCase.java index 9243a1ccd517e..5dd8421bf5fc1 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/AbstractGeoTestCase.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/AbstractGeoTestCase.java @@ -87,8 +87,7 @@ public abstract class AbstractGeoTestCase extends OpenSearchIntegTestCase { public void setupSuiteScopeCluster() throws Exception { createIndex(UNMAPPED_IDX_NAME); assertAcked( - prepareCreate(IDX_NAME).addMapping( - "type", + prepareCreate(IDX_NAME).setMapping( SINGLE_VALUED_FIELD_NAME, "type=geo_point", MULTI_VALUED_FIELD_NAME, @@ -168,11 +167,10 @@ public void setupSuiteScopeCluster() throws Exception { ); } - assertAcked(prepareCreate(EMPTY_IDX_NAME).addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=geo_point")); + assertAcked(prepareCreate(EMPTY_IDX_NAME).setMapping(SINGLE_VALUED_FIELD_NAME, "type=geo_point")); assertAcked( - prepareCreate(DATELINE_IDX_NAME).addMapping( - "type", + prepareCreate(DATELINE_IDX_NAME).setMapping( SINGLE_VALUED_FIELD_NAME, "type=geo_point", MULTI_VALUED_FIELD_NAME, @@ -205,8 +203,7 @@ public void setupSuiteScopeCluster() throws Exception { } assertAcked( prepareCreate(HIGH_CARD_IDX_NAME).setSettings(Settings.builder().put("number_of_shards", 2)) - .addMapping( - "type", + .setMapping( SINGLE_VALUED_FIELD_NAME, "type=geo_point", MULTI_VALUED_FIELD_NAME, @@ -247,7 +244,7 @@ public void setupSuiteScopeCluster() throws Exception { client().prepareIndex(IDX_ZERO_NAME) .setSource(jsonBuilder().startObject().array(SINGLE_VALUED_FIELD_NAME, 0.0, 1.0).endObject()) ); - assertAcked(prepareCreate(IDX_ZERO_NAME).addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=geo_point")); + assertAcked(prepareCreate(IDX_ZERO_NAME).setMapping(SINGLE_VALUED_FIELD_NAME, "type=geo_point")); indexRandom(true, builders); ensureSearchable(); diff --git a/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java b/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java index 4247a2ccabff2..d6c5e4f9a6083 100644 --- a/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java +++ b/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java @@ -148,7 +148,7 @@ protected XContentBuilder createRandomMapping() throws Exception { public void testShapeFetchingPath() throws Exception { createIndex("shapes"); - client().admin().indices().prepareCreate("test").addMapping("type", "geo", "type=geo_shape").get(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape").get(); String location = "\"geo\" : {\"type\":\"polygon\", \"coordinates\":[[[-10,-10],[10,-10],[10,10],[-10,10],[-10,-10]]]}"; @@ -538,14 +538,9 @@ public void testPointQuery() throws Exception { PointBuilder pb = new PointBuilder(pt[0], pt[1]); gcb.shape(pb); if (randomBoolean()) { - client().admin().indices().prepareCreate("test").addMapping("type", "geo", "type=geo_shape").execute().actionGet(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape").execute().actionGet(); } else { - client().admin() - .indices() - .prepareCreate("test") - .addMapping("type", "geo", "type=geo_shape,tree=quadtree") - .execute() - .actionGet(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape,tree=quadtree").execute().actionGet(); } XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("geo"), null).endObject(); client().prepareIndex("test").setId("1").setSource(docSource).setRefreshPolicy(IMMEDIATE).get(); @@ -578,14 +573,9 @@ public void testContainsShapeQuery() throws Exception { } if (usePrefixTrees) { - client().admin() - .indices() - .prepareCreate("test") - .addMapping("type", "geo", "type=geo_shape,tree=quadtree") - .execute() - .actionGet(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape,tree=quadtree").execute().actionGet(); } else { - client().admin().indices().prepareCreate("test").addMapping("type", "geo", "type=geo_shape").execute().actionGet(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape").execute().actionGet(); } XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("geo"), null).endObject(); @@ -805,7 +795,7 @@ public void testQueryRandomGeoCollection() throws Exception { public void testShapeFilterWithDefinedGeoCollection() throws Exception { createIndex("shapes"); - client().admin().indices().prepareCreate("test").addMapping("type", "geo", "type=geo_shape,tree=quadtree").get(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape,tree=quadtree").get(); XContentBuilder docSource = jsonBuilder().startObject() .startObject("geo") diff --git a/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java b/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java index c2c2728a348f5..1092bc4f8f47c 100644 --- a/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java +++ b/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java @@ -100,7 +100,7 @@ public static void index01Docs(String type, String settings, OpenSearchIntegTest assertAcked( testCase.prepareCreate(INDEX_NAME) .setSettings(settings, XContentType.JSON) - .addMapping("_doc", "text", textMappings, CLASS_FIELD, "type=keyword") + .setMapping("text", textMappings, CLASS_FIELD, "type=keyword") ); String[] gb = { "0", "1" }; List indexRequestBuilderList = new ArrayList<>(); diff --git a/test/framework/src/main/java/org/opensearch/search/aggregations/metrics/AbstractNumericTestCase.java b/test/framework/src/main/java/org/opensearch/search/aggregations/metrics/AbstractNumericTestCase.java index 495eb73e3f39a..a4f6b97115bb0 100644 --- a/test/framework/src/main/java/org/opensearch/search/aggregations/metrics/AbstractNumericTestCase.java +++ b/test/framework/src/main/java/org/opensearch/search/aggregations/metrics/AbstractNumericTestCase.java @@ -76,7 +76,7 @@ public void setupSuiteScopeCluster() throws Exception { // two docs {value: 0} and {value : 2}, then building a histogram agg with interval 1 and with empty // buckets computed.. the empty bucket is the one associated with key "1". then each test will have // to check that this bucket exists with the appropriate sub aggregations. - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").execute().actionGet(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").execute().actionGet(); builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java index fe65d14bbcd0f..3fe26d92bd17f 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java @@ -322,8 +322,8 @@ protected IndexService createIndex(String index, Settings settings, String type, @Deprecated protected IndexService createIndex(String index, Settings settings, String type, String... mappings) { CreateIndexRequestBuilder createIndexRequestBuilder = client().admin().indices().prepareCreate(index).setSettings(settings); - if (type != null) { - createIndexRequestBuilder.addMapping(type, mappings); + if (mappings != null) { + createIndexRequestBuilder.setMapping(mappings); } return createIndex(index, createIndexRequestBuilder); } From 9f83deadf40441e43f6f8fefd56141fad9e6626f Mon Sep 17 00:00:00 2001 From: Suraj Singh <79435743+dreamer-89@users.noreply.github.com> Date: Thu, 17 Mar 2022 18:38:10 -0700 Subject: [PATCH 10/46] [Remove] Type from Percolate query API (#2490) * [Remove] Type from Percolator query API Signed-off-by: Suraj Singh * Address review comment Signed-off-by: Suraj Singh --- .../percolator/PercolatorQuerySearchIT.java | 14 +- .../percolator/PercolateQueryBuilder.java | 169 +++++------------- .../PercolateQueryBuilderTests.java | 60 +------ 3 files changed, 61 insertions(+), 182 deletions(-) diff --git a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java index f78b74e272ebf..8d3c37bc9b039 100644 --- a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java @@ -397,14 +397,14 @@ public void testPercolatorQueryExistingDocument() throws Exception { logger.info("percolating empty doc"); SearchResponse response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", "test", "type", "1", null, null, null)) + .setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null)) .get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("1")); logger.info("percolating doc with 1 field"); response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", "test", "type", "5", null, null, null)) + .setQuery(new PercolateQueryBuilder("query", "test", "5", null, null, null)) .addSort("id", SortOrder.ASC) .get(); assertHitCount(response, 2); @@ -413,7 +413,7 @@ public void testPercolatorQueryExistingDocument() throws Exception { logger.info("percolating doc with 2 fields"); response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", "test", "type", "6", null, null, null)) + .setQuery(new PercolateQueryBuilder("query", "test", "6", null, null, null)) .addSort("id", SortOrder.ASC) .get(); assertHitCount(response, 3); @@ -438,7 +438,7 @@ public void testPercolatorQueryExistingDocumentSourceDisabled() throws Exception logger.info("percolating empty doc with source disabled"); IllegalArgumentException e = expectThrows( IllegalArgumentException.class, - () -> { client().prepareSearch().setQuery(new PercolateQueryBuilder("query", "test", "type", "1", null, null, null)).get(); } + () -> { client().prepareSearch().setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null)).get(); } ); assertThat(e.getMessage(), containsString("source disabled")); } @@ -1193,10 +1193,10 @@ public void testPercolatorQueryViaMultiSearch() throws Exception { ) ) ) - .add(client().prepareSearch("test").setQuery(new PercolateQueryBuilder("query", "test", "type", "5", null, null, null))) + .add(client().prepareSearch("test").setQuery(new PercolateQueryBuilder("query", "test", "5", null, null, null))) .add( client().prepareSearch("test") // non existing doc, so error element - .setQuery(new PercolateQueryBuilder("query", "test", "type", "6", null, null, null)) + .setQuery(new PercolateQueryBuilder("query", "test", "6", null, null, null)) ) .get(); @@ -1228,7 +1228,7 @@ public void testPercolatorQueryViaMultiSearch() throws Exception { item = response.getResponses()[5]; assertThat(item.getResponse(), nullValue()); assertThat(item.getFailureMessage(), notNullValue()); - assertThat(item.getFailureMessage(), containsString("[test/type/6] couldn't be found")); + assertThat(item.getFailureMessage(), containsString("[test/6] couldn't be found")); } public void testDisallowExpensiveQueries() throws IOException { diff --git a/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java b/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java index 87f08e2ff50fc..b2130eca3bb02 100644 --- a/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java +++ b/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java @@ -67,7 +67,6 @@ import org.opensearch.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; -import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.xcontent.ConstructingObjectParser; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.NamedXContentRegistry; @@ -111,19 +110,11 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder { public static final String NAME = "percolate"; - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(ParseField.class); - static final String DOCUMENT_TYPE_DEPRECATION_MESSAGE = "[types removal] Types are deprecated in [percolate] queries. " - + "The [document_type] should no longer be specified."; - static final String TYPE_DEPRECATION_MESSAGE = "[types removal] Types are deprecated in [percolate] queries. " - + "The [type] of the indexed document should no longer be specified."; - static final ParseField DOCUMENT_FIELD = new ParseField("document"); static final ParseField DOCUMENTS_FIELD = new ParseField("documents"); private static final ParseField NAME_FIELD = new ParseField("name"); private static final ParseField QUERY_FIELD = new ParseField("field"); - private static final ParseField DOCUMENT_TYPE_FIELD = new ParseField("document_type"); private static final ParseField INDEXED_DOCUMENT_FIELD_INDEX = new ParseField("index"); - private static final ParseField INDEXED_DOCUMENT_FIELD_TYPE = new ParseField("type"); private static final ParseField INDEXED_DOCUMENT_FIELD_ID = new ParseField("id"); private static final ParseField INDEXED_DOCUMENT_FIELD_ROUTING = new ParseField("routing"); private static final ParseField INDEXED_DOCUMENT_FIELD_PREFERENCE = new ParseField("preference"); @@ -131,29 +122,16 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder documents; private final XContentType documentXContentType; private final String indexedDocumentIndex; - @Deprecated - private final String indexedDocumentType; private final String indexedDocumentId; private final String indexedDocumentRouting; private final String indexedDocumentPreference; private final Long indexedDocumentVersion; private final Supplier documentSupplier; - /** - * @deprecated use {@link #PercolateQueryBuilder(String, BytesReference, XContentType)} with the document content - * type to avoid autodetection. - */ - @Deprecated - public PercolateQueryBuilder(String field, String documentType, BytesReference document) { - this(field, documentType, Collections.singletonList(document), XContentHelper.xContentType(document)); - } - /** * Creates a percolator query builder instance for percolating a provided document. * @@ -162,7 +140,7 @@ public PercolateQueryBuilder(String field, String documentType, BytesReference d * @param documentXContentType The content type of the binary blob containing the document to percolate */ public PercolateQueryBuilder(String field, BytesReference document, XContentType documentXContentType) { - this(field, null, Collections.singletonList(document), documentXContentType); + this(field, Collections.singletonList(document), documentXContentType); } /** @@ -173,11 +151,6 @@ public PercolateQueryBuilder(String field, BytesReference document, XContentType * @param documentXContentType The content type of the binary blob containing the document to percolate */ public PercolateQueryBuilder(String field, List documents, XContentType documentXContentType) { - this(field, null, documents, documentXContentType); - } - - @Deprecated - public PercolateQueryBuilder(String field, String documentType, List documents, XContentType documentXContentType) { if (field == null) { throw new IllegalArgumentException("[field] is a required argument"); } @@ -185,11 +158,9 @@ public PercolateQueryBuilder(String field, String documentType, List documentSupplier) { - if (field == null) { - throw new IllegalArgumentException("[field] is a required argument"); - } - this.field = field; - this.documentType = documentType; - this.documents = Collections.emptyList(); - this.documentXContentType = null; - this.documentSupplier = documentSupplier; - indexedDocumentIndex = null; - indexedDocumentType = null; - indexedDocumentId = null; - indexedDocumentRouting = null; - indexedDocumentPreference = null; - indexedDocumentVersion = null; - } - /** * Creates a percolator query builder instance for percolating a document in a remote index. * * @param field The field that contains the percolator query * @param indexedDocumentIndex The index containing the document to percolate - * @param indexedDocumentType The type containing the document to percolate * @param indexedDocumentId The id of the document to percolate * @param indexedDocumentRouting The routing value for the document to percolate * @param indexedDocumentPreference The preference to use when fetching the document to percolate @@ -228,30 +181,6 @@ protected PercolateQueryBuilder(String field, String documentType, Supplier documentSupplier) { + if (field == null) { + throw new IllegalArgumentException("[field] is a required argument"); + } + this.field = field; + this.documents = Collections.emptyList(); + this.documentXContentType = null; + this.documentSupplier = documentSupplier; + indexedDocumentIndex = null; + indexedDocumentId = null; + indexedDocumentRouting = null; + indexedDocumentPreference = null; + indexedDocumentVersion = null; + } + /** * Read from a stream. */ @@ -286,9 +228,20 @@ public PercolateQueryBuilder( super(in); field = in.readString(); name = in.readOptionalString(); - documentType = in.readOptionalString(); + if (in.getVersion().before(Version.V_2_0_0)) { + String documentType = in.readOptionalString(); + if (documentType != null) { + throw new IllegalStateException("documentType must be null"); + } + } indexedDocumentIndex = in.readOptionalString(); - indexedDocumentType = in.readOptionalString(); + if (in.getVersion().before(Version.V_2_0_0)) { + String indexedDocumentType = in.readOptionalString(); + if (indexedDocumentType != null) { + throw new IllegalStateException("indexedDocumentType must be null"); + } + } + indexedDocumentId = in.readOptionalString(); indexedDocumentRouting = in.readOptionalString(); indexedDocumentPreference = in.readOptionalString(); @@ -322,9 +275,15 @@ protected void doWriteTo(StreamOutput out) throws IOException { } out.writeString(field); out.writeOptionalString(name); - out.writeOptionalString(documentType); + if (out.getVersion().before(Version.V_2_0_0)) { + // In 7x, typeless percolate queries are represented by null documentType values + out.writeOptionalString(null); + } out.writeOptionalString(indexedDocumentIndex); - out.writeOptionalString(indexedDocumentType); + if (out.getVersion().before(Version.V_2_0_0)) { + // In 7x, typeless percolate queries are represented by null indexedDocumentType values + out.writeOptionalString(null); + } out.writeOptionalString(indexedDocumentId); out.writeOptionalString(indexedDocumentRouting); out.writeOptionalString(indexedDocumentPreference); @@ -346,7 +305,6 @@ protected void doWriteTo(StreamOutput out) throws IOException { @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(NAME); - builder.field(DOCUMENT_TYPE_FIELD.getPreferredName(), documentType); builder.field(QUERY_FIELD.getPreferredName(), field); if (name != null) { builder.field(NAME_FIELD.getPreferredName(), name); @@ -367,13 +325,10 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep } builder.endArray(); } - if (indexedDocumentIndex != null || indexedDocumentType != null || indexedDocumentId != null) { + if (indexedDocumentIndex != null || indexedDocumentId != null) { if (indexedDocumentIndex != null) { builder.field(INDEXED_DOCUMENT_FIELD_INDEX.getPreferredName(), indexedDocumentIndex); } - if (indexedDocumentType != null) { - builder.field(INDEXED_DOCUMENT_FIELD_TYPE.getPreferredName(), indexedDocumentType); - } if (indexedDocumentId != null) { builder.field(INDEXED_DOCUMENT_FIELD_ID.getPreferredName(), indexedDocumentId); } @@ -401,23 +356,12 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep String indexDocRouting = (String) args[5]; String indexDocPreference = (String) args[6]; Long indexedDocVersion = (Long) args[7]; - String indexedDocType = (String) args[8]; - String docType = (String) args[9]; if (indexedDocId != null) { - return new PercolateQueryBuilder( - field, - docType, - indexedDocIndex, - indexedDocType, - indexedDocId, - indexDocRouting, - indexDocPreference, - indexedDocVersion - ); + return new PercolateQueryBuilder(field, indexedDocIndex, indexedDocId, indexDocRouting, indexDocPreference, indexedDocVersion); } else if (document != null) { - return new PercolateQueryBuilder(field, docType, Collections.singletonList(document), XContentType.JSON); + return new PercolateQueryBuilder(field, Collections.singletonList(document), XContentType.JSON); } else { - return new PercolateQueryBuilder(field, docType, documents, XContentType.JSON); + return new PercolateQueryBuilder(field, documents, XContentType.JSON); } }); static { @@ -429,8 +373,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep PARSER.declareString(optionalConstructorArg(), INDEXED_DOCUMENT_FIELD_ROUTING); PARSER.declareString(optionalConstructorArg(), INDEXED_DOCUMENT_FIELD_PREFERENCE); PARSER.declareLong(optionalConstructorArg(), INDEXED_DOCUMENT_FIELD_VERSION); - PARSER.declareStringOrNull(optionalConstructorArg(), INDEXED_DOCUMENT_FIELD_TYPE); - PARSER.declareStringOrNull(optionalConstructorArg(), DOCUMENT_TYPE_FIELD); PARSER.declareString(PercolateQueryBuilder::setName, NAME_FIELD); PARSER.declareString(PercolateQueryBuilder::queryName, AbstractQueryBuilder.NAME_FIELD); PARSER.declareFloat(PercolateQueryBuilder::boost, BOOST_FIELD); @@ -461,10 +403,8 @@ public static PercolateQueryBuilder fromXContent(XContentParser parser) throws I @Override protected boolean doEquals(PercolateQueryBuilder other) { return Objects.equals(field, other.field) - && Objects.equals(documentType, other.documentType) && Objects.equals(documents, other.documents) && Objects.equals(indexedDocumentIndex, other.indexedDocumentIndex) - && Objects.equals(indexedDocumentType, other.indexedDocumentType) && Objects.equals(documentSupplier, other.documentSupplier) && Objects.equals(indexedDocumentId, other.indexedDocumentId); @@ -472,7 +412,7 @@ protected boolean doEquals(PercolateQueryBuilder other) { @Override protected int doHashCode() { - return Objects.hash(field, documentType, documents, indexedDocumentIndex, indexedDocumentType, indexedDocumentId, documentSupplier); + return Objects.hash(field, documents, indexedDocumentIndex, indexedDocumentId, documentSupplier); } @Override @@ -491,7 +431,6 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) { } else { PercolateQueryBuilder rewritten = new PercolateQueryBuilder( field, - documentType, Collections.singletonList(source), XContentHelper.xContentType(source) ); @@ -513,20 +452,14 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) { client.get(getRequest, ActionListener.wrap(getResponse -> { if (getResponse.isExists() == false) { throw new ResourceNotFoundException( - "indexed document [{}{}/{}] couldn't be found", + "indexed document [{}/{}] couldn't be found", indexedDocumentIndex, - indexedDocumentType == null ? "" : "/" + indexedDocumentType, indexedDocumentId ); } if (getResponse.isSourceEmpty()) { throw new IllegalArgumentException( - "indexed document [" - + indexedDocumentIndex - + (indexedDocumentType == null ? "" : "/" + indexedDocumentType) - + "/" - + indexedDocumentId - + "] source disabled" + "indexed document [" + indexedDocumentIndex + "/" + indexedDocumentId + "] source disabled" ); } documentSupplier.set(getResponse.getSourceAsBytesRef()); @@ -534,7 +467,7 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) { }, listener::onFailure)); }); - PercolateQueryBuilder rewritten = new PercolateQueryBuilder(field, documentType, documentSupplier::get); + PercolateQueryBuilder rewritten = new PercolateQueryBuilder(field, documentSupplier::get); if (name != null) { rewritten.setName(name); } @@ -576,14 +509,6 @@ protected Query doToQuery(QueryShardContext context) throws IOException { final DocumentMapper docMapper; final MapperService mapperService = context.getMapperService(); String type = mapperService.documentMapper().type(); - if (documentType != null) { - deprecationLogger.deprecate("percolate_with_document_type", DOCUMENT_TYPE_DEPRECATION_MESSAGE); - if (documentType.equals(type) == false) { - throw new IllegalArgumentException( - "specified document_type [" + documentType + "] is not equal to the actual type [" + type + "]" - ); - } - } docMapper = mapperService.documentMapper(); for (BytesReference document : documents) { docs.add(docMapper.parse(new SourceToParse(context.index().getName(), "_temp_id", document, documentXContentType))); @@ -631,10 +556,6 @@ public String getField() { return field; } - public String getDocumentType() { - return documentType; - } - public List getDocuments() { return documents; } diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java index 44d8d64086091..87aa28a3346bc 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java @@ -148,16 +148,14 @@ private PercolateQueryBuilder doCreateTestQueryBuilder(boolean indexedDocument) indexedDocumentVersion = (long) randomIntBetween(0, Integer.MAX_VALUE); queryBuilder = new PercolateQueryBuilder( queryField, - null, indexedDocumentIndex, - null, indexedDocumentId, indexedDocumentRouting, indexedDocumentPreference, indexedDocumentVersion ); } else { - queryBuilder = new PercolateQueryBuilder(queryField, null, documentSource, XContentType.JSON); + queryBuilder = new PercolateQueryBuilder(queryField, documentSource, XContentType.JSON); } if (randomBoolean()) { queryBuilder.setName(randomAlphaOfLength(4)); @@ -217,7 +215,6 @@ protected GetResponse executeGet(GetRequest getRequest) { protected void doAssertLuceneQuery(PercolateQueryBuilder queryBuilder, Query query, QueryShardContext context) throws IOException { assertThat(query, Matchers.instanceOf(PercolateQuery.class)); PercolateQuery percolateQuery = (PercolateQuery) query; - assertNull(queryBuilder.getDocumentType()); assertThat(percolateQuery.getDocuments(), Matchers.equalTo(documentSource)); } @@ -227,12 +224,7 @@ public void testMustRewrite() throws IOException { IllegalStateException e = expectThrows(IllegalStateException.class, () -> pqb.toQuery(createShardContext())); assertThat(e.getMessage(), equalTo("query builder must be rewritten first")); QueryBuilder rewrite = rewriteAndFetch(pqb, createShardContext()); - PercolateQueryBuilder geoShapeQueryBuilder = new PercolateQueryBuilder( - pqb.getField(), - pqb.getDocumentType(), - documentSource, - XContentType.JSON - ); + PercolateQueryBuilder geoShapeQueryBuilder = new PercolateQueryBuilder(pqb.getField(), documentSource, XContentType.JSON); assertEquals(geoShapeQueryBuilder, rewrite); } @@ -259,25 +251,19 @@ public void testRequiredParameters() { ); assertThat(e.getMessage(), equalTo("[field] is a required argument")); - e = expectThrows(IllegalArgumentException.class, () -> new PercolateQueryBuilder("_field", "_document_type", null, null)); - assertThat(e.getMessage(), equalTo("[document] is a required argument")); - e = expectThrows( IllegalArgumentException.class, - () -> { new PercolateQueryBuilder(null, null, "_index", "_type", "_id", null, null, null); } + () -> new PercolateQueryBuilder("_field", (List) null, XContentType.JSON) ); + assertThat(e.getMessage(), equalTo("[document] is a required argument")); + + e = expectThrows(IllegalArgumentException.class, () -> { new PercolateQueryBuilder(null, "_index", "_id", null, null, null); }); assertThat(e.getMessage(), equalTo("[field] is a required argument")); - e = expectThrows( - IllegalArgumentException.class, - () -> { new PercolateQueryBuilder("_field", "_document_type", null, "_type", "_id", null, null, null); } - ); + e = expectThrows(IllegalArgumentException.class, () -> { new PercolateQueryBuilder("_field", null, "_id", null, null, null); }); assertThat(e.getMessage(), equalTo("[index] is a required argument")); - e = expectThrows( - IllegalArgumentException.class, - () -> { new PercolateQueryBuilder("_field", "_document_type", "_index", "_type", null, null, null, null); } - ); + e = expectThrows(IllegalArgumentException.class, () -> { new PercolateQueryBuilder("_field", "_index", null, null, null, null); }); assertThat(e.getMessage(), equalTo("[id] is a required argument")); } @@ -287,15 +273,6 @@ public void testFromJsonNoDocumentType() throws IOException { queryBuilder.toQuery(queryShardContext); } - public void testFromJsonWithDocumentType() throws IOException { - QueryShardContext queryShardContext = createShardContext(); - QueryBuilder queryBuilder = parseQuery( - "{\"percolate\" : { \"document\": {}, \"document_type\":\"" + docType + "\", \"field\":\"" + queryField + "\"}}" - ); - queryBuilder.toQuery(queryShardContext); - assertWarnings(PercolateQueryBuilder.DOCUMENT_TYPE_DEPRECATION_MESSAGE); - } - public void testFromJsonNoType() throws IOException { indexedDocumentIndex = randomAlphaOfLength(4); indexedDocumentId = randomAlphaOfLength(4); @@ -315,25 +292,6 @@ public void testFromJsonNoType() throws IOException { rewriteAndFetch(queryBuilder, queryShardContext).toQuery(queryShardContext); } - public void testFromJsonWithType() throws IOException { - indexedDocumentIndex = randomAlphaOfLength(4); - indexedDocumentId = randomAlphaOfLength(4); - indexedDocumentVersion = Versions.MATCH_ANY; - documentSource = Collections.singletonList(randomSource(new HashSet<>())); - - QueryShardContext queryShardContext = createShardContext(); - QueryBuilder queryBuilder = parseQuery( - "{\"percolate\" : { \"index\": \"" - + indexedDocumentIndex - + "\", \"type\": \"_doc\", \"id\": \"" - + indexedDocumentId - + "\", \"field\":\"" - + queryField - + "\"}}" - ); - rewriteAndFetch(queryBuilder, queryShardContext).toQuery(queryShardContext); - } - public void testBothDocumentAndDocumentsSpecified() { IllegalArgumentException e = expectThrows( IllegalArgumentException.class, @@ -426,7 +384,7 @@ public void testSettingNameWhileRewritingWhenDocumentSupplierAndSourceNotNull() Supplier supplier = () -> new BytesArray("{\"test\": \"test\"}"); String testName = "name1"; QueryShardContext shardContext = createShardContext(); - PercolateQueryBuilder percolateQueryBuilder = new PercolateQueryBuilder(queryField, null, supplier); + PercolateQueryBuilder percolateQueryBuilder = new PercolateQueryBuilder(queryField, supplier); percolateQueryBuilder.setName(testName); QueryBuilder rewrittenQueryBuilder = percolateQueryBuilder.doRewrite(shardContext); From e0ebf409648e69f9b4bf9c7c83bdea783c066d67 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Fri, 18 Mar 2022 11:28:48 -0500 Subject: [PATCH 11/46] [Upgrade] ICU4j from 68.2 to 70.1 (#2504) Upgrade ICU4j to 70.1 to be consistent with Lucene 9.1 dependency. Signed-off-by: Nicholas Walter Knize --- buildSrc/version.properties | 2 +- plugins/analysis-icu/licenses/icu4j-68.2.jar.sha1 | 1 - plugins/analysis-icu/licenses/icu4j-70.1.jar.sha1 | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 plugins/analysis-icu/licenses/icu4j-68.2.jar.sha1 create mode 100644 plugins/analysis-icu/licenses/icu4j-70.1.jar.sha1 diff --git a/buildSrc/version.properties b/buildSrc/version.properties index 5202b60cbdc20..1486ce4b6e44c 100644 --- a/buildSrc/version.properties +++ b/buildSrc/version.properties @@ -11,7 +11,7 @@ spatial4j = 0.7 jts = 1.15.0 jackson = 2.12.6 snakeyaml = 1.26 -icu4j = 68.2 +icu4j = 70.1 supercsv = 2.4.0 log4j = 2.17.1 slf4j = 1.6.2 diff --git a/plugins/analysis-icu/licenses/icu4j-68.2.jar.sha1 b/plugins/analysis-icu/licenses/icu4j-68.2.jar.sha1 deleted file mode 100644 index fcb3d79075099..0000000000000 --- a/plugins/analysis-icu/licenses/icu4j-68.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -76893e6000401ace133a65262254be0ebe556d46 \ No newline at end of file diff --git a/plugins/analysis-icu/licenses/icu4j-70.1.jar.sha1 b/plugins/analysis-icu/licenses/icu4j-70.1.jar.sha1 new file mode 100644 index 0000000000000..6fad735235417 --- /dev/null +++ b/plugins/analysis-icu/licenses/icu4j-70.1.jar.sha1 @@ -0,0 +1 @@ +dfa3a1fbc55bf5db8c6e79fc0935ac7ab1202950 \ No newline at end of file From 9c4d7d92b316637493142ae2b4460470dbf0c24b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Mar 2022 12:18:07 -0700 Subject: [PATCH 12/46] Bump json-schema-validator from 1.0.36 to 1.0.67 in /buildSrc (#2454) Bumps [json-schema-validator](https://github.com/networknt/json-schema-validator) from 1.0.36 to 1.0.67. - [Release notes](https://github.com/networknt/json-schema-validator/releases) - [Changelog](https://github.com/networknt/json-schema-validator/blob/master/CHANGELOG.md) - [Commits](https://github.com/networknt/json-schema-validator/compare/1.0.36...1.0.67) --- updated-dependencies: - dependency-name: com.networknt:json-schema-validator dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- buildSrc/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index ff79cc5df0df0..5925d1a4d8164 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -115,7 +115,7 @@ dependencies { api 'de.thetaphi:forbiddenapis:3.2' api 'com.avast.gradle:gradle-docker-compose-plugin:0.14.12' api 'org.apache.maven:maven-model:3.6.2' - api 'com.networknt:json-schema-validator:1.0.36' + api 'com.networknt:json-schema-validator:1.0.67' api "com.fasterxml.jackson.core:jackson-databind:${props.getProperty('jackson')}" testFixturesApi "junit:junit:${props.getProperty('junit')}" From 19eadb46ba80df1750402a3faad55114823087f2 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Fri, 18 Mar 2022 14:55:49 -0700 Subject: [PATCH 13/46] Deprecate setting 'cluster.initial_master_nodes' and introduce the alternative setting 'cluster.initial_cluster_manager_nodes' (#2463) * Deprecate setting cluster.initial_master_nodes, and add setting cluster.initial_cluster_manager_nodes Signed-off-by: Tianli Feng --- .../gradle/test/ClusterFormationTasks.groovy | 3 +- .../testclusters/OpenSearchCluster.java | 7 +- distribution/docker/docker-compose.yml | 4 +- distribution/src/config/opensearch.yml | 4 +- qa/remote-clusters/docker-compose.yml | 4 +- .../discovery/ClusterDisruptionIT.java | 2 +- .../gateway/RecoveryFromGatewayIT.java | 4 +- .../opensearch/bootstrap/BootstrapChecks.java | 9 +- .../coordination/ClusterBootstrapService.java | 23 +++-- .../ClusterFormationFailureHelper.java | 8 +- .../common/settings/ClusterSettings.java | 3 +- .../bootstrap/BootstrapChecksTests.java | 4 +- ...erBootstrapServiceRenamedSettingTests.java | 84 +++++++++++++++++++ .../ClusterBootstrapServiceTests.java | 68 ++++++++++----- .../ClusterFormationFailureHelperTests.java | 10 +-- .../indices/IndicesServiceCloseTests.java | 4 +- .../snapshots/SnapshotResiliencyTests.java | 4 +- .../AbstractCoordinatorTestCase.java | 4 +- .../opensearch/test/InternalTestCluster.java | 17 ++-- .../test/OpenSearchSingleNodeTestCase.java | 4 +- 20 files changed, 202 insertions(+), 68 deletions(-) create mode 100644 server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy index c3dd2526de385..0c88c33921309 100644 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy @@ -153,7 +153,8 @@ class ClusterFormationTasks { } boolean supportsInitialMasterNodes = hasBwcNodes == false || config.bwcVersion.onOrAfter("7.0.0") if (esConfig['discovery.type'] == null && config.getAutoSetInitialMasterNodes() && supportsInitialMasterNodes) { - esConfig['cluster.initial_master_nodes'] = nodes.stream().map({ n -> + // To promote inclusive language, the old setting name is deprecated in 2.0.0 + esConfig[node.nodeVersion.onOrAfter("2.0.0") ? 'cluster.initial_cluster_manager_nodes' : 'cluster.initial_master_nodes'] = nodes.stream().map({ n -> if (n.config.settings['node.name'] == null) { return "node-" + n.nodeNum } else { diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java index a94ebacd460a5..ef52adab6377a 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java @@ -361,7 +361,12 @@ private void commonNodeConfig(OpenSearchNode node, String nodeNames, OpenSearchN .collect(Collectors.toList()) .forEach(node.defaultConfig::remove); if (nodeNames != null && node.settings.getOrDefault("discovery.type", "anything").equals("single-node") == false) { - node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]"); + // To promote inclusive language, the old setting name is deprecated n 2.0.0 + if (node.getVersion().onOrAfter("2.0.0")) { + node.defaultConfig.put("cluster.initial_cluster_manager_nodes", "[" + nodeNames + "]"); + } else { + node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]"); + } } node.defaultConfig.put("discovery.seed_providers", "file"); node.defaultConfig.put("discovery.seed_hosts", "[]"); diff --git a/distribution/docker/docker-compose.yml b/distribution/docker/docker-compose.yml index f648a514e1db4..5ed2b159ffe2b 100644 --- a/distribution/docker/docker-compose.yml +++ b/distribution/docker/docker-compose.yml @@ -5,7 +5,7 @@ services: image: opensearch:test environment: - node.name=opensearch-1 - - cluster.initial_master_nodes=opensearch-1,opensearch-2 + - cluster.initial_cluster_manager_nodes=opensearch-1,opensearch-2 - discovery.seed_hosts=opensearch-2:9300 - cluster.name=opensearch - bootstrap.memory_lock=true @@ -29,7 +29,7 @@ services: image: opensearch:test environment: - node.name=opensearch-2 - - cluster.initial_master_nodes=opensearch-1,opensearch-2 + - cluster.initial_cluster_manager_nodes=opensearch-1,opensearch-2 - discovery.seed_hosts=opensearch-1:9300 - cluster.name=opensearch - bootstrap.memory_lock=true diff --git a/distribution/src/config/opensearch.yml b/distribution/src/config/opensearch.yml index accc920e6aa17..2188fbe600cbf 100644 --- a/distribution/src/config/opensearch.yml +++ b/distribution/src/config/opensearch.yml @@ -67,9 +67,9 @@ ${path.logs} # #discovery.seed_hosts: ["host1", "host2"] # -# Bootstrap the cluster using an initial set of master-eligible nodes: +# Bootstrap the cluster using an initial set of cluster-manager-eligible nodes: # -#cluster.initial_master_nodes: ["node-1", "node-2"] +#cluster.initial_cluster_manager_nodes: ["node-1", "node-2"] # # For more information, consult the discovery and cluster formation module documentation. # diff --git a/qa/remote-clusters/docker-compose.yml b/qa/remote-clusters/docker-compose.yml index 74aaa9e2a5271..cf6aefcf5c1a3 100644 --- a/qa/remote-clusters/docker-compose.yml +++ b/qa/remote-clusters/docker-compose.yml @@ -5,7 +5,7 @@ services: image: opensearch:test environment: - node.name=opensearch-1 - - cluster.initial_master_nodes=opensearch-1 + - cluster.initial_cluster_manager_nodes=opensearch-1 - cluster.name=opensearch-1 - bootstrap.memory_lock=true - network.publish_host=127.0.0.1 @@ -39,7 +39,7 @@ services: image: opensearch:test environment: - node.name=opensearch-2 - - cluster.initial_master_nodes=opensearch-2 + - cluster.initial_cluster_manager_nodes=opensearch-2 - cluster.name=opensearch-2 - bootstrap.memory_lock=true - network.publish_host=127.0.0.1 diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java index 53002a38c3a9d..ceec1315a9d59 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java @@ -422,7 +422,7 @@ public boolean clearData(String nodeName) { @Override public Settings onNodeStopped(String nodeName) { return Settings.builder() - .put(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), nodeName) + .put(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), nodeName) /* * the data node might join while the master is still not fully established as master just yet and bypasses the join * validation that is done before adding the node to the cluster. Only the join validation when handling the publish diff --git a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java index 3c5f2828ff94f..d76e21ea712f3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java @@ -83,7 +83,7 @@ import java.util.Set; import java.util.stream.IntStream; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder; @@ -383,7 +383,7 @@ public void testTwoNodeFirstNodeCleared() throws Exception { public Settings onNodeStopped(String nodeName) { return Settings.builder() .put(RECOVER_AFTER_NODES_SETTING.getKey(), 2) - .putList(INITIAL_MASTER_NODES_SETTING.getKey()) // disable bootstrapping + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey()) // disable bootstrapping .build(); } diff --git a/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java b/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java index e2072cae84733..79019a73c69e3 100644 --- a/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java +++ b/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java @@ -64,6 +64,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; @@ -773,10 +774,12 @@ public BootstrapCheckResult check(BootstrapContext context) { return BootstrapCheckResult.failure( String.format( Locale.ROOT, - "the default discovery settings are unsuitable for production use; at least one of [%s] must be configured", - Stream.of(DISCOVERY_SEED_HOSTS_SETTING, DISCOVERY_SEED_PROVIDERS_SETTING, INITIAL_MASTER_NODES_SETTING) + // TODO: Remove ' / %s' from the error message after removing MASTER_ROLE, and update unit test. + "the default discovery settings are unsuitable for production use; at least one of [%s / %s] must be configured", + Stream.of(DISCOVERY_SEED_HOSTS_SETTING, DISCOVERY_SEED_PROVIDERS_SETTING, INITIAL_CLUSTER_MANAGER_NODES_SETTING) .map(Setting::getKey) - .collect(Collectors.joining(", ")) + .collect(Collectors.joining(", ")), + INITIAL_MASTER_NODES_SETTING.getKey() ) ); } diff --git a/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java b/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java index 7f239aff2d5a8..ce34a21e4adb6 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java @@ -75,6 +75,15 @@ public class ClusterBootstrapService { "cluster.initial_master_nodes", emptyList(), Function.identity(), + Property.NodeScope, + Property.Deprecated + ); + // The setting below is going to replace the above. + // To keep backwards compatibility, the old usage is remained, and it's also used as the fallback for the new usage. + public static final Setting> INITIAL_CLUSTER_MANAGER_NODES_SETTING = Setting.listSetting( + "cluster.initial_cluster_manager_nodes", + INITIAL_MASTER_NODES_SETTING, + Function.identity(), Property.NodeScope ); @@ -105,10 +114,14 @@ public ClusterBootstrapService( Consumer votingConfigurationConsumer ) { if (DiscoveryModule.isSingleNodeDiscovery(settings)) { - if (INITIAL_MASTER_NODES_SETTING.exists(settings)) { + if (INITIAL_CLUSTER_MANAGER_NODES_SETTING.existsOrFallbackExists(settings)) { + // TODO: Remove variable 'initialClusterManagerSettingName' after removing MASTER_ROLE. + String initialClusterManagerSettingName = INITIAL_CLUSTER_MANAGER_NODES_SETTING.exists(settings) + ? INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + : INITIAL_MASTER_NODES_SETTING.getKey(); throw new IllegalArgumentException( "setting [" - + INITIAL_MASTER_NODES_SETTING.getKey() + + initialClusterManagerSettingName + "] is not allowed when [" + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey() + "] is set to [" @@ -128,11 +141,11 @@ public ClusterBootstrapService( bootstrapRequirements = Collections.singleton(Node.NODE_NAME_SETTING.get(settings)); unconfiguredBootstrapTimeout = null; } else { - final List initialMasterNodes = INITIAL_MASTER_NODES_SETTING.get(settings); + final List initialMasterNodes = INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings); bootstrapRequirements = unmodifiableSet(new LinkedHashSet<>(initialMasterNodes)); if (bootstrapRequirements.size() != initialMasterNodes.size()) { throw new IllegalArgumentException( - "setting [" + INITIAL_MASTER_NODES_SETTING.getKey() + "] contains duplicates: " + initialMasterNodes + "setting [" + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + "] contains duplicates: " + initialMasterNodes ); } unconfiguredBootstrapTimeout = discoveryIsConfigured(settings) ? null : UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING.get(settings); @@ -150,7 +163,7 @@ public static boolean discoveryIsConfigured(Settings settings) { LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING, DISCOVERY_SEED_HOSTS_SETTING, LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING, - INITIAL_MASTER_NODES_SETTING + INITIAL_CLUSTER_MANAGER_NODES_SETTING ).anyMatch(s -> s.exists(settings)); } diff --git a/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java b/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java index 394a33eb3cac3..c36a2983a011a 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.monitor.StatusInfo.Status.UNHEALTHY; public class ClusterFormationFailureHelper { @@ -198,13 +198,13 @@ String getDescription() { if (clusterState.getLastAcceptedConfiguration().isEmpty()) { final String bootstrappingDescription; - if (INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY).equals(INITIAL_MASTER_NODES_SETTING.get(settings))) { - bootstrappingDescription = "[" + INITIAL_MASTER_NODES_SETTING.getKey() + "] is empty on this node"; + if (INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY).equals(INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings))) { + bootstrappingDescription = "[" + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + "] is empty on this node"; } else { bootstrappingDescription = String.format( Locale.ROOT, "this node must discover master-eligible nodes %s to bootstrap a cluster", - INITIAL_MASTER_NODES_SETTING.get(settings) + INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings) ); } diff --git a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java index 308ab13a8a785..247898843296f 100644 --- a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java @@ -539,7 +539,8 @@ public void apply(Settings value, Settings current, Settings previous) { LeaderChecker.LEADER_CHECK_RETRY_COUNT_SETTING, Reconfigurator.CLUSTER_AUTO_SHRINK_VOTING_CONFIGURATION, TransportAddVotingConfigExclusionsAction.MAXIMUM_VOTING_CONFIG_EXCLUSIONS_SETTING, - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING, + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING, // deprecated + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING, ClusterBootstrapService.UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING, LagDetector.CLUSTER_FOLLOWER_LAG_TIMEOUT_SETTING, HandshakingTransportAddressConnector.PROBE_CONNECT_TIMEOUT_SETTING, diff --git a/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java b/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java index 04cc138061539..d941c624509da 100644 --- a/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java +++ b/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java @@ -802,7 +802,7 @@ public void testDiscoveryConfiguredCheck() throws NodeValidationException { hasToString( containsString( "the default discovery settings are unsuitable for production use; at least one " - + "of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured" + + "of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_cluster_manager_nodes / cluster.initial_master_nodes] must be configured" ) ) ); @@ -815,7 +815,7 @@ public void testDiscoveryConfiguredCheck() throws NodeValidationException { BootstrapChecks.check(context, true, checks); }; - ensureChecksPass.accept(Settings.builder().putList(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey())); + ensureChecksPass.accept(Settings.builder().putList(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey())); ensureChecksPass.accept(Settings.builder().putList(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey())); ensureChecksPass.accept(Settings.builder().putList(SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey())); } diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java new file mode 100644 index 0000000000000..09fb6a5ea256d --- /dev/null +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java @@ -0,0 +1,84 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.cluster.coordination; + +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Setting; +import org.opensearch.common.settings.Settings; +import org.opensearch.test.OpenSearchTestCase; + +import java.util.Arrays; +import java.util.Set; + +/** + * A unit test to validate the former name of the setting 'cluster.initial_cluster_manager_nodes' still take effect, + * after it is deprecated, so that the backwards compatibility is maintained. + * The test can be removed along with removing support of the deprecated setting. + */ +public class ClusterBootstrapServiceRenamedSettingTests extends OpenSearchTestCase { + /** + * Validate the both settings are known and supported. + */ + public void testReindexSettingsExist() { + Set> settings = ClusterSettings.BUILT_IN_CLUSTER_SETTINGS; + assertTrue( + "Both 'cluster.initial_cluster_manager_nodes' and its predecessor should be supported built-in settings.", + settings.containsAll( + Arrays.asList( + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING, + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING + ) + ) + ); + } + + /** + * Validate the default value of the both settings is the same. + */ + public void testSettingFallback() { + assertEquals( + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY), + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY) + ); + } + + /** + * Validate the new setting can be configured correctly, and it doesn't impact the old setting. + */ + public void testSettingGetValue() { + Settings settings = Settings.builder().put("cluster.initial_cluster_manager_nodes", "node-a").build(); + assertEquals(Arrays.asList("node-a"), ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings)); + assertEquals( + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getDefault(Settings.EMPTY), + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(settings) + ); + } + + /** + * Validate the value of the old setting will be applied to the new setting, if the new setting is not configured. + */ + public void testSettingGetValueWithFallback() { + Settings settings = Settings.builder().put("cluster.initial_master_nodes", "node-a").build(); + assertEquals(Arrays.asList("node-a"), ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings)); + assertSettingDeprecationsAndWarnings(new Setting[] { ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING }); + } + + /** + * Validate the value of the old setting will be ignored, if the new setting is configured. + */ + public void testSettingGetValueWhenBothAreConfigured() { + Settings settings = Settings.builder() + .put("cluster.initial_cluster_manager_nodes", "node-a") + .put("cluster.initial_master_nodes", "node-a, node-b") + .build(); + assertEquals(Arrays.asList("node-a"), ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings)); + assertEquals(Arrays.asList("node-a", "node-b"), ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(settings)); + assertSettingDeprecationsAndWarnings(new Setting[] { ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING }); + } +} diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java index a2fe39ef4531e..d8007933c2559 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java @@ -57,6 +57,7 @@ import static java.util.Collections.emptySet; import static java.util.Collections.singletonList; import static org.opensearch.cluster.coordination.ClusterBootstrapService.BOOTSTRAP_PLACEHOLDER_PREFIX; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; import static org.opensearch.cluster.coordination.ClusterBootstrapService.UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING; import static org.opensearch.common.settings.Settings.builder; @@ -166,7 +167,7 @@ public void testDoesNothingByDefaultIfSeedHostsConfigured() { } public void testDoesNothingByDefaultIfMasterNodesConfigured() { - testDoesNothingWithSettings(builder().putList(INITIAL_MASTER_NODES_SETTING.getKey())); + testDoesNothingWithSettings(builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey())); } public void testDoesNothingByDefaultOnMasterIneligibleNodes() { @@ -197,7 +198,7 @@ private void testDoesNothingWithSettings(Settings.Builder builder) { public void testThrowsExceptionOnDuplicates() { final IllegalArgumentException illegalArgumentException = expectThrows(IllegalArgumentException.class, () -> { new ClusterBootstrapService( - builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), "duplicate-requirement", "duplicate-requirement").build(), + builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), "duplicate-requirement", "duplicate-requirement").build(), transportService, Collections::emptyList, () -> false, @@ -205,7 +206,7 @@ public void testThrowsExceptionOnDuplicates() { ); }); - assertThat(illegalArgumentException.getMessage(), containsString(INITIAL_MASTER_NODES_SETTING.getKey())); + assertThat(illegalArgumentException.getMessage(), containsString(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey())); assertThat(illegalArgumentException.getMessage(), containsString("duplicate-requirement")); } @@ -214,7 +215,7 @@ public void testBootstrapsOnDiscoveryOfAllRequiredNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(otherNode1, otherNode2).collect(Collectors.toList()), @@ -242,7 +243,7 @@ public void testBootstrapsOnDiscoveryOfTwoOfThreeRequiredNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> singletonList(otherNode1), @@ -276,7 +277,7 @@ public void testBootstrapsOnDiscoveryOfThreeOfFiveRequiredNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() .putList( - INITIAL_MASTER_NODES_SETTING.getKey(), + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName(), @@ -325,7 +326,7 @@ public void testBootstrapsOnDiscoveryOfThreeOfFiveRequiredNodes() { public void testDoesNotBootstrapIfNoNodesDiscovered() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, Collections::emptyList, @@ -342,7 +343,7 @@ public void testDoesNotBootstrapIfTwoOfFiveNodesDiscovered() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() .putList( - INITIAL_MASTER_NODES_SETTING.getKey(), + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName(), @@ -365,7 +366,7 @@ public void testDoesNotBootstrapIfThreeOfSixNodesDiscovered() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() .putList( - INITIAL_MASTER_NODES_SETTING.getKey(), + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName(), @@ -388,7 +389,7 @@ public void testDoesNotBootstrapIfThreeOfSixNodesDiscovered() { public void testDoesNotBootstrapIfAlreadyBootstrapped() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(otherNode1, otherNode2).collect(Collectors.toList()), @@ -412,7 +413,7 @@ public void testDoesNotBootstrapsOnNonMasterNode() { ); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(localNode, otherNode1, otherNode2).collect(Collectors.toList()), @@ -424,9 +425,9 @@ public void testDoesNotBootstrapsOnNonMasterNode() { deterministicTaskQueue.runAllTasks(); } - public void testDoesNotBootstrapsIfLocalNodeNotInInitialMasterNodes() { + public void testDoesNotBootstrapsIfLocalNodeNotInInitialClusterManagerNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), otherNode1.getName(), otherNode2.getName()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), otherNode1.getName(), otherNode2.getName()).build(), transportService, () -> Stream.of(localNode, otherNode1, otherNode2).collect(Collectors.toList()), () -> false, @@ -439,7 +440,7 @@ public void testDoesNotBootstrapsIfLocalNodeNotInInitialMasterNodes() { public void testDoesNotBootstrapsIfNotConfigured() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey()).build(), transportService, () -> Stream.of(localNode, otherNode1, otherNode2).collect(Collectors.toList()), () -> false, @@ -455,7 +456,7 @@ public void testRetriesBootstrappingOnException() { final AtomicLong bootstrappingAttempts = new AtomicLong(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(otherNode1, otherNode2).collect(Collectors.toList()), @@ -480,7 +481,7 @@ public void testCancelsBootstrapIfRequirementMatchesMultipleNodes() { Stream.of(otherNode1, otherNode2).collect(Collectors.toList()) ); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getAddress().getAddress()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getAddress().getAddress()).build(), transportService, discoveredNodes::get, () -> false, @@ -502,7 +503,7 @@ public void testCancelsBootstrapIfNodeMatchesMultipleRequirements() { ); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), otherNode1.getAddress().toString(), otherNode1.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), otherNode1.getAddress().toString(), otherNode1.getName()) .build(), transportService, discoveredNodes::get, @@ -542,7 +543,7 @@ public void testCancelsBootstrapIfNodeMatchesMultipleRequirements() { public void testMatchesOnNodeName() { final AtomicBoolean bootstrapped = new AtomicBoolean(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName()).build(), transportService, Collections::emptyList, () -> false, @@ -558,7 +559,7 @@ public void testMatchesOnNodeName() { public void testMatchesOnNodeAddress() { final AtomicBoolean bootstrapped = new AtomicBoolean(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getAddress().toString()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getAddress().toString()).build(), transportService, Collections::emptyList, () -> false, @@ -574,7 +575,7 @@ public void testMatchesOnNodeAddress() { public void testMatchesOnNodeHostAddress() { final AtomicBoolean bootstrapped = new AtomicBoolean(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getAddress().getAddress()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getAddress().getAddress()).build(), transportService, Collections::emptyList, () -> false, @@ -589,7 +590,7 @@ public void testMatchesOnNodeHostAddress() { public void testDoesNotJustMatchEverything() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), randomAlphaOfLength(10)).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), randomAlphaOfLength(10)).build(), transportService, Collections::emptyList, () -> false, @@ -606,7 +607,7 @@ public void testDoesNotIncludeExtraNodes() { final AtomicBoolean bootstrapped = new AtomicBoolean(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(otherNode1, otherNode2, extraNode).collect(Collectors.toList()), @@ -670,6 +671,29 @@ public void testFailBootstrapWithBothSingleNodeDiscoveryAndInitialMasterNodes() ); } + /** + * Validate the correct setting name of cluster.initial_cluster_manager_nodes is shown in the exception, + * when discovery type is single-node. + */ + public void testFailBootstrapWithBothSingleNodeDiscoveryAndInitialClusterManagerNodes() { + final Settings.Builder settings = Settings.builder() + .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE) + .put(NODE_NAME_SETTING.getKey(), localNode.getName()) + .put(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), "test"); + + assertThat( + expectThrows( + IllegalArgumentException.class, + () -> new ClusterBootstrapService(settings.build(), transportService, () -> emptyList(), () -> false, vc -> fail()) + ).getMessage(), + containsString( + "setting [" + + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + + "] is not allowed when [discovery.type] is set to [single-node]" + ) + ); + } + public void testFailBootstrapNonMasterEligibleNodeWithSingleNodeDiscovery() { final Settings.Builder settings = Settings.builder() .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE) diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java index c53c6fb8f4a18..4288d4eb5d53b 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java @@ -56,7 +56,7 @@ import static java.util.Collections.emptySet; import static java.util.Collections.singletonList; import static org.opensearch.cluster.coordination.ClusterBootstrapService.BOOTSTRAP_PLACEHOLDER_PREFIX; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.monitor.StatusInfo.Status.HEALTHY; import static org.opensearch.monitor.StatusInfo.Status.UNHEALTHY; import static org.opensearch.node.Node.NODE_NAME_SETTING; @@ -329,7 +329,7 @@ public void testDescriptionBeforeBootstrapping() { ).getDescription(), is( "master not discovered yet, this node has not previously joined a bootstrapped cluster, and " - + "[cluster.initial_master_nodes] is empty on this node: have discovered []; " + + "[cluster.initial_cluster_manager_nodes] is empty on this node: have discovered []; " + "discovery will continue using [] from hosts providers and [" + localNode + "] from last-known cluster state; node term 1, last-accepted version 7 in term 4" @@ -349,7 +349,7 @@ public void testDescriptionBeforeBootstrapping() { ).getDescription(), is( "master not discovered yet, this node has not previously joined a bootstrapped cluster, and " - + "[cluster.initial_master_nodes] is empty on this node: have discovered []; " + + "[cluster.initial_cluster_manager_nodes] is empty on this node: have discovered []; " + "discovery will continue using [" + otherAddress + "] from hosts providers and [" @@ -371,7 +371,7 @@ public void testDescriptionBeforeBootstrapping() { ).getDescription(), is( "master not discovered yet, this node has not previously joined a bootstrapped cluster, and " - + "[cluster.initial_master_nodes] is empty on this node: have discovered [" + + "[cluster.initial_cluster_manager_nodes] is empty on this node: have discovered [" + otherNode + "]; " + "discovery will continue using [] from hosts providers and [" @@ -382,7 +382,7 @@ public void testDescriptionBeforeBootstrapping() { assertThat( new ClusterFormationState( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), "other").build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), "other").build(), clusterState, emptyList(), emptyList(), diff --git a/server/src/test/java/org/opensearch/indices/IndicesServiceCloseTests.java b/server/src/test/java/org/opensearch/indices/IndicesServiceCloseTests.java index ff97b87708202..e3b2afaccf054 100644 --- a/server/src/test/java/org/opensearch/indices/IndicesServiceCloseTests.java +++ b/server/src/test/java/org/opensearch/indices/IndicesServiceCloseTests.java @@ -64,7 +64,7 @@ import java.util.Collections; import java.util.concurrent.TimeUnit; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; @@ -94,7 +94,7 @@ private Node startNode() throws NodeValidationException { // turn it off for these tests. .put(HierarchyCircuitBreakerService.USE_REAL_MEMORY_USAGE_SETTING.getKey(), false) .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()) // empty list disables a port scan for other nodes - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), nodeName) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), nodeName) .put(IndicesQueryCache.INDICES_QUERIES_CACHE_ALL_SEGMENTS_SETTING.getKey(), true) .build(); diff --git a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java index 74da44af28e1d..5e7def04fe8c8 100644 --- a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java +++ b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java @@ -1445,8 +1445,8 @@ private Environment createEnvironment(String nodeName) { .put(PATH_HOME_SETTING.getKey(), tempDir.resolve(nodeName).toAbsolutePath()) .put(Environment.PATH_REPO_SETTING.getKey(), tempDir.resolve("repo").toAbsolutePath()) .putList( - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY) + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY) ) .put(MappingUpdatedAction.INDICES_MAX_IN_FLIGHT_UPDATES_SETTING.getKey(), 1000) // o.w. some tests might block .build() diff --git a/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java b/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java index 828496ebfa3a4..9841daa5f81b7 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java +++ b/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java @@ -1089,8 +1089,8 @@ protected Optional getDisruptableMockTransport(Transpo : Settings.builder() .put(nodeSettings) .putList( - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY) + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY) ) .build(); // suppress auto-bootstrap transportService = mockTransport.createTransportService( diff --git a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java index 11b39f0ff8da1..8000582793a95 100644 --- a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java @@ -157,7 +157,7 @@ import static org.apache.lucene.tests.util.LuceneTestCase.TEST_NIGHTLY; import static org.apache.lucene.tests.util.LuceneTestCase.rarely; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.common.unit.TimeValue.timeValueMillis; import static org.opensearch.common.unit.TimeValue.timeValueSeconds; import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_TYPE_SETTING; @@ -616,7 +616,7 @@ private NodeAndClient getOrBuildRandomNode() { final int nodeId = nextNodeId.getAndIncrement(); final Settings settings = getNodeSettings(nodeId, random.nextLong(), Settings.EMPTY, 1); final Settings nodeSettings = Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), Node.NODE_NAME_SETTING.get(settings)) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), Node.NODE_NAME_SETTING.get(settings)) .put(settings) .build(); final NodeAndClient buildNode = buildNode(nodeId, nodeSettings, false, onTransportServiceStarted); @@ -990,8 +990,8 @@ Settings closeForRestart(RestartCallback callback, int minMasterNodes) throws Ex Settings.Builder newSettings = Settings.builder(); newSettings.put(callbackSettings); if (minMasterNodes >= 0) { - if (INITIAL_MASTER_NODES_SETTING.exists(callbackSettings) == false) { - newSettings.putList(INITIAL_MASTER_NODES_SETTING.getKey()); + if (INITIAL_CLUSTER_MANAGER_NODES_SETTING.exists(callbackSettings) == false) { + newSettings.putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey()); } } // delete data folders now, before we start other nodes that may claim it @@ -1174,7 +1174,10 @@ private synchronized void reset(boolean wipeData) throws IOException { for (int i = 0; i < numSharedDedicatedMasterNodes + numSharedDataNodes + numSharedCoordOnlyNodes; i++) { Settings nodeSettings = updatedSettings.get(i); if (i == autoBootstrapMasterNodeIndex) { - nodeSettings = Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), masterNodeNames).put(nodeSettings).build(); + nodeSettings = Settings.builder() + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), masterNodeNames) + .put(nodeSettings) + .build(); } final NodeAndClient nodeAndClient = buildNode(i, nodeSettings, true, onTransportServiceStarted); toStartAndPublish.add(nodeAndClient); @@ -2034,7 +2037,7 @@ private List bootstrapMasterNodeWithSpecifiedIndex(List allN newSettings.add( Settings.builder() .put(settings) - .putList(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), nodeNames) + .putList(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), nodeNames) .build() ); @@ -2122,7 +2125,7 @@ public synchronized List startNodes(Settings... extraSettings) { final Builder builder = Settings.builder(); if (DiscoveryNode.isMasterNode(nodeSettings)) { if (autoBootstrapMasterNodeIndex == 0) { - builder.putList(INITIAL_MASTER_NODES_SETTING.getKey(), initialMasterNodes); + builder.putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), initialMasterNodes); } autoBootstrapMasterNodeIndex -= 1; } diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java index 3fe26d92bd17f..e3f6e6019546b 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java @@ -78,7 +78,7 @@ import java.util.Collections; import java.util.concurrent.TimeUnit; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; import static org.opensearch.test.NodeRoles.dataNode; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; @@ -241,7 +241,7 @@ private Node newNode() { // turn it off for these tests. .put(HierarchyCircuitBreakerService.USE_REAL_MEMORY_USAGE_SETTING.getKey(), false) .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()) // empty list disables a port scan for other nodes - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), nodeName) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), nodeName) .put(nodeSettings()) // allow test cases to provide their own settings or override these .build(); From ec47a937f3730f2af08531cdc9571f3df57fd1cb Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Fri, 18 Mar 2022 14:56:17 -0700 Subject: [PATCH 14/46] Deprecate setting 'cluster.service.slow_master_task_logging_threshold' and introduce the alternative setting 'cluster.service.slow_cluster_manager_task_logging_threshold' (#2451) Signed-off-by: Tianli Feng --- .../cluster/service/MasterService.java | 16 ++- .../common/settings/ClusterSettings.java | 3 +- .../MasterServiceRenamedSettingTests.java | 99 +++++++++++++++++++ .../cluster/service/MasterServiceTests.java | 27 ++--- 4 files changed, 131 insertions(+), 14 deletions(-) create mode 100644 server/src/test/java/org/opensearch/cluster/service/MasterServiceRenamedSettingTests.java diff --git a/server/src/main/java/org/opensearch/cluster/service/MasterService.java b/server/src/main/java/org/opensearch/cluster/service/MasterService.java index 7b0bede4c6c76..ad0bc599420f1 100644 --- a/server/src/main/java/org/opensearch/cluster/service/MasterService.java +++ b/server/src/main/java/org/opensearch/cluster/service/MasterService.java @@ -90,6 +90,15 @@ public class MasterService extends AbstractLifecycleComponent { "cluster.service.slow_master_task_logging_threshold", TimeValue.timeValueSeconds(10), Setting.Property.Dynamic, + Setting.Property.NodeScope, + Setting.Property.Deprecated + ); + // The setting below is going to replace the above. + // To keep backwards compatibility, the old usage is remained, and it's also used as the fallback for the new usage. + public static final Setting CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING = Setting.positiveTimeSetting( + "cluster.service.slow_cluster_manager_task_logging_threshold", + MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, + Setting.Property.Dynamic, Setting.Property.NodeScope ); @@ -111,8 +120,11 @@ public class MasterService extends AbstractLifecycleComponent { public MasterService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool) { this.nodeName = Objects.requireNonNull(Node.NODE_NAME_SETTING.get(settings)); - this.slowTaskLoggingThreshold = MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings); - clusterSettings.addSettingsUpdateConsumer(MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, this::setSlowTaskLoggingThreshold); + this.slowTaskLoggingThreshold = CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings); + clusterSettings.addSettingsUpdateConsumer( + CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, + this::setSlowTaskLoggingThreshold + ); this.threadPool = threadPool; } diff --git a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java index 247898843296f..786c1381e725b 100644 --- a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java @@ -332,7 +332,8 @@ public void apply(Settings value, Settings current, Settings previous) { IndexModule.NODE_STORE_ALLOW_MMAP, ClusterApplierService.CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, ClusterService.USER_DEFINED_METADATA, - MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, + MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, // deprecated + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, SearchService.DEFAULT_SEARCH_TIMEOUT_SETTING, SearchService.DEFAULT_ALLOW_PARTIAL_SEARCH_RESULTS, TransportSearchAction.SHARD_COUNT_LIMIT_SETTING, diff --git a/server/src/test/java/org/opensearch/cluster/service/MasterServiceRenamedSettingTests.java b/server/src/test/java/org/opensearch/cluster/service/MasterServiceRenamedSettingTests.java new file mode 100644 index 0000000000000..acf089dc43b56 --- /dev/null +++ b/server/src/test/java/org/opensearch/cluster/service/MasterServiceRenamedSettingTests.java @@ -0,0 +1,99 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.cluster.service; + +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Setting; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.unit.TimeValue; +import org.opensearch.test.OpenSearchTestCase; + +import java.util.Arrays; +import java.util.Set; + +/** + * A unit test to validate the former name of the setting 'cluster.service.slow_cluster_manager_task_logging_threshold' still take effect, + * after it is deprecated, so that the backwards compatibility is maintained. + * The test can be removed along with removing support of the deprecated setting. + */ +public class MasterServiceRenamedSettingTests extends OpenSearchTestCase { + + /** + * Validate the both settings are known and supported. + */ + public void testClusterManagerServiceSettingsExist() { + Set> settings = ClusterSettings.BUILT_IN_CLUSTER_SETTINGS; + assertTrue( + "Both 'cluster.service.slow_cluster_manager_task_logging_threshold' and its predecessor should be supported built-in settings", + settings.containsAll( + Arrays.asList( + MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING + ) + ) + ); + } + + /** + * Validate the default value of the both settings is the same. + */ + public void testSettingFallback() { + assertEquals( + MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY), + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY) + ); + } + + /** + * Validate the new setting can be configured correctly, and it doesn't impact the old setting. + */ + public void testSettingGetValue() { + Settings settings = Settings.builder().put("cluster.service.slow_cluster_manager_task_logging_threshold", "9s").build(); + assertEquals( + TimeValue.timeValueSeconds(9), + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings) + ); + assertEquals( + MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.getDefault(Settings.EMPTY), + MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings) + + ); + } + + /** + * Validate the value of the old setting will be applied to the new setting, if the new setting is not configured. + */ + public void testSettingGetValueWithFallback() { + Settings settings = Settings.builder().put("cluster.service.slow_master_task_logging_threshold", "8s").build(); + assertEquals( + TimeValue.timeValueSeconds(8), + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings) + + ); + assertSettingDeprecationsAndWarnings(new Setting[] { MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING }); + } + + /** + * Validate the value of the old setting will be ignored, if the new setting is configured. + */ + public void testSettingGetValueWhenBothAreConfigured() { + Settings settings = Settings.builder() + .put("cluster.service.slow_cluster_manager_task_logging_threshold", "9s") + .put("cluster.service.slow_master_task_logging_threshold", "8s") + .build(); + assertEquals( + TimeValue.timeValueSeconds(9), + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings) + + ); + assertEquals(TimeValue.timeValueSeconds(8), MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings)); + assertSettingDeprecationsAndWarnings(new Setting[] { MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING }); + } + +} diff --git a/server/src/test/java/org/opensearch/cluster/service/MasterServiceTests.java b/server/src/test/java/org/opensearch/cluster/service/MasterServiceTests.java index 134356b6e04c2..845a5ee91052d 100644 --- a/server/src/test/java/org/opensearch/cluster/service/MasterServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/service/MasterServiceTests.java @@ -809,12 +809,14 @@ public void testLongClusterStateUpdateLogging() throws Exception { final AtomicReference clusterStateRef = new AtomicReference<>(initialClusterState); masterService.setClusterStatePublisher((event, publishListener, ackListener) -> { if (event.source().contains("test5")) { - relativeTimeInMillis += MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY) - .millis() + randomLongBetween(1, 1000000); + relativeTimeInMillis += MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get( + Settings.EMPTY + ).millis() + randomLongBetween(1, 1000000); } if (event.source().contains("test6")) { - relativeTimeInMillis += MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY) - .millis() + randomLongBetween(1, 1000000); + relativeTimeInMillis += MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get( + Settings.EMPTY + ).millis() + randomLongBetween(1, 1000000); throw new OpenSearchException("simulated error during slow publication which should trigger logging"); } clusterStateRef.set(event.state()); @@ -830,7 +832,7 @@ public void testLongClusterStateUpdateLogging() throws Exception { public ClusterState execute(ClusterState currentState) { relativeTimeInMillis += randomLongBetween( 0L, - MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY).millis() + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY).millis() ); return currentState; } @@ -851,8 +853,9 @@ public void onFailure(String source, Exception e) { masterService.submitStateUpdateTask("test2", new ClusterStateUpdateTask() { @Override public ClusterState execute(ClusterState currentState) { - relativeTimeInMillis += MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY) - .millis() + randomLongBetween(1, 1000000); + relativeTimeInMillis += MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get( + Settings.EMPTY + ).millis() + randomLongBetween(1, 1000000); throw new IllegalArgumentException("Testing handling of exceptions in the cluster state task"); } @@ -869,8 +872,9 @@ public void onFailure(String source, Exception e) { masterService.submitStateUpdateTask("test3", new ClusterStateUpdateTask() { @Override public ClusterState execute(ClusterState currentState) { - relativeTimeInMillis += MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY) - .millis() + randomLongBetween(1, 1000000); + relativeTimeInMillis += MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get( + Settings.EMPTY + ).millis() + randomLongBetween(1, 1000000); return ClusterState.builder(currentState).incrementVersion().build(); } @@ -887,8 +891,9 @@ public void onFailure(String source, Exception e) { masterService.submitStateUpdateTask("test4", new ClusterStateUpdateTask() { @Override public ClusterState execute(ClusterState currentState) { - relativeTimeInMillis += MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY) - .millis() + randomLongBetween(1, 1000000); + relativeTimeInMillis += MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get( + Settings.EMPTY + ).millis() + randomLongBetween(1, 1000000); return currentState; } From 1193ec101b5d840c78ff3fa7a76cc0488f99f7ab Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Fri, 18 Mar 2022 14:57:08 -0700 Subject: [PATCH 15/46] Deprecate setting 'cluster.no_master_block' and introduce the alternative setting 'cluster.no_cluster_manager_block' (#2453) * Add a new setting `cluster.no_cluster_manager_block`, aims to replace the existing `cluster.no_master_block` * Set the value of the old setting `cluster.no_master_block` as the fallback to the new setting * Deprecate the existing `setting cluster.no_master_block` * Add unit tests Signed-off-by: Tianli Feng --- .../opensearch/cluster/NoMasterNodeIT.java | 6 +- .../discovery/MasterDisruptionIT.java | 6 +- .../coordination/NoMasterBlockService.java | 14 ++- .../common/settings/ClusterSettings.java | 3 +- .../coordination/CoordinatorTests.java | 6 +- ...MasterBlockServiceRenamedSettingTests.java | 87 +++++++++++++++++++ .../NoMasterBlockServiceTests.java | 16 ++-- .../opensearch/test/InternalTestCluster.java | 2 +- 8 files changed, 119 insertions(+), 21 deletions(-) create mode 100644 server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceRenamedSettingTests.java diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java index cef22343a1fea..5226eed2b6610 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java @@ -90,7 +90,7 @@ protected Collection> nodePlugins() { public void testNoMasterActions() throws Exception { Settings settings = Settings.builder() .put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), true) - .put(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), "all") + .put(NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "all") .build(); final TimeValue timeout = TimeValue.timeValueMillis(10); @@ -242,7 +242,7 @@ void checkWriteAction(ActionRequestBuilder builder) { public void testNoMasterActionsWriteMasterBlock() throws Exception { Settings settings = Settings.builder() .put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), false) - .put(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), "write") + .put(NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "write") .build(); final List nodes = internalCluster().startNodes(3, settings); @@ -323,7 +323,7 @@ public void testNoMasterActionsWriteMasterBlock() throws Exception { public void testNoMasterActionsMetadataWriteMasterBlock() throws Exception { Settings settings = Settings.builder() - .put(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), "metadata_write") + .put(NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "metadata_write") .put(MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING.getKey(), "100ms") .build(); diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/MasterDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/MasterDisruptionIT.java index 5f90e15701331..14e7a26bb448e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/MasterDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/MasterDisruptionIT.java @@ -189,7 +189,7 @@ public void testIsolateMasterAndVerifyClusterStateConsensus() throws Exception { * Verify that the proper block is applied when nodes lose their master */ public void testVerifyApiBlocksDuringPartition() throws Exception { - internalCluster().startNodes(3, Settings.builder().putNull(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey()).build()); + internalCluster().startNodes(3, Settings.builder().putNull(NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey()).build()); // Makes sure that the get request can be executed on each node locally: assertAcked( @@ -247,11 +247,11 @@ public void testVerifyApiBlocksDuringPartition() throws Exception { // Wait until the master node sees al 3 nodes again. ensureStableCluster(3, new TimeValue(DISRUPTION_HEALING_OVERHEAD.millis() + networkDisruption.expectedTimeToHeal().millis())); - logger.info("Verify no master block with {} set to {}", NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), "all"); + logger.info("Verify no master block with {} set to {}", NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "all"); client().admin() .cluster() .prepareUpdateSettings() - .setTransientSettings(Settings.builder().put(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), "all")) + .setTransientSettings(Settings.builder().put(NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "all")) .get(); networkDisruption.startDisrupting(); diff --git a/server/src/main/java/org/opensearch/cluster/coordination/NoMasterBlockService.java b/server/src/main/java/org/opensearch/cluster/coordination/NoMasterBlockService.java index a578389f86343..8cbb0446a1337 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/NoMasterBlockService.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/NoMasterBlockService.java @@ -76,14 +76,24 @@ public class NoMasterBlockService { "write", NoMasterBlockService::parseNoMasterBlock, Property.Dynamic, + Property.NodeScope, + Property.Deprecated + ); + // The setting below is going to replace the above. + // To keep backwards compatibility, the old usage is remained, and it's also used as the fallback for the new usage. + public static final Setting NO_CLUSTER_MANAGER_BLOCK_SETTING = new Setting<>( + "cluster.no_cluster_manager_block", + NO_MASTER_BLOCK_SETTING, + NoMasterBlockService::parseNoMasterBlock, + Property.Dynamic, Property.NodeScope ); private volatile ClusterBlock noMasterBlock; public NoMasterBlockService(Settings settings, ClusterSettings clusterSettings) { - this.noMasterBlock = NO_MASTER_BLOCK_SETTING.get(settings); - clusterSettings.addSettingsUpdateConsumer(NO_MASTER_BLOCK_SETTING, this::setNoMasterBlock); + this.noMasterBlock = NO_CLUSTER_MANAGER_BLOCK_SETTING.get(settings); + clusterSettings.addSettingsUpdateConsumer(NO_CLUSTER_MANAGER_BLOCK_SETTING, this::setNoMasterBlock); } private static ClusterBlock parseNoMasterBlock(String value) { diff --git a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java index 786c1381e725b..c758b7d2918e7 100644 --- a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java @@ -272,7 +272,8 @@ public void apply(Settings value, Settings current, Settings previous) { InternalClusterInfoService.INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING, InternalSnapshotsInfoService.INTERNAL_SNAPSHOT_INFO_MAX_CONCURRENT_FETCHES_SETTING, DestructiveOperations.REQUIRES_NAME_SETTING, - NoMasterBlockService.NO_MASTER_BLOCK_SETTING, + NoMasterBlockService.NO_MASTER_BLOCK_SETTING, // deprecated + NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING, GatewayService.EXPECTED_DATA_NODES_SETTING, GatewayService.EXPECTED_MASTER_NODES_SETTING, GatewayService.EXPECTED_NODES_SETTING, diff --git a/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java b/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java index 8164047178b1f..33d522e196d9b 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java @@ -84,7 +84,7 @@ import static org.opensearch.cluster.coordination.LeaderChecker.LEADER_CHECK_TIMEOUT_SETTING; import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_ALL; import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_METADATA_WRITES; -import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_SETTING; +import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING; import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_WRITES; import static org.opensearch.cluster.coordination.Reconfigurator.CLUSTER_AUTO_SHRINK_VOTING_CONFIGURATION; import static org.opensearch.discovery.PeerFinder.DISCOVERY_FIND_PEERS_INTERVAL_SETTING; @@ -1143,9 +1143,9 @@ private void testAppliesNoMasterBlock(String noMasterBlockSetting, ClusterBlock cluster.stabilise(); final ClusterNode leader = cluster.getAnyLeader(); - leader.submitUpdateTask("update NO_MASTER_BLOCK_SETTING", cs -> { + leader.submitUpdateTask("update NO_CLUSTER_MANAGER_BLOCK_SETTING", cs -> { final Builder settingsBuilder = Settings.builder().put(cs.metadata().persistentSettings()); - settingsBuilder.put(NO_MASTER_BLOCK_SETTING.getKey(), noMasterBlockSetting); + settingsBuilder.put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), noMasterBlockSetting); return ClusterState.builder(cs) .metadata(Metadata.builder(cs.metadata()).persistentSettings(settingsBuilder.build())) .build(); diff --git a/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceRenamedSettingTests.java b/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceRenamedSettingTests.java new file mode 100644 index 0000000000000..2c988cad5f79c --- /dev/null +++ b/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceRenamedSettingTests.java @@ -0,0 +1,87 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.cluster.coordination; + +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Setting; +import org.opensearch.common.settings.Settings; +import org.opensearch.test.OpenSearchTestCase; + +import java.util.Arrays; +import java.util.Set; + +/** + * A unit test to validate the former name of the setting 'cluster.no_cluster_manager_block' still take effect, + * after it is deprecated, so that the backwards compatibility is maintained. + * The test can be removed along with removing support of the deprecated setting. + */ +public class NoMasterBlockServiceRenamedSettingTests extends OpenSearchTestCase { + + /** + * Validate the both settings are known and supported. + */ + public void testReindexSettingsExist() { + Set> settings = ClusterSettings.BUILT_IN_CLUSTER_SETTINGS; + assertTrue( + "Both 'cluster.no_cluster_manager_block' and its predecessor should be supported built-in settings.", + settings.containsAll( + Arrays.asList(NoMasterBlockService.NO_MASTER_BLOCK_SETTING, NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING) + ) + ); + } + + /** + * Validate the default value of the both settings is the same. + */ + public void testSettingFallback() { + assertEquals( + NoMasterBlockService.NO_MASTER_BLOCK_SETTING.get(Settings.EMPTY), + NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.get(Settings.EMPTY) + + ); + } + + /** + * Validate the new setting can be configured correctly, and it doesn't impact the old setting. + */ + public void testSettingGetValue() { + Settings settings = Settings.builder().put("cluster.no_cluster_manager_block", "all").build(); + assertEquals(NoMasterBlockService.NO_MASTER_BLOCK_ALL, NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.get(settings)); + assertEquals( + NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getDefault(Settings.EMPTY), + NoMasterBlockService.NO_MASTER_BLOCK_SETTING.get(settings) + ); + } + + /** + * Validate the value of the old setting will be applied to the new setting, if the new setting is not configured. + */ + public void testSettingGetValueWithFallback() { + Settings settings = Settings.builder().put("cluster.no_master_block", "metadata_write").build(); + assertEquals( + NoMasterBlockService.NO_MASTER_BLOCK_METADATA_WRITES, + NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.get(settings) + ); + assertSettingDeprecationsAndWarnings(new Setting[] { NoMasterBlockService.NO_MASTER_BLOCK_SETTING }); + } + + /** + * Validate the value of the old setting will be ignored, if the new setting is configured. + */ + public void testSettingGetValueWhenBothAreConfigured() { + Settings settings = Settings.builder() + .put("cluster.no_cluster_manager_block", "all") + .put("cluster.no_master_block", "metadata_write") + .build(); + assertEquals(NoMasterBlockService.NO_MASTER_BLOCK_ALL, NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.get(settings)); + assertEquals(NoMasterBlockService.NO_MASTER_BLOCK_METADATA_WRITES, NoMasterBlockService.NO_MASTER_BLOCK_SETTING.get(settings)); + assertSettingDeprecationsAndWarnings(new Setting[] { NoMasterBlockService.NO_MASTER_BLOCK_SETTING }); + } + +} diff --git a/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceTests.java b/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceTests.java index c1ca775142a5b..a637826951f87 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceTests.java @@ -37,7 +37,7 @@ import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_ALL; import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_METADATA_WRITES; -import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_SETTING; +import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING; import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_WRITES; import static org.opensearch.common.settings.ClusterSettings.BUILT_IN_CLUSTER_SETTINGS; import static org.hamcrest.Matchers.sameInstance; @@ -65,35 +65,35 @@ public void testBlocksWritesByDefault() { } public void testBlocksWritesIfConfiguredBySetting() { - createService(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "write").build()); + createService(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "write").build()); assertThat(noMasterBlockService.getNoMasterBlock(), sameInstance(NO_MASTER_BLOCK_WRITES)); } public void testBlocksAllIfConfiguredBySetting() { - createService(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "all").build()); + createService(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "all").build()); assertThat(noMasterBlockService.getNoMasterBlock(), sameInstance(NO_MASTER_BLOCK_ALL)); } public void testBlocksMetadataWritesIfConfiguredBySetting() { - createService(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "metadata_write").build()); + createService(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "metadata_write").build()); assertThat(noMasterBlockService.getNoMasterBlock(), sameInstance(NO_MASTER_BLOCK_METADATA_WRITES)); } public void testRejectsInvalidSetting() { expectThrows( IllegalArgumentException.class, - () -> createService(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "unknown").build()) + () -> createService(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "unknown").build()) ); } public void testSettingCanBeUpdated() { - createService(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "all").build()); + createService(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "all").build()); assertThat(noMasterBlockService.getNoMasterBlock(), sameInstance(NO_MASTER_BLOCK_ALL)); - clusterSettings.applySettings(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "write").build()); + clusterSettings.applySettings(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "write").build()); assertThat(noMasterBlockService.getNoMasterBlock(), sameInstance(NO_MASTER_BLOCK_WRITES)); - clusterSettings.applySettings(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "metadata_write").build()); + clusterSettings.applySettings(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "metadata_write").build()); assertThat(noMasterBlockService.getNoMasterBlock(), sameInstance(NO_MASTER_BLOCK_METADATA_WRITES)); } } diff --git a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java index 8000582793a95..7461ebb9c8713 100644 --- a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java @@ -435,7 +435,7 @@ public InternalTestCluster( ); // TODO: currently we only randomize "cluster.no_master_block" between "write" and "metadata_write", as "all" is fragile // and fails shards when a master abdicates, which breaks many tests. - builder.put(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), randomFrom(random, "write", "metadata_write")); + builder.put(NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), randomFrom(random, "write", "metadata_write")); defaultSettings = builder.build(); executor = OpenSearchExecutors.newScaling( "internal_test_cluster_executor", From 3da9eb642cdab557711e88fba997303031e3b7f5 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Fri, 18 Mar 2022 15:00:23 -0700 Subject: [PATCH 16/46] Add a new REST API endpoint 'GET _cat/cluster_manager' as the replacement of 'GET _cat/master' (#2404) * Add a new path `/_cat/cluster_manager` for the REST request handler `RestMasterAction` * Deprecate the existing path `/_cat/master` * Change the name of the `RestMasterAction` handler from `cat_master_action` to `cat_cluster_manager_action` * Change the response of `GET _cat` to only show the new path `/_cat/cluster_manager` * Rename the JSON rest-api-spec file `cat.master.json` to `cat.cluster_manager.json` and update the paths. * Add YAML REST test. By default, it will run test for both endpoints `GET _cat/cluster_manager` and `GET _cat/master` Signed-off-by: Tianli Feng --- ...t.master.json => cat.cluster_manager.json} | 20 ++++++-- .../test/cat.cluster_manager/10_basic.yml | 46 +++++++++++++++++++ .../rest/action/cat/RestMasterAction.java | 9 ++-- 3 files changed, 66 insertions(+), 9 deletions(-) rename rest-api-spec/src/main/resources/rest-api-spec/api/{cat.master.json => cat.cluster_manager.json} (67%) create mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/cat.cluster_manager/10_basic.yml diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cat.master.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cat.cluster_manager.json similarity index 67% rename from rest-api-spec/src/main/resources/rest-api-spec/api/cat.master.json rename to rest-api-spec/src/main/resources/rest-api-spec/api/cat.cluster_manager.json index 63fe159ee56b8..c1084825546bf 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/cat.master.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cat.cluster_manager.json @@ -1,17 +1,27 @@ { - "cat.master":{ + "cat.cluster_manager":{ "documentation":{ - "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html", - "description":"Returns information about the master node." + "url":"https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/", + "description":"Returns information about the cluster-manager node." }, "stability":"stable", "url":{ "paths":[ { - "path":"/_cat/master", + "path":"/_cat/cluster_manager", "methods":[ "GET" ] + }, + { + "path":"/_cat/master", + "methods":[ + "GET" + ], + "deprecated":{ + "version":"2.0.0", + "description":"To promote inclusive language, please use '/_cat/cluster_manager' instead." + } } ] }, @@ -22,7 +32,7 @@ }, "local":{ "type":"boolean", - "description":"Return local information, do not retrieve the state from master node (default: false)" + "description":"Return local information, do not retrieve the state from cluster-manager node (default: false)" }, "master_timeout":{ "type":"time", diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.cluster_manager/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.cluster_manager/10_basic.yml new file mode 100644 index 0000000000000..b0f1c81b56a0e --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.cluster_manager/10_basic.yml @@ -0,0 +1,46 @@ +setup: + - skip: + features: allowed_warnings + +--- +"Help": + - skip: + version: " - 1.4.99" + reason: "path _cat/cluster_manager is introduced in 2.0.0" + + - do: + cat.cluster_manager: + help: true + allowed_warnings: + - '[GET /_cat/master] is deprecated! Use [GET /_cat/cluster_manager] instead.' + + - match: + $body: | + /^ id .+ \n + host .+ \n + ip .+ \n + node .+ \n + + $/ + +--- +"Test cat cluster_manager output": + - skip: + version: " - 1.4.99" + reason: "path _cat/cluster_manager is introduced in 2.0.0" + + - do: + cat.cluster_manager: {} + allowed_warnings: + - '[GET /_cat/master] is deprecated! Use [GET /_cat/cluster_manager] instead.' + + - match: + $body: | + /^ + ( \S+ \s+ # node id + [-\w.]+ \s+ # host name + (\d{1,3}\.){3}\d{1,3} \s+ # ip address + [-\w.]+ # node name + \n + ) + $/ diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestMasterAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestMasterAction.java index 56172e41effe1..1219b419122c6 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestMasterAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestMasterAction.java @@ -50,18 +50,19 @@ public class RestMasterAction extends AbstractCatAction { @Override - public List routes() { - return singletonList(new Route(GET, "/_cat/master")); + public List replacedRoutes() { + // The deprecated path will be removed in a future major version. + return singletonList(new ReplacedRoute(GET, "/_cat/cluster_manager", "/_cat/master")); } @Override public String getName() { - return "cat_master_action"; + return "cat_cluster_manager_action"; } @Override protected void documentation(StringBuilder sb) { - sb.append("/_cat/master\n"); + sb.append("/_cat/cluster_manager\n"); } @Override From a87c9d4455f042cf14e684c7f4dce1904dd0dbe5 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Fri, 18 Mar 2022 15:02:06 -0700 Subject: [PATCH 17/46] Add request parameter 'cluster_manager_timeout' as the alternative for 'master_timeout', and deprecate 'master_timeout' - in CAT Nodes API (#2435) * `master_timeout` is being used in multiple APIs, such as cat allocation and cat nodes APIs. The PR take CAT Nodes API as a sample. * Add a new request parameter `cluster_manager_timeout`, as the alternative for the existing `master_timeout`, in CAT Nodes API * Throw an exception when both master_timeout and cluster_manager_timeout are assigned but with different values, such as `GET _cat/nodes?v&master_timeout=1s&cluster_manager_timeout=2s`. This is addressed by the temporary method `validateParamValuesAreEqual()` added in `RestRequest` class. * Add deprecation log when using request parameter `master_timeout` * Deprecate request parameter `master_timeout` of in rest api spec * Add unit tests Signed-off-by: Tianli Feng --- .../rest-api-spec/api/cat.nodes.json | 10 ++++- .../java/org/opensearch/rest/RestRequest.java | 27 ++++++++++++++ .../rest/action/cat/RestNodesAction.java | 21 ++++++++++- .../org/opensearch/rest/RestRequestTests.java | 37 +++++++++++++++++++ .../rest/action/cat/RestNodesActionTests.java | 18 +++++++++ 5 files changed, 111 insertions(+), 2 deletions(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cat.nodes.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cat.nodes.json index ba3faa92c5ec6..abb13d015b4d5 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/cat.nodes.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cat.nodes.json @@ -51,7 +51,15 @@ }, "master_timeout":{ "type":"time", - "description":"Explicit operation timeout for connection to master node" + "description":"Explicit operation timeout for connection to master node", + "deprecated":{ + "version":"2.0.0", + "description":"To promote inclusive language, use 'cluster_manager_timeout' instead." + } + }, + "cluster_manager_timeout":{ + "type":"time", + "description":"Explicit operation timeout for connection to cluster-manager node" }, "h":{ "type":"list", diff --git a/server/src/main/java/org/opensearch/rest/RestRequest.java b/server/src/main/java/org/opensearch/rest/RestRequest.java index 7d11da7e122cd..e04d8faa8af39 100644 --- a/server/src/main/java/org/opensearch/rest/RestRequest.java +++ b/server/src/main/java/org/opensearch/rest/RestRequest.java @@ -54,6 +54,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -578,6 +579,32 @@ public static XContentType parseContentType(List header) { throw new IllegalArgumentException("empty Content-Type header"); } + /** + * The method is only used to validate whether the values of the 2 request parameters "master_timeout" and "cluster_manager_timeout" is the same value or not. + * If the 2 values are not the same, throw an {@link OpenSearchParseException}. + * @param keys Names of the request parameters. + * @deprecated The method will be removed along with the request parameter "master_timeout". + */ + @Deprecated + public void validateParamValuesAreEqual(String... keys) { + // Track the last seen value and ensure that every subsequent value matches it. + // The value to be tracked is the non-empty values of the parameters with the key. + String lastSeenValue = null; + for (String key : keys) { + String value = param(key); + if (!Strings.isNullOrEmpty(value)) { + if (lastSeenValue == null || value.equals(lastSeenValue)) { + lastSeenValue = value; + } else { + throw new OpenSearchParseException( + "The values of the request parameters: {} are required to be equal, otherwise please only assign value to one of the request parameters.", + Arrays.toString(keys) + ); + } + } + } + } + public static class ContentTypeHeaderException extends RuntimeException { ContentTypeHeaderException(final IllegalArgumentException cause) { diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java index bce9b2d6b7e9d..7899909cdebbf 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java @@ -86,6 +86,8 @@ public class RestNodesAction extends AbstractCatAction { private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestNodesAction.class); static final String LOCAL_DEPRECATED_MESSAGE = "Deprecated parameter [local] used. This parameter does not cause this API to act " + "locally, and should not be used. It will be unsupported in version 8.0."; + static final String MASTER_TIMEOUT_DEPRECATED_MESSAGE = + "Deprecated parameter [master_timeout] used. To promote inclusive language, please use [cluster_manager_timeout] instead. It will be unsupported in a future major version."; @Override public List routes() { @@ -110,7 +112,8 @@ public RestChannelConsumer doCatRequest(final RestRequest request, final NodeCli deprecationLogger.deprecate("cat_nodes_local_parameter", LOCAL_DEPRECATED_MESSAGE); } clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); - clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout())); + clusterStateRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", clusterStateRequest.masterNodeTimeout())); + parseDeprecatedMasterTimeoutParameter(clusterStateRequest, request); final boolean fullId = request.paramAsBoolean("full_id", false); return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener(channel) { @Override @@ -525,4 +528,20 @@ Table buildTable( private short calculatePercentage(long used, long max) { return max <= 0 ? 0 : (short) ((100d * used) / max); } + + /** + * Parse the deprecated request parameter 'master_timeout', and add deprecated log if the parameter is used. + * It also validates whether the value of 'master_timeout' is the same with 'cluster_manager_timeout'. + * Remove the method along with MASTER_ROLE. + * @deprecated As of 2.0, because promoting inclusive language. + */ + @Deprecated + private void parseDeprecatedMasterTimeoutParameter(ClusterStateRequest clusterStateRequest, RestRequest request) { + final String deprecatedTimeoutParam = "master_timeout"; + if (request.hasParam(deprecatedTimeoutParam)) { + deprecationLogger.deprecate("cat_nodes_master_timeout_parameter", MASTER_TIMEOUT_DEPRECATED_MESSAGE); + request.validateParamValuesAreEqual(deprecatedTimeoutParam, "cluster_manager_timeout"); + clusterStateRequest.masterNodeTimeout(request.paramAsTime(deprecatedTimeoutParam, clusterStateRequest.masterNodeTimeout())); + } + } } diff --git a/server/src/test/java/org/opensearch/rest/RestRequestTests.java b/server/src/test/java/org/opensearch/rest/RestRequestTests.java index 7abc53e4ca610..d5a915b42cf87 100644 --- a/server/src/test/java/org/opensearch/rest/RestRequestTests.java +++ b/server/src/test/java/org/opensearch/rest/RestRequestTests.java @@ -34,6 +34,7 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.common.CheckedConsumer; +import org.opensearch.common.Strings; import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.collect.MapBuilder; @@ -50,11 +51,13 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; +import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.mockito.Mockito.mock; @@ -280,6 +283,40 @@ public void testRequiredContent() { assertEquals("unknown content type", e.getMessage()); } + /* + * The test is added in 2.0 when the request parameter "cluster_manager_timeout" is introduced. + * Remove the test along with the removal of the non-inclusive terminology "master_timeout". + */ + public void testValidateParamValuesAreEqualWhenTheyAreEqual() { + FakeRestRequest request = new FakeRestRequest(); + String valueForKey1 = randomFrom("value1", "", null); + String valueForKey2 = "value1"; + request.params().put("key1", valueForKey1); + request.params().put("key2", valueForKey2); + request.validateParamValuesAreEqual("key1", "key2"); + assertTrue( + String.format( + Locale.ROOT, + "The 2 values should be equal, or having 1 null/empty value. Value of key1: %s. Value of key2: %s", + valueForKey1, + valueForKey2 + ), + Strings.isNullOrEmpty(valueForKey1) || valueForKey1.equals(valueForKey2) + ); + } + + /* + * The test is added in 2.0 when the request parameter "cluster_manager_timeout" is introduced. + * Remove the test along with the removal of the non-inclusive terminology "master_timeout". + */ + public void testValidateParamValuesAreEqualWhenTheyAreNotEqual() { + FakeRestRequest request = new FakeRestRequest(); + request.params().put("key1", "value1"); + request.params().put("key2", "value2"); + Exception e = assertThrows(OpenSearchParseException.class, () -> request.validateParamValuesAreEqual("key1", "key2")); + assertThat(e.getMessage(), containsString("The values of the request parameters: [key1, key2] are required to be equal")); + } + private static RestRequest contentRestRequest(String content, Map params) { Map> headers = new HashMap<>(); headers.put("Content-Type", Collections.singletonList("application/json")); diff --git a/server/src/test/java/org/opensearch/rest/action/cat/RestNodesActionTests.java b/server/src/test/java/org/opensearch/rest/action/cat/RestNodesActionTests.java index 593ad2907797e..9293d40605f42 100644 --- a/server/src/test/java/org/opensearch/rest/action/cat/RestNodesActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/cat/RestNodesActionTests.java @@ -32,6 +32,7 @@ package org.opensearch.rest.action.cat; +import org.opensearch.OpenSearchParseException; import org.opensearch.Version; import org.opensearch.action.admin.cluster.node.info.NodesInfoResponse; import org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse; @@ -51,6 +52,7 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; +import static org.hamcrest.CoreMatchers.containsString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -89,4 +91,20 @@ public void testCatNodesWithLocalDeprecationWarning() { terminate(threadPool); } + + /** + * Validate both cluster_manager_timeout and its predecessor can be parsed correctly. + * Remove the test along with MASTER_ROLE. It's added in version 2.0.0. + */ + public void testCatNodesWithClusterManagerTimeout() { + TestThreadPool threadPool = new TestThreadPool(RestNodesActionTests.class.getName()); + NodeClient client = new NodeClient(Settings.EMPTY, threadPool); + FakeRestRequest request = new FakeRestRequest(); + request.params().put("cluster_manager_timeout", randomFrom("1h", "2m")); + request.params().put("master_timeout", "3s"); + Exception e = assertThrows(OpenSearchParseException.class, () -> action.doCatRequest(request, client)); + assertThat(e.getMessage(), containsString("[master_timeout, cluster_manager_timeout] are required to be equal")); + assertWarnings(RestNodesAction.MASTER_TIMEOUT_DEPRECATED_MESSAGE); + terminate(threadPool); + } } From 1c2bdd86429fe8ff5c5ea323482d40d5b6a972a4 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Fri, 18 Mar 2022 15:03:06 -0700 Subject: [PATCH 18/46] Add a field discovered_cluster_manager in get cluster health api (#2437) * Add a new field discovered_cluster_manager to the response of `GET _cluster/health` API, which has got the same value with the existing discovered_master field, aims to replace the non-inclusive term "master" in the API response field. * Add yaml rest test to validate `discovered_cluster_manager` and `discovered_master` field have got the same value. Signed-off-by: Tianli Feng --- .../rest-api-spec/test/cluster.health/10_basic.yml | 13 +++++++++++++ .../admin/cluster/health/ClusterHealthResponse.java | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml index db74e51cc2f91..0f12a87bd8771 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml @@ -275,3 +275,16 @@ cluster.health: index: index-2 - match: { status: yellow } + +--- +"Get cluster health has same value for discovered_master and discovered_cluster_manager": + - skip: + version: " - 1.4.99" + reason: "discovered_cluster_manager is added in 2.0.0" + - do: + cluster.health: {} + - set: + discovered_master: discovered_or_not + + - match: { discovered_master: $discovered_or_not } + - match: { discovered_cluster_manager: $discovered_or_not } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java index 6296fcd34fb23..d9094e307fff1 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java @@ -67,6 +67,7 @@ public class ClusterHealthResponse extends ActionResponse implements StatusToXCo private static final String NUMBER_OF_NODES = "number_of_nodes"; private static final String NUMBER_OF_DATA_NODES = "number_of_data_nodes"; private static final String DISCOVERED_MASTER = "discovered_master"; + private static final String DISCOVERED_CLUSTER_MANAGER = "discovered_cluster_manager"; private static final String NUMBER_OF_PENDING_TASKS = "number_of_pending_tasks"; private static final String NUMBER_OF_IN_FLIGHT_FETCH = "number_of_in_flight_fetch"; private static final String DELAYED_UNASSIGNED_SHARDS = "delayed_unassigned_shards"; @@ -376,7 +377,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field(TIMED_OUT, isTimedOut()); builder.field(NUMBER_OF_NODES, getNumberOfNodes()); builder.field(NUMBER_OF_DATA_NODES, getNumberOfDataNodes()); - builder.field(DISCOVERED_MASTER, hasDiscoveredMaster()); + builder.field(DISCOVERED_MASTER, hasDiscoveredMaster()); // the field will be removed in a future major version + builder.field(DISCOVERED_CLUSTER_MANAGER, hasDiscoveredMaster()); builder.field(ACTIVE_PRIMARY_SHARDS, getActivePrimaryShards()); builder.field(ACTIVE_SHARDS, getActiveShards()); builder.field(RELOCATING_SHARDS, getRelocatingShards()); From ee048851f5c5e0019f0e212fee8efc63c752d057 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Fri, 18 Mar 2022 15:04:03 -0700 Subject: [PATCH 19/46] Replace 'discovered_master' with 'discovered_cluster_manager' in 'GET Cat Health' API (#2438) * Replace 'discovered_master' with 'discovered_cluster_manager' in the table header of `GET Cat Health` API, to promote inclusive language. * Add `dcm` as the alias for the table header `discovered_cluster_manager` * Add `discovered_master` as the alias for the table header `discovered_cluster_manager`, for keeping compatibility when using `GET _cat/nodes?v&h=discovered_master` to show the specific column only. * Add YAML rest test Signed-off-by: Tianli Feng --- .../test/cat.health/10_basic.yml | 42 +++++++++++++++++-- .../rest/action/cat/RestHealthAction.java | 7 +++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml index 731fc5d166eca..0d945d01a6ddb 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml @@ -1,11 +1,19 @@ --- -"Help": +"Help - before 2.0.0": - skip: - version: " - 7.10.99" - reason: "discovered_master added in OpenSearch 1.0.0" + version: " - 7.10.99 , 2.0.0 - " + reason: "discovered_master added in OpenSearch 1.0.0, and renamed to discovered_cluster_manager in 2.0.0" + features: node_selector - do: cat.health: help: true + node_selector: + # Only send request to nodes in <2.0 versions, especially during ':qa:mixed-cluster:v1.x.x#mixedClusterTest'. + # Because YAML REST test takes the minimum OpenSearch version in the cluster to apply the filter in 'skip' section, + # see OpenSearchClientYamlSuiteTestCase#initAndResetContext() for detail. + # During 'mixedClusterTest', the cluster can be mixed with nodes in 1.x and 2.x versions, + # so node_selector is required, and only filtering version in 'skip' is not enough. + version: "1.0.0 - 1.4.99" - match: $body: | @@ -27,6 +35,34 @@ $/ +--- +"Help": + - skip: + version: " - 1.4.99" + reason: "discovered_cluster_manager is added in OpenSearch 2.0.0" + - do: + cat.health: + help: true + + - match: + $body: | + /^ epoch .+ \n + timestamp .+ \n + cluster .+ \n + status .+ \n + node.total .+ \n + node.data .+ \n + discovered_cluster_manager .+ \n + shards .+ \n + pri .+ \n + relo .+ \n + init .+ \n + unassign .+ \n + pending_tasks .+ \n + max_task_wait_time .+ \n + active_shards_percent .+ \n + + $/ --- "Empty cluster": diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java index b6e945620f918..c05b0b9c77129 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java @@ -88,7 +88,12 @@ protected Table getTableWithHeader(final RestRequest request) { t.addCell("status", "alias:st;desc:health status"); t.addCell("node.total", "alias:nt,nodeTotal;text-align:right;desc:total number of nodes"); t.addCell("node.data", "alias:nd,nodeData;text-align:right;desc:number of nodes that can store data"); - t.addCell("discovered_master", "alias:dm;text-align:right;desc:discovered master"); + // TODO: Remove the header alias 'discovered_master', after removing MASTER_ROLE. + // The alias 'discovered_master' is added for compatibility when using request parameter 'h=discovered_master'. + t.addCell( + "discovered_cluster_manager", + "alias:dcm,dm,discovered_master;text-align:right;desc:cluster manager is discovered or not" + ); t.addCell("shards", "alias:t,sh,shards.total,shardsTotal;text-align:right;desc:total number of shards"); t.addCell("pri", "alias:p,shards.primary,shardsPrimary;text-align:right;desc:number of primary shards"); t.addCell("relo", "alias:r,shards.relocating,shardsRelocating;text-align:right;desc:number of relocating nodes"); From 641350b0b61ee7ff3ca8175114b84406b590429b Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Fri, 18 Mar 2022 15:04:49 -0700 Subject: [PATCH 20/46] Replace 'master' with 'cluster_manager' in 'GET Cat Nodes' API (#2441) * Replace 'master' with 'cluster_manager' in the table header of [GET Cat Nodes](https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-nodes/) API, to promote inclusive language. * Add `cm` as the alias for the table header `cluster_manager` * Add `master` as the alias for the table header `cluster_manager`, for keeping compatibility when using `GET _cat/nodes?v&h=master` to show the specific column only. * Add YAML rest test Signed-off-by: Tianli Feng --- .../resources/rest-api-spec/test/11_nodes.yml | 26 +++++++++++--- .../rest-api-spec/test/cat.nodes/10_basic.yml | 34 ++++++++++++++++--- .../rest/action/cat/RestNodesAction.java | 3 +- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml b/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml index af1ed146c41aa..95ea022696942 100644 --- a/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml +++ b/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml @@ -1,13 +1,31 @@ +--- +"Test cat nodes output - before 2.0.0": + - skip: + version: "2.0.0 - " + reason: "master is replaced by cluster_manager in 2.0.0" + + - do: + cat.nodes: + v: true + + - match: + $body: | + /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n + ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + --- "Test cat nodes output": + - skip: + version: " - 1.4.99" + reason: "cluster_manager is introduced in 2.0.0" - do: cat.nodes: {} - match: $body: | - / #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name - ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + / #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role cluster_manager name + ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ - do: cat.nodes: @@ -15,8 +33,8 @@ - match: $body: | - /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n - ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ cluster_manager \s+ name \n + ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ - do: cat.nodes: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yml index 16bf099081c6d..789ea5fc19c3f 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yml @@ -1,13 +1,39 @@ +--- +"Test cat nodes output - before 2.0.0": + - skip: + version: "2.0.0 - " + reason: "master is replaced by cluster_manager in 2.0.0" + features: node_selector + + - do: + cat.nodes: + v: true + node_selector: + # Only send request to nodes in <2.0 versions, especially during ':qa:mixed-cluster:v1.x.x#mixedClusterTest'. + # Because YAML REST test takes the minimum OpenSearch version in the cluster to apply the filter in 'skip' section, + # see OpenSearchClientYamlSuiteTestCase#initAndResetContext() for detail. + # During 'mixedClusterTest', the cluster can be mixed with nodes in 1.x and 2.x versions, + # so node_selector is required, and only filtering version in 'skip' is not enough. + version: "1.0.0 - 1.4.99" + + - match: + $body: | + /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n + ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + --- "Test cat nodes output": + - skip: + version: " - 1.4.99" + reason: "cluster_manager is introduced in 2.0.0" - do: cat.nodes: {} - match: $body: | - / #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name - ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + / #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role cluster_manager name + ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ - do: cat.nodes: @@ -15,8 +41,8 @@ - match: $body: | - /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n - ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ cluster_manager \s+ name \n + ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ - do: cat.nodes: diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java index 7899909cdebbf..abc4b48b01cff 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java @@ -196,7 +196,8 @@ protected Table getTableWithHeader(final RestRequest request) { "node.role", "alias:r,role,nodeRole;desc:m:master eligible node, d:data node, i:ingest node, -:coordinating node only" ); - table.addCell("master", "alias:m;desc:*:current master"); + // TODO: Remove the header alias 'master', after removing MASTER_ROLE. It's added for compatibility when using parameter 'h=master'. + table.addCell("cluster_manager", "alias:cm,m,master;desc:*:current cluster manager"); table.addCell("name", "alias:n;desc:node name"); table.addCell("completion.size", "alias:cs,completionSize;default:false;text-align:right;desc:size of completion"); From ea3148312622cd1362593e3623d498e57913ae45 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Fri, 18 Mar 2022 15:06:06 -0700 Subject: [PATCH 21/46] Add a new node role 'cluster_manager' as the alternative for 'master' role and deprecate 'master' role (#2424) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new node role `cluster_manager`, as the replacement for `master` role, that used in setting `node.roles: [ master ]`. They have got the same functionality, but can NOT be assigned to `node.roles` together. * Add `CLUSTER_MANAGER_ROLE` in `DiscoveryNodeRole` class, and deprecate `MASTER_ROLE` * Remove `MASTER_ROLE` from the `DiscoveryNodeRole.BUILT_IN_ROLES`, and temporarily load the role by the existing method `DiscoveryNode.setAdditionalRoles` * Add a method `validateRole()` in `DiscoveryNodeRole` class, it's used to validate a specific role is compatible with the other roles to be assigned to a node together. * Add deprecation message when assigning `master` role in setting `node.roles` * Replace most `MASTER_ROLE` with `CLUSTER_MANAGER_ROLE` in current unit and integration tests * Add new unit and integration tests to validate `CLUSTER_MANAGER_ROLE` and `MASTER_ROLE` can be treated as the same. More explanation: * New node will have "cluster_manager", "data", and "ingest" roles by default. Which means the default value of setting "node.roles" will be `["cluster_manager","data","ingest"]`, instead of `["master","data","ingest"]` * "cluster_manager" role will be treated as "master" role in the OpenSearch node of previous versions. * "cluster_manager” role and "master" role have got the same abbreviation name: "m" Signed-off-by: Tianli Feng --- .../routing/allocation/Allocators.java | 2 +- .../main/java/org/opensearch/client/Node.java | 8 +-- .../test/cluster.stats/10_basic.yml | 19 +++++ .../test/nodes.info/10_basic.yml | 32 ++++++++- .../admin/cluster/stats/ClusterStatsIT.java | 4 +- .../org/opensearch/env/NodeEnvironmentIT.java | 2 +- .../cluster/stats/ClusterStatsNodes.java | 9 ++- .../cluster/node/DiscoveryNode.java | 20 +++--- .../cluster/node/DiscoveryNodeRole.java | 70 ++++++++++++++++++- .../cluster/node/DiscoveryNodes.java | 19 ++++- .../org/opensearch/env/NodeEnvironment.java | 2 +- .../org/opensearch/node/NodeRoleSettings.java | 6 +- .../repositories/RepositoriesService.java | 3 +- ...AddVotingConfigExclusionsRequestTests.java | 30 ++++---- ...tAddVotingConfigExclusionsActionTests.java | 2 +- .../shrink/TransportResizeActionTests.java | 2 +- .../TransportMultiSearchActionTests.java | 2 +- .../TransportMasterNodeActionTests.java | 4 +- .../nodes/TransportNodesActionTests.java | 2 + .../cluster/ClusterChangedEventTests.java | 6 +- .../ClusterBootstrapServiceTests.java | 6 +- .../ClusterFormationFailureHelperTests.java | 4 +- .../coordination/CoordinatorTests.java | 2 +- .../cluster/coordination/NodeJoinTests.java | 4 +- .../health/ClusterHealthAllocationTests.java | 4 +- .../metadata/AutoExpandReplicasTests.java | 14 ++-- .../MetadataCreateIndexServiceTests.java | 2 +- .../metadata/TemplateUpgradeServiceTests.java | 2 +- .../node/DiscoveryNodeRoleSettingTests.java | 6 ++ .../cluster/node/DiscoveryNodeRoleTests.java | 10 +++ .../cluster/node/DiscoveryNodeTests.java | 6 ++ .../cluster/node/DiscoveryNodesTests.java | 9 +++ .../DelayedAllocationServiceTests.java | 2 +- .../routing/OperationRoutingTests.java | 2 +- .../allocation/AllocationCommandsTests.java | 10 ++- .../allocation/FailedNodeRoutingTests.java | 2 +- .../decider/DiskThresholdDeciderTests.java | 4 +- ...storeInProgressAllocationDeciderTests.java | 2 +- .../opensearch/env/NodeEnvironmentTests.java | 2 +- .../env/NodeRepurposeCommandTests.java | 2 +- .../gateway/ClusterStateUpdatersTests.java | 4 +- .../GatewayMetaStatePersistedStateTests.java | 2 +- ...ClusterStateServiceRandomUpdatesTests.java | 2 +- .../node/NodeRoleSettingsTests.java | 57 +++++++++++++++ .../PersistentTasksClusterServiceTests.java | 2 +- .../snapshots/SnapshotResiliencyTests.java | 2 +- .../SniffConnectionStrategyTests.java | 8 +-- .../cluster/OpenSearchAllocationTestCase.java | 2 +- .../CoordinationStateTestCluster.java | 6 +- .../opensearch/test/InternalTestCluster.java | 8 +-- .../java/org/opensearch/test/NodeRoles.java | 13 +++- .../test/test/InternalTestClusterTests.java | 16 +++-- 52 files changed, 356 insertions(+), 105 deletions(-) create mode 100644 server/src/test/java/org/opensearch/node/NodeRoleSettingsTests.java diff --git a/benchmarks/src/main/java/org/opensearch/benchmark/routing/allocation/Allocators.java b/benchmarks/src/main/java/org/opensearch/benchmark/routing/allocation/Allocators.java index 7c00fa5abb53f..d700b9dab2cf3 100644 --- a/benchmarks/src/main/java/org/opensearch/benchmark/routing/allocation/Allocators.java +++ b/benchmarks/src/main/java/org/opensearch/benchmark/routing/allocation/Allocators.java @@ -111,7 +111,7 @@ public static DiscoveryNode newNode(String nodeId, Map attribute nodeId, new TransportAddress(TransportAddress.META_ADDRESS, portGenerator.incrementAndGet()), attributes, - Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE), + Sets.newHashSet(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE), Version.CURRENT ); } diff --git a/client/rest/src/main/java/org/opensearch/client/Node.java b/client/rest/src/main/java/org/opensearch/client/Node.java index 41c2926a7d54d..c982ae8eb931f 100644 --- a/client/rest/src/main/java/org/opensearch/client/Node.java +++ b/client/rest/src/main/java/org/opensearch/client/Node.java @@ -210,21 +210,21 @@ public Roles(final Set roles) { } /** - * Teturns whether or not the node could be elected master. + * Returns whether or not the node could be elected master. */ public boolean isMasterEligible() { - return roles.contains("master"); + return roles.contains("master") || roles.contains("cluster_manager"); } /** - * Teturns whether or not the node stores data. + * Returns whether or not the node stores data. */ public boolean isData() { return roles.contains("data"); } /** - * Teturns whether or not the node runs ingest pipelines. + * Returns whether or not the node runs ingest pipelines. */ public boolean isIngest() { return roles.contains("ingest"); diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.stats/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.stats/10_basic.yml index a0432fa7aa558..6e149b297d843 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.stats/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.stats/10_basic.yml @@ -91,3 +91,22 @@ cluster.stats: {} - is_true: nodes.packaging_types + +--- +"get cluster stats nodes count with both master and cluster_manager": + - skip: + version: " - 1.4.99" + reason: "node role cluster_manager is added in 2.0.0" + + - do: + cluster.stats: {} + + - set: + nodes.count.cluster_manager: cluster_manager_count + + - gte: { nodes.count.total: 1} + - match: { nodes.count.cluster_manager: $cluster_manager_count } + - match: { nodes.count.master: $cluster_manager_count } + - gte: { nodes.count.data: 1} + - gte: { nodes.count.ingest: 0} + - gte: { nodes.count.coordinating_only: 0} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/nodes.info/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/nodes.info/10_basic.yml index 2a4bbfe0a20ba..c779cb80d13b3 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/nodes.info/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/nodes.info/10_basic.yml @@ -12,14 +12,24 @@ setup: - is_true: cluster_name --- -"node_info role test": +"node_info role test - before 2.0.0": - skip: - version: " - 7.7.99" + version: " - 7.7.99 , 2.0.0 - " reason: "node roles were not sorted before 7.8.0" + features: node_selector - do: nodes.info: {} + node_selector: + # Only send request to nodes in <2.0 versions, especially during ':qa:mixed-cluster:v1.x.x#mixedClusterTest'. + # Because YAML REST test takes the minimum OpenSearch version in the cluster to apply the filter in 'skip' section, + # see OpenSearchClientYamlSuiteTestCase#initAndResetContext() for detail. + # During 'mixedClusterTest', the cluster can be mixed with nodes in 1.x and 2.x versions, + # so node_selector is required, and only filtering version in 'skip' is not enough. + version: "1.0.0 - 1.4.99" + - set: + # Note: It will only stash the first node_id in the api response. nodes._arbitrary_key_: node_id - is_true: nodes.$node_id.roles @@ -29,3 +39,21 @@ setup: - match: { nodes.$node_id.roles.2: "master" } - match: { nodes.$node_id.roles.3: "remote_cluster_client" } +--- +"node_info role test": + - skip: + version: " - 1.4.99" + reason: "node role cluster_manager is added in 2.0.0" + + - do: + nodes.info: {} + + - set: + nodes._arbitrary_key_: node_id + + - is_true: nodes.$node_id.roles + # the roles output is sorted + - match: { nodes.$node_id.roles.0: "cluster_manager" } + - match: { nodes.$node_id.roles.1: "data" } + - match: { nodes.$node_id.roles.2: "ingest" } + - match: { nodes.$node_id.roles.3: "remote_cluster_client" } diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/stats/ClusterStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/stats/ClusterStatsIT.java index 72f34133067ee..5b48268dfa89f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/stats/ClusterStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/stats/ClusterStatsIT.java @@ -85,6 +85,7 @@ public void testNodeCounts() { Map expectedCounts = new HashMap<>(); expectedCounts.put(DiscoveryNodeRole.DATA_ROLE.roleName(), 1); expectedCounts.put(DiscoveryNodeRole.MASTER_ROLE.roleName(), 1); + expectedCounts.put(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), 1); expectedCounts.put(DiscoveryNodeRole.INGEST_ROLE.roleName(), 1); expectedCounts.put(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE.roleName(), 1); expectedCounts.put(ClusterStatsNodes.Counts.COORDINATING_ONLY, 0); @@ -106,7 +107,7 @@ public void testNodeCounts() { roles.add(DiscoveryNodeRole.INGEST_ROLE); } if (isMasterNode) { - roles.add(DiscoveryNodeRole.MASTER_ROLE); + roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } if (isRemoteClusterClientNode) { roles.add(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE); @@ -129,6 +130,7 @@ public void testNodeCounts() { } if (isMasterNode) { incrementCountForRole(DiscoveryNodeRole.MASTER_ROLE.roleName(), expectedCounts); + incrementCountForRole(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), expectedCounts); } if (isRemoteClusterClientNode) { incrementCountForRole(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE.roleName(), expectedCounts); diff --git a/server/src/internalClusterTest/java/org/opensearch/env/NodeEnvironmentIT.java b/server/src/internalClusterTest/java/org/opensearch/env/NodeEnvironmentIT.java index 0bebcce27f975..83c103bd82738 100644 --- a/server/src/internalClusterTest/java/org/opensearch/env/NodeEnvironmentIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/env/NodeEnvironmentIT.java @@ -95,7 +95,7 @@ public Settings onNodeStopped(String nodeName) { }) ); if (writeDanglingIndices) { - assertThat(ex.getMessage(), startsWith("node does not have the data and master roles but has index metadata")); + assertThat(ex.getMessage(), startsWith("node does not have the data and cluster_manager roles but has index metadata")); } else { assertThat(ex.getMessage(), startsWith("node does not have the data role but has shard data")); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsNodes.java b/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsNodes.java index 0ae7ebd17aaa5..fbca94780f827 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsNodes.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsNodes.java @@ -223,7 +223,14 @@ private Counts(final List nodeInfos) { roles.merge(COORDINATING_ONLY, 1, Integer::sum); } else { for (DiscoveryNodeRole role : nodeInfo.getNode().getRoles()) { - roles.merge(role.roleName(), 1, Integer::sum); + // TODO: Remove the 'if' condition and only keep the statement in 'else' after removing MASTER_ROLE. + // As of 2.0, CLUSTER_MANAGER_ROLE is added, and it should be taken as MASTER_ROLE + if (role.isClusterManager()) { + roles.merge(DiscoveryNodeRole.MASTER_ROLE.roleName(), 1, Integer::sum); + roles.merge(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), 1, Integer::sum); + } else { + roles.merge(role.roleName(), 1, Integer::sum); + } } } } diff --git a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java index 9fa49ec93d307..6bd943c5e1d0d 100644 --- a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java +++ b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java @@ -94,7 +94,7 @@ public static boolean hasRole(final Settings settings, final DiscoveryNodeRole r } public static boolean isMasterNode(Settings settings) { - return hasRole(settings, DiscoveryNodeRole.MASTER_ROLE); + return hasRole(settings, DiscoveryNodeRole.MASTER_ROLE) || hasRole(settings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } /** @@ -343,7 +343,7 @@ public DiscoveryNode(StreamInput in) throws IOException { final LegacyRole legacyRole = in.readEnum(LegacyRole.class); switch (legacyRole) { case MASTER: - roles.add(DiscoveryNodeRole.MASTER_ROLE); + roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); break; case DATA: roles.add(DiscoveryNodeRole.DATA_ROLE); @@ -390,11 +390,11 @@ public void writeTo(StreamOutput out) throws IOException { .collect(Collectors.toList()); out.writeVInt(rolesToWrite.size()); for (final DiscoveryNodeRole role : rolesToWrite) { - if (role == DiscoveryNodeRole.MASTER_ROLE) { + if (role.isClusterManager()) { out.writeEnum(LegacyRole.MASTER); - } else if (role == DiscoveryNodeRole.DATA_ROLE) { + } else if (role.equals(DiscoveryNodeRole.DATA_ROLE)) { out.writeEnum(LegacyRole.DATA); - } else if (role == DiscoveryNodeRole.INGEST_ROLE) { + } else if (role.equals(DiscoveryNodeRole.INGEST_ROLE)) { out.writeEnum(LegacyRole.INGEST); } } @@ -456,7 +456,7 @@ public boolean isDataNode() { * Can this node become master or not. */ public boolean isMasterNode() { - return roles.contains(DiscoveryNodeRole.MASTER_ROLE); + return roles.contains(DiscoveryNodeRole.MASTER_ROLE) || roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } /** @@ -591,7 +591,11 @@ public static void setAdditionalRoles(final Set additionalRol + "], roles by name abbreviation [" + roleNameAbbreviationToPossibleRoles + "]"; - roleMap = roleNameToPossibleRoles; + // TODO: Remove the Map 'roleNameToPossibleRolesWithMaster' and let 'roleMap = roleNameToPossibleRoles', after removing MASTER_ROLE. + // It's used to allow CLUSTER_MANAGER_ROLE that introduced in 2.0, having the same abbreviation name with MASTER_ROLE. + final Map roleNameToPossibleRolesWithMaster = new HashMap<>(roleNameToPossibleRoles); + roleNameToPossibleRolesWithMaster.put(DiscoveryNodeRole.MASTER_ROLE.roleName(), DiscoveryNodeRole.MASTER_ROLE); + roleMap = Collections.unmodifiableMap(roleNameToPossibleRolesWithMaster); } public static Set getPossibleRoleNames() { @@ -599,7 +603,7 @@ public static Set getPossibleRoleNames() { } /** - * Enum that holds all the possible roles that that a node can fulfill in a cluster. + * Enum that holds all the possible roles that a node can fulfill in a cluster. * Each role has its name and a corresponding abbreviation used by cat apis. */ private enum LegacyRole { diff --git a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java index fb1cfb24166c4..cff1a77f4cdb7 100644 --- a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java +++ b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java @@ -34,6 +34,7 @@ import org.opensearch.LegacyESVersion; import org.opensearch.Version; +import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Setting.Property; import org.opensearch.common.settings.Settings; @@ -41,6 +42,8 @@ import java.util.Arrays; import java.util.Collections; +import java.util.List; +import java.util.Locale; import java.util.Objects; import java.util.SortedSet; import java.util.TreeSet; @@ -50,6 +53,10 @@ */ public abstract class DiscoveryNodeRole implements Comparable { + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DiscoveryNodeRole.class); + public static final String MASTER_ROLE_DEPRECATION_MESSAGE = + "Assigning [master] role in setting [node.roles] is deprecated. To promote inclusive language, please use [cluster_manager] role instead."; + private final String roleName; /** @@ -129,6 +136,13 @@ public DiscoveryNodeRole getCompatibilityRole(Version nodeVersion) { return this; } + /** + * Validate the role is compatible with the other roles in the list, when assigning the list of roles to a node. + * An {@link IllegalArgumentException} is expected to be thrown, if the role can't coexist with the other roles. + * @param roles a {@link List} of {@link DiscoveryNodeRole} that a node is going to have + */ + public void validateRole(List roles) {}; + @Override public final boolean equals(Object o) { if (this == o) return true; @@ -193,15 +207,60 @@ public Setting legacySetting() { /** * Represents the role for a master-eligible node. + * @deprecated As of 2.0, because promoting inclusive language, replaced by {@link #CLUSTER_MANAGER_ROLE} */ + @Deprecated public static final DiscoveryNodeRole MASTER_ROLE = new DiscoveryNodeRole("master", "m") { + @Override + public Setting legacySetting() { + // copy the setting here so we can mark it private in org.opensearch.node.Node + // As of 2.0, set the default value to 'false', so that MASTER_ROLE isn't added as a default value of NODE_ROLES_SETTING + return Setting.boolSetting("node.master", false, Property.Deprecated, Property.NodeScope); + } + + @Override + public void validateRole(List roles) { + deprecationLogger.deprecate("node_role_master", MASTER_ROLE_DEPRECATION_MESSAGE); + } + + }; + + /** + * Represents the role for a cluster-manager-eligible node. + */ + public static final DiscoveryNodeRole CLUSTER_MANAGER_ROLE = new DiscoveryNodeRole("cluster_manager", "m") { + @Override public Setting legacySetting() { // copy the setting here so we can mark it private in org.opensearch.node.Node return Setting.boolSetting("node.master", true, Property.Deprecated, Property.NodeScope); } + @Override + public DiscoveryNodeRole getCompatibilityRole(Version nodeVersion) { + if (nodeVersion.onOrAfter(Version.V_2_0_0)) { + return this; + } else { + return DiscoveryNodeRole.MASTER_ROLE; + } + } + + @Override + public void validateRole(List roles) { + if (roles.contains(DiscoveryNodeRole.MASTER_ROLE)) { + throw new IllegalArgumentException( + String.format( + Locale.ROOT, + "The two roles [%s, %s] can not be assigned together to a node. %s", + DiscoveryNodeRole.MASTER_ROLE.roleName(), + DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), + MASTER_ROLE_DEPRECATION_MESSAGE + ) + ); + } + } + }; public static final DiscoveryNodeRole REMOTE_CLUSTER_CLIENT_ROLE = new DiscoveryNodeRole("remote_cluster_client", "r") { @@ -223,7 +282,7 @@ public Setting legacySetting() { * The built-in node roles. */ public static SortedSet BUILT_IN_ROLES = Collections.unmodifiableSortedSet( - new TreeSet<>(Arrays.asList(DATA_ROLE, INGEST_ROLE, MASTER_ROLE, REMOTE_CLUSTER_CLIENT_ROLE)) + new TreeSet<>(Arrays.asList(DATA_ROLE, INGEST_ROLE, CLUSTER_MANAGER_ROLE, REMOTE_CLUSTER_CLIENT_ROLE)) ); /** @@ -262,4 +321,13 @@ public Setting legacySetting() { } + /** + * Check if the role is {@link #CLUSTER_MANAGER_ROLE} or {@link #MASTER_ROLE}. + * @deprecated As of 2.0, because promoting inclusive language. MASTER_ROLE is deprecated. + * @return true if the node role is{@link #CLUSTER_MANAGER_ROLE} or {@link #MASTER_ROLE} + */ + @Deprecated + public boolean isClusterManager() { + return this.equals(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE) || this.equals(DiscoveryNodeRole.MASTER_ROLE); + } } diff --git a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java index d6e2f129f0ed8..1097f3bc245ac 100644 --- a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java +++ b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java @@ -370,7 +370,7 @@ public DiscoveryNode resolveNode(String node) { * Works by tracking the current set of nodes and applying each node specification in sequence. The set starts out empty and each node * specification may either add or remove nodes. For instance: * - * - _local, _master and _all respectively add to the subset the local node, the currently-elected master, and all the nodes + * - _local, _cluster_manager (_master) and _all respectively add to the subset the local node, the currently-elected cluster_manager, and all the nodes * - node IDs, names, hostnames and IP addresses all add to the subset any nodes which match * - a wildcard-based pattern of the form "attr*:value*" adds to the subset all nodes with a matching attribute with a matching value * - role:true adds to the subset all nodes with a matching role @@ -393,7 +393,7 @@ public String[] resolveNodes(String... nodes) { if (localNodeId != null) { resolvedNodesIds.add(localNodeId); } - } else if (nodeId.equals("_master")) { + } else if (nodeId.equals("_master") || nodeId.equals("_cluster_manager")) { String masterNodeId = getMasterNodeId(); if (masterNodeId != null) { resolvedNodesIds.add(masterNodeId); @@ -419,7 +419,7 @@ public String[] resolveNodes(String... nodes) { } else { resolvedNodesIds.removeAll(dataNodes.keys()); } - } else if (DiscoveryNodeRole.MASTER_ROLE.roleName().equals(matchAttrName)) { + } else if (roleNameIsClusterManager(matchAttrName)) { if (Booleans.parseBoolean(matchAttrValue, true)) { resolvedNodesIds.addAll(masterNodes.keys()); } else { @@ -797,4 +797,17 @@ public boolean isLocalNodeElectedMaster() { return masterNodeId != null && masterNodeId.equals(localNodeId); } } + + /** + * Check if the given name of the node role is 'cluster_manger' or 'master'. + * The method is added for {@link #resolveNodes} to keep the code clear, when support the both above roles. + * @deprecated As of 2.0, because promoting inclusive language. MASTER_ROLE is deprecated. + * @param matchAttrName a given String for a name of the node role. + * @return true if the given roleName is 'cluster_manger' or 'master' + */ + @Deprecated + private boolean roleNameIsClusterManager(String matchAttrName) { + return DiscoveryNodeRole.MASTER_ROLE.roleName().equals(matchAttrName) + || DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName().equals(matchAttrName); + } } diff --git a/server/src/main/java/org/opensearch/env/NodeEnvironment.java b/server/src/main/java/org/opensearch/env/NodeEnvironment.java index 06109e7fcdc5b..555ca990b736d 100644 --- a/server/src/main/java/org/opensearch/env/NodeEnvironment.java +++ b/server/src/main/java/org/opensearch/env/NodeEnvironment.java @@ -1138,7 +1138,7 @@ private void ensureNoIndexMetadata(final NodePath[] nodePaths) throws IOExceptio Locale.ROOT, "node does not have the %s and %s roles but has index metadata: %s. Use 'opensearch-node repurpose' tool to clean up", DiscoveryNodeRole.DATA_ROLE.roleName(), - DiscoveryNodeRole.MASTER_ROLE.roleName(), + DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), indexMetadataPaths ); throw new IllegalStateException(message); diff --git a/server/src/main/java/org/opensearch/node/NodeRoleSettings.java b/server/src/main/java/org/opensearch/node/NodeRoleSettings.java index 1e29f22b140f9..d690cfa4caa69 100644 --- a/server/src/main/java/org/opensearch/node/NodeRoleSettings.java +++ b/server/src/main/java/org/opensearch/node/NodeRoleSettings.java @@ -51,7 +51,11 @@ public class NodeRoleSettings { .filter(role -> role.isEnabledByDefault(settings)) .map(DiscoveryNodeRole::roleName) .collect(Collectors.toList()), - roles -> {}, + roles -> { + for (DiscoveryNodeRole role : roles) { + role.validateRole(roles); + } + }, Property.NodeScope ); diff --git a/server/src/main/java/org/opensearch/repositories/RepositoriesService.java b/server/src/main/java/org/opensearch/repositories/RepositoriesService.java index ec5cb02c32379..e7c5804f458a0 100644 --- a/server/src/main/java/org/opensearch/repositories/RepositoriesService.java +++ b/server/src/main/java/org/opensearch/repositories/RepositoriesService.java @@ -346,8 +346,9 @@ protected void doRun() { }); } + // Note: "voting_only" role has not been implemented yet, so the method always returns false. static boolean isDedicatedVotingOnlyNode(Set roles) { - return roles.contains(DiscoveryNodeRole.MASTER_ROLE) + return roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE) && roles.contains(DiscoveryNodeRole.DATA_ROLE) == false && roles.stream().anyMatch(role -> role.roleName().equals("voting_only")); } diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequestTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequestTests.java index a1aa38017a808..8da65ba13b9cb 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequestTests.java @@ -113,7 +113,7 @@ public void testResolve() { "local", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion localNodeExclusion = new VotingConfigExclusion(localNode); @@ -122,7 +122,7 @@ public void testResolve() { "other1", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion otherNode1Exclusion = new VotingConfigExclusion(otherNode1); @@ -131,7 +131,7 @@ public void testResolve() { "other2", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion otherNode2Exclusion = new VotingConfigExclusion(otherNode2); @@ -238,7 +238,7 @@ public void testResolveByNodeIds() { "nodeId1", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion node1Exclusion = new VotingConfigExclusion(node1); @@ -248,7 +248,7 @@ public void testResolveByNodeIds() { "nodeId2", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion node2Exclusion = new VotingConfigExclusion(node2); @@ -258,7 +258,7 @@ public void testResolveByNodeIds() { "nodeId3", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); @@ -298,7 +298,7 @@ public void testResolveByNodeNames() { "nodeId1", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion node1Exclusion = new VotingConfigExclusion(node1); @@ -308,7 +308,7 @@ public void testResolveByNodeNames() { "nodeId2", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion node2Exclusion = new VotingConfigExclusion(node2); @@ -318,7 +318,7 @@ public void testResolveByNodeNames() { "nodeId3", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); @@ -348,7 +348,7 @@ public void testResolveRemoveExistingVotingConfigExclusions() { "nodeId1", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); @@ -357,7 +357,7 @@ public void testResolveRemoveExistingVotingConfigExclusions() { "nodeId2", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion node2Exclusion = new VotingConfigExclusion(node2); @@ -367,7 +367,7 @@ public void testResolveRemoveExistingVotingConfigExclusions() { "nodeId3", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); @@ -399,7 +399,7 @@ public void testResolveAndCheckMaximum() { "local", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion localNodeExclusion = new VotingConfigExclusion(localNode); @@ -408,7 +408,7 @@ public void testResolveAndCheckMaximum() { "other1", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion otherNode1Exclusion = new VotingConfigExclusion(otherNode1); @@ -417,7 +417,7 @@ public void testResolveAndCheckMaximum() { "other2", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion otherNode2Exclusion = new VotingConfigExclusion(otherNode2); diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java index b4540a66c9264..a570db040a805 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java @@ -119,7 +119,7 @@ private static DiscoveryNode makeDiscoveryNode(String name) { name, buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/shrink/TransportResizeActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/shrink/TransportResizeActionTests.java index 37cdda6c365b8..e4b79ac54f8fd 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/shrink/TransportResizeActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/shrink/TransportResizeActionTests.java @@ -278,7 +278,7 @@ public void testShrinkIndexSettings() { private DiscoveryNode newNode(String nodeId) { final Set roles = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE)) + new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE)) ); return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT); } diff --git a/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java b/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java index 05f9ef8baed29..09ab2438bd106 100644 --- a/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java +++ b/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java @@ -263,7 +263,7 @@ public void testDefaultMaxConcurrentSearches() { "master", buildNewFakeTransportAddress(), Collections.emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ) ); diff --git a/server/src/test/java/org/opensearch/action/support/master/TransportMasterNodeActionTests.java b/server/src/test/java/org/opensearch/action/support/master/TransportMasterNodeActionTests.java index 60dcbc15b96c8..a8ad356e947b5 100644 --- a/server/src/test/java/org/opensearch/action/support/master/TransportMasterNodeActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/master/TransportMasterNodeActionTests.java @@ -121,14 +121,14 @@ public void setUp() throws Exception { "local_node", buildNewFakeTransportAddress(), Collections.emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); remoteNode = new DiscoveryNode( "remote_node", buildNewFakeTransportAddress(), Collections.emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); allNodes = new DiscoveryNode[] { localNode, remoteNode }; diff --git a/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java b/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java index a8755df6b5daa..53ebceb25510a 100644 --- a/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java @@ -172,7 +172,9 @@ private List mockList(Supplier supplier, int size) { private enum NodeSelector { LOCAL("_local"), ELECTED_MASTER("_master"), + // TODO: Remove this element after removing DiscoveryNodeRole.MASTER_ROLE MASTER_ELIGIBLE("master:true"), + CLUSTER_MANAGER_ELIGIBLE("cluster_manager:true"), DATA("data:true"), CUSTOM_ATTRIBUTE("attr:value"); diff --git a/server/src/test/java/org/opensearch/cluster/ClusterChangedEventTests.java b/server/src/test/java/org/opensearch/cluster/ClusterChangedEventTests.java index 4f68358b15b3d..49d4a8baf0a1c 100644 --- a/server/src/test/java/org/opensearch/cluster/ClusterChangedEventTests.java +++ b/server/src/test/java/org/opensearch/cluster/ClusterChangedEventTests.java @@ -447,17 +447,17 @@ private static DiscoveryNodes createDiscoveryNodes(final int numNodes, final boo if (i == 0) { // the master node builder.masterNodeId(nodeId); - roles.add(DiscoveryNodeRole.MASTER_ROLE); + roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } else if (i == 1) { // the alternate master node - roles.add(DiscoveryNodeRole.MASTER_ROLE); + roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } else if (i == 2) { // we need at least one data node roles.add(DiscoveryNodeRole.DATA_ROLE); } else { // remaining nodes can be anything (except for master) if (randomBoolean()) { - roles.add(DiscoveryNodeRole.MASTER_ROLE); + roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } if (randomBoolean()) { roles.add(DiscoveryNodeRole.DATA_ROLE); diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java index d8007933c2559..079b31f31f599 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java @@ -112,7 +112,7 @@ private DiscoveryNode newDiscoveryNode(String nodeName) { randomAlphaOfLength(10), buildNewFakeTransportAddress(), emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); } @@ -522,7 +522,7 @@ public void testCancelsBootstrapIfNodeMatchesMultipleRequirements() { randomAlphaOfLength(10), buildNewFakeTransportAddress(), emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ), new DiscoveryNode( @@ -530,7 +530,7 @@ public void testCancelsBootstrapIfNodeMatchesMultipleRequirements() { randomAlphaOfLength(10), otherNode1.getAddress(), emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ) ).collect(Collectors.toList()) diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java index 4288d4eb5d53b..13cdc640008cb 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java @@ -287,7 +287,7 @@ public void testDescriptionOnUnhealthyNodes() { "local", buildNewFakeTransportAddress(), emptyMap(), - org.opensearch.common.collect.Set.of(DiscoveryNodeRole.MASTER_ROLE), + org.opensearch.common.collect.Set.of(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); clusterState = ClusterState.builder(ClusterName.DEFAULT) @@ -825,7 +825,7 @@ public void testDescriptionAfterBootstrapping() { emptyMap(), new HashSet<>( randomSubsetOf(DiscoveryNodeRole.BUILT_IN_ROLES).stream() - .filter(r -> r != DiscoveryNodeRole.MASTER_ROLE) + .filter(r -> r != DiscoveryNodeRole.CLUSTER_MANAGER_ROLE) .collect(Collectors.toList()) ), Version.CURRENT diff --git a/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java b/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java index 33d522e196d9b..1cdea588564c4 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java @@ -1789,7 +1789,7 @@ private ClusterState buildNewClusterStateWithVotingConfigExclusion( "resolvableNodeId", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ) ) diff --git a/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java b/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java index bccd94e2c40bf..3b309908a1df0 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java @@ -248,7 +248,7 @@ protected DiscoveryNode newNode(int i) { protected DiscoveryNode newNode(int i, boolean master) { final Set roles; if (master) { - roles = singleton(DiscoveryNodeRole.MASTER_ROLE); + roles = singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } else { roles = Collections.emptySet(); } @@ -492,7 +492,7 @@ public void testJoinUpdateVotingConfigExclusion() throws Exception { "newNodeId", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); long newTerm = initialTerm + randomLongBetween(1, 10); diff --git a/server/src/test/java/org/opensearch/cluster/health/ClusterHealthAllocationTests.java b/server/src/test/java/org/opensearch/cluster/health/ClusterHealthAllocationTests.java index 2e4bba0ff1c7b..2f05297146f8e 100644 --- a/server/src/test/java/org/opensearch/cluster/health/ClusterHealthAllocationTests.java +++ b/server/src/test/java/org/opensearch/cluster/health/ClusterHealthAllocationTests.java @@ -87,7 +87,9 @@ public void testClusterHealth() { private ClusterState addNode(ClusterState clusterState, String nodeName, boolean isMaster) { DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.getNodes()); - nodeBuilder.add(newNode(nodeName, Collections.singleton(isMaster ? DiscoveryNodeRole.MASTER_ROLE : DiscoveryNodeRole.DATA_ROLE))); + nodeBuilder.add( + newNode(nodeName, Collections.singleton(isMaster ? DiscoveryNodeRole.CLUSTER_MANAGER_ROLE : DiscoveryNodeRole.DATA_ROLE)) + ); return ClusterState.builder(clusterState).nodes(nodeBuilder).build(); } diff --git a/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java b/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java index 13bc108591f7f..d6c62e4bb0903 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java @@ -146,7 +146,7 @@ public void testAutoExpandWhenNodeLeavesAndPossiblyRejoins() throws InterruptedE try { List allNodes = new ArrayList<>(); - DiscoveryNode localNode = createNode(DiscoveryNodeRole.MASTER_ROLE); // local node is the master + DiscoveryNode localNode = createNode(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); // local node is the master allNodes.add(localNode); int numDataNodes = randomIntBetween(3, 5); List dataNodes = new ArrayList<>(numDataNodes); @@ -245,7 +245,7 @@ public void testOnlyAutoExpandAllocationFilteringAfterAllNodesUpgraded() { List allNodes = new ArrayList<>(); DiscoveryNode oldNode = createNode( VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, LegacyESVersion.V_7_5_1), - DiscoveryNodeRole.MASTER_ROLE, + DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE ); // local node is the master allNodes.add(oldNode); @@ -266,11 +266,11 @@ public void testOnlyAutoExpandAllocationFilteringAfterAllNodesUpgraded() { state = cluster.reroute(state, new ClusterRerouteRequest()); } - DiscoveryNode newNode = createNode(LegacyESVersion.V_7_6_0, DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE); // local - // node - // is - // the - // master + DiscoveryNode newNode = createNode( + LegacyESVersion.V_7_6_0, + DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, + DiscoveryNodeRole.DATA_ROLE + ); // local node is the cluster_manager state = cluster.addNodes(state, Collections.singletonList(newNode)); diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java index 19f6a516ca83a..5bea69c5bbd66 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java @@ -582,7 +582,7 @@ private void runPrepareResizeIndexSettingsTest( private DiscoveryNode newNode(String nodeId) { final Set roles = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE)) + new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE)) ); return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT); } diff --git a/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java index e4692fe7d21f7..1e52fa380793e 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java @@ -261,7 +261,7 @@ public void testUpdateTemplates() { } private static final Set MASTER_DATA_ROLES = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE)) + new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE)) ); @SuppressWarnings("unchecked") diff --git a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleSettingTests.java b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleSettingTests.java index 006968a2f2ac2..55c518c62973e 100644 --- a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleSettingTests.java +++ b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleSettingTests.java @@ -56,9 +56,15 @@ public void testIsIngestNode() { } public void testIsMasterNode() { + // It's used to add MASTER_ROLE into 'roleMap', because MASTER_ROLE is removed from DiscoveryNodeRole.BUILT_IN_ROLES in 2.0. + DiscoveryNode.setAdditionalRoles(Collections.emptySet()); runRoleTest(DiscoveryNode::isMasterNode, DiscoveryNodeRole.MASTER_ROLE); } + public void testIsClusterManagerNode() { + runRoleTest(DiscoveryNode::isMasterNode, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); + } + public void testIsRemoteClusterClient() { runRoleTest(DiscoveryNode::isRemoteClusterClient, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE); } diff --git a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleTests.java b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleTests.java index 76f9843e386b8..d1acec2832b7c 100644 --- a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleTests.java +++ b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleTests.java @@ -128,4 +128,14 @@ public void testUnknownRoleIsDistinctFromKnownRoles() { assertNotEquals(buildInRole.toString(), unknownDataRole.toString()); } } + + /** + * Validate the method can identify the role as cluster-manager. + * Remove along with MASTER_ROLE. + */ + public void testIsClusterManager() { + assertTrue(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.isClusterManager()); + assertTrue(DiscoveryNodeRole.MASTER_ROLE.isClusterManager()); + assertFalse(randomFrom(DiscoveryNodeRole.DATA_ROLE.isClusterManager(), DiscoveryNodeRole.INGEST_ROLE.isClusterManager())); + } } diff --git a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeTests.java b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeTests.java index 39a3381bede26..933d9d5f825e9 100644 --- a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeTests.java +++ b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeTests.java @@ -174,6 +174,12 @@ public void testDiscoveryNodeIsRemoteClusterClientUnset() { runTestDiscoveryNodeIsRemoteClusterClient(nonRemoteClusterClientNode(), false); } + // TODO: Remove the test along with MASTER_ROLE. It is added in 2.0, along with the introduction of CLUSTER_MANAGER_ROLE. + public void testSetAdditionalRolesCanAddDeprecatedMasterRole() { + DiscoveryNode.setAdditionalRoles(Collections.emptySet()); + assertTrue(DiscoveryNode.getPossibleRoleNames().contains(DiscoveryNodeRole.MASTER_ROLE.roleName())); + } + private void runTestDiscoveryNodeIsRemoteClusterClient(final Settings settings, final boolean expected) { final DiscoveryNode node = DiscoveryNode.createLocal(settings, new TransportAddress(TransportAddress.META_ADDRESS, 9200), "node"); assertThat(node.isRemoteClusterClient(), equalTo(expected)); diff --git a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java index 69cecade5b745..aff9e1cfe7a8c 100644 --- a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java +++ b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java @@ -361,6 +361,7 @@ Set matchingNodeIds(DiscoveryNodes nodes) { return Collections.singleton(nodes.getMasterNodeId()); } }, + // TODO: Remove this element after removing DiscoveryNodeRole.MASTER_ROLE MASTER_ELIGIBLE(DiscoveryNodeRole.MASTER_ROLE.roleName() + ":true") { @Override Set matchingNodeIds(DiscoveryNodes nodes) { @@ -369,6 +370,14 @@ Set matchingNodeIds(DiscoveryNodes nodes) { return ids; } }, + CLUSTER_MANAGER_ELIGIBLE(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName() + ":true") { + @Override + Set matchingNodeIds(DiscoveryNodes nodes) { + Set ids = new HashSet<>(); + nodes.getMasterNodes().keysIt().forEachRemaining(ids::add); + return ids; + } + }, DATA(DiscoveryNodeRole.DATA_ROLE.roleName() + ":true") { @Override Set matchingNodeIds(DiscoveryNodes nodes) { diff --git a/server/src/test/java/org/opensearch/cluster/routing/DelayedAllocationServiceTests.java b/server/src/test/java/org/opensearch/cluster/routing/DelayedAllocationServiceTests.java index 1f79d52d84d74..1f45c5c1dfce4 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/DelayedAllocationServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/DelayedAllocationServiceTests.java @@ -262,7 +262,7 @@ public void testDelayedUnassignedScheduleRerouteAfterDelayedReroute() throws Exc .routingTable(RoutingTable.builder().addAsNew(metadata.index("short_delay")).addAsNew(metadata.index("long_delay")).build()) .nodes( DiscoveryNodes.builder() - .add(newNode("node0", singleton(DiscoveryNodeRole.MASTER_ROLE))) + .add(newNode("node0", singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))) .localNodeId("node0") .masterNodeId("node0") .add(newNode("node1")) diff --git a/server/src/test/java/org/opensearch/cluster/routing/OperationRoutingTests.java b/server/src/test/java/org/opensearch/cluster/routing/OperationRoutingTests.java index 7a5e24a7eeca2..d42c3e80c60c9 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/OperationRoutingTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/OperationRoutingTests.java @@ -778,7 +778,7 @@ private DiscoveryNode[] setupNodes() { "master", buildNewFakeTransportAddress(), Collections.emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); allNodes[i] = master; diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/AllocationCommandsTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/AllocationCommandsTests.java index 28599ea0b9baa..cda0f1afaf62c 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/AllocationCommandsTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/AllocationCommandsTests.java @@ -188,7 +188,7 @@ public void testAllocateCommand() { .add(newNode("node1")) .add(newNode("node2")) .add(newNode("node3")) - .add(newNode("node4", singleton(DiscoveryNodeRole.MASTER_ROLE))) + .add(newNode("node4", singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))) ) .build(); clusterState = allocation.reroute(clusterState, "reroute"); @@ -748,7 +748,9 @@ public void testMoveShardToNonDataNode() { "test2", buildNewFakeTransportAddress(), emptyMap(), - new HashSet<>(randomSubsetOf(new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.INGEST_ROLE)))), + new HashSet<>( + randomSubsetOf(new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.INGEST_ROLE))) + ), Version.CURRENT ); @@ -817,7 +819,9 @@ public void testMoveShardFromNonDataNode() { "test2", buildNewFakeTransportAddress(), emptyMap(), - new HashSet<>(randomSubsetOf(new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.INGEST_ROLE)))), + new HashSet<>( + randomSubsetOf(new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.INGEST_ROLE))) + ), Version.CURRENT ); diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/FailedNodeRoutingTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/FailedNodeRoutingTests.java index f871d74d3d1a5..f60497b4108b7 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/FailedNodeRoutingTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/FailedNodeRoutingTests.java @@ -230,7 +230,7 @@ private static Version getNodeVersion(ShardRouting shardRouting, ClusterState st public ClusterState randomInitialClusterState() { List allNodes = new ArrayList<>(); - DiscoveryNode localNode = createNode(DiscoveryNodeRole.MASTER_ROLE); // local node is the master + DiscoveryNode localNode = createNode(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); // local node is the master allNodes.add(localNode); // at least two nodes that have the data role so that we can allocate shards allNodes.add(createNode(DiscoveryNodeRole.DATA_ROLE)); diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java index 038dd2713bbf9..a2fcf14638d45 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java @@ -1078,7 +1078,7 @@ public void testForSingleDataNode() { "node1", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); DiscoveryNode discoveryNode2 = new DiscoveryNode( @@ -1227,7 +1227,7 @@ public void testWatermarksEnabledForSingleDataNode() { "master", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); DiscoveryNode dataNode = new DiscoveryNode( diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java index 8917b9793e621..5b05cb3afd83e 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java @@ -199,7 +199,7 @@ private ClusterState createInitialClusterState() { RoutingTable routingTable = RoutingTable.builder().addAsNew(metadata.index("test")).build(); DiscoveryNodes discoveryNodes = DiscoveryNodes.builder() - .add(newNode("master", Collections.singleton(DiscoveryNodeRole.MASTER_ROLE))) + .add(newNode("master", Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))) .localNodeId("master") .masterNodeId("master") .build(); diff --git a/server/src/test/java/org/opensearch/env/NodeEnvironmentTests.java b/server/src/test/java/org/opensearch/env/NodeEnvironmentTests.java index e6f0f2824b7d3..6f07d0de1e31d 100644 --- a/server/src/test/java/org/opensearch/env/NodeEnvironmentTests.java +++ b/server/src/test/java/org/opensearch/env/NodeEnvironmentTests.java @@ -602,7 +602,7 @@ private void verifyFailsOnMetadata(Settings settings, Path indexPath) { ); assertThat(ex.getMessage(), containsString(indexPath.resolve(MetadataStateFormat.STATE_DIR_NAME).toAbsolutePath().toString())); - assertThat(ex.getMessage(), startsWith("node does not have the data and master roles but has index metadata")); + assertThat(ex.getMessage(), startsWith("node does not have the data and cluster_manager roles but has index metadata")); } /** Converts an array of Strings to an array of Paths, adding an additional child if specified */ diff --git a/server/src/test/java/org/opensearch/env/NodeRepurposeCommandTests.java b/server/src/test/java/org/opensearch/env/NodeRepurposeCommandTests.java index 45ec6d8ebf75a..9897ad1a3650b 100644 --- a/server/src/test/java/org/opensearch/env/NodeRepurposeCommandTests.java +++ b/server/src/test/java/org/opensearch/env/NodeRepurposeCommandTests.java @@ -105,7 +105,7 @@ public void createNodePaths() throws IOException { dataNoMasterSettings = nonMasterNode(dataMasterSettings); noDataNoMasterSettings = removeRoles( dataMasterSettings, - Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE))) + Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))) ); noDataMasterSettings = masterNode(nonDataNode(dataMasterSettings)); diff --git a/server/src/test/java/org/opensearch/gateway/ClusterStateUpdatersTests.java b/server/src/test/java/org/opensearch/gateway/ClusterStateUpdatersTests.java index f6a8f1515002d..1f63dff04b3df 100644 --- a/server/src/test/java/org/opensearch/gateway/ClusterStateUpdatersTests.java +++ b/server/src/test/java/org/opensearch/gateway/ClusterStateUpdatersTests.java @@ -304,7 +304,7 @@ public void testSetLocalNode() { "node1", buildNewFakeTransportAddress(), Collections.emptyMap(), - Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE), + Sets.newHashSet(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); @@ -354,7 +354,7 @@ public void testHideStateIfNotRecovered() { "node1", buildNewFakeTransportAddress(), Collections.emptyMap(), - Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE), + Sets.newHashSet(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final ClusterState updatedState = Function.identity() diff --git a/server/src/test/java/org/opensearch/gateway/GatewayMetaStatePersistedStateTests.java b/server/src/test/java/org/opensearch/gateway/GatewayMetaStatePersistedStateTests.java index 4ab5d7c44f356..339b04f45c830 100644 --- a/server/src/test/java/org/opensearch/gateway/GatewayMetaStatePersistedStateTests.java +++ b/server/src/test/java/org/opensearch/gateway/GatewayMetaStatePersistedStateTests.java @@ -97,7 +97,7 @@ public void setUp() throws Exception { "node1", buildNewFakeTransportAddress(), Collections.emptyMap(), - Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE), + Sets.newHashSet(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); clusterName = new ClusterName(randomAlphaOfLength(10)); diff --git a/server/src/test/java/org/opensearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java b/server/src/test/java/org/opensearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java index 5574e3c911213..7789054cfdc16 100644 --- a/server/src/test/java/org/opensearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java +++ b/server/src/test/java/org/opensearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java @@ -327,7 +327,7 @@ public ClusterState randomInitialClusterState( Supplier indicesServiceSupplier ) { List allNodes = new ArrayList<>(); - DiscoveryNode localNode = createNode(DiscoveryNodeRole.MASTER_ROLE); // local node is the master + DiscoveryNode localNode = createNode(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); // local node is the master allNodes.add(localNode); // at least two nodes that have the data role so that we can allocate shards allNodes.add(createNode(DiscoveryNodeRole.DATA_ROLE)); diff --git a/server/src/test/java/org/opensearch/node/NodeRoleSettingsTests.java b/server/src/test/java/org/opensearch/node/NodeRoleSettingsTests.java new file mode 100644 index 0000000000000..c875fec1979d1 --- /dev/null +++ b/server/src/test/java/org/opensearch/node/NodeRoleSettingsTests.java @@ -0,0 +1,57 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.node; + +import org.opensearch.cluster.node.DiscoveryNode; +import org.opensearch.cluster.node.DiscoveryNodeRole; +import org.opensearch.common.settings.Settings; +import org.opensearch.test.OpenSearchTestCase; + +import java.util.Arrays; +import java.util.Collections; + +import static org.hamcrest.Matchers.containsString; + +public class NodeRoleSettingsTests extends OpenSearchTestCase { + + /** + * Validate cluster_manager role and master role can not coexist in a node. + * Remove the test after removing MASTER_ROLE. + */ + public void testClusterManagerAndMasterRoleCanNotCoexist() { + // It's used to add MASTER_ROLE into 'roleMap', because MASTER_ROLE is removed from DiscoveryNodeRole.BUILT_IN_ROLES in 2.0. + DiscoveryNode.setAdditionalRoles(Collections.emptySet()); + Settings roleSettings = Settings.builder().put(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), "cluster_manager, master").build(); + Exception exception = expectThrows(IllegalArgumentException.class, () -> NodeRoleSettings.NODE_ROLES_SETTING.get(roleSettings)); + assertThat(exception.getMessage(), containsString("[master, cluster_manager] can not be assigned together to a node")); + } + + /** + * Validate cluster_manager role and data role can coexist in a node. The test is added along with validateRole(). + */ + public void testClusterManagerAndDataNodeRoles() { + Settings roleSettings = Settings.builder().put(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), "cluster_manager, data").build(); + assertEquals( + Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE), + NodeRoleSettings.NODE_ROLES_SETTING.get(roleSettings) + ); + } + + /** + * Validate setting master role will result a deprecation message. + * Remove the test after removing MASTER_ROLE. + */ + public void testMasterRoleDeprecationMessage() { + // It's used to add MASTER_ROLE into 'roleMap', because MASTER_ROLE is removed from DiscoveryNodeRole.BUILT_IN_ROLES in 2.0. + DiscoveryNode.setAdditionalRoles(Collections.emptySet()); + Settings roleSettings = Settings.builder().put(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), "master").build(); + assertEquals(Collections.singletonList(DiscoveryNodeRole.MASTER_ROLE), NodeRoleSettings.NODE_ROLES_SETTING.get(roleSettings)); + assertWarnings(DiscoveryNodeRole.MASTER_ROLE_DEPRECATION_MESSAGE); + } +} diff --git a/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java b/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java index de9dbdc2d5793..bb8f0405ecf7e 100644 --- a/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java +++ b/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java @@ -886,7 +886,7 @@ private String addTask(PersistentTasksCustomMetadata.Builder tasks, String param private DiscoveryNode newNode(String nodeId) { final Set roles = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE)) + new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE)) ); return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT); } diff --git a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java index 5e7def04fe8c8..7855f7f2b0e59 100644 --- a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java +++ b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java @@ -1500,7 +1500,7 @@ public TestClusterNode nodeById(final String nodeId) { } private TestClusterNode newMasterNode(String nodeName) throws IOException { - return newNode(nodeName, DiscoveryNodeRole.MASTER_ROLE); + return newNode(nodeName, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } private TestClusterNode newDataNode(String nodeName) throws IOException { diff --git a/server/src/test/java/org/opensearch/transport/SniffConnectionStrategyTests.java b/server/src/test/java/org/opensearch/transport/SniffConnectionStrategyTests.java index 7e456fa86754f..1714f154036a5 100644 --- a/server/src/test/java/org/opensearch/transport/SniffConnectionStrategyTests.java +++ b/server/src/test/java/org/opensearch/transport/SniffConnectionStrategyTests.java @@ -747,7 +747,7 @@ public void testGetNodePredicateNodeRoles() { "id", address, Collections.emptyMap(), - new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE)), + new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)), Version.CURRENT ); assertTrue(nodePredicate.test(dataMaster)); @@ -757,7 +757,7 @@ public void testGetNodePredicateNodeRoles() { "id", address, Collections.emptyMap(), - new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE)), + new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)), Version.CURRENT ); assertFalse(nodePredicate.test(dedicatedMaster)); @@ -777,7 +777,7 @@ public void testGetNodePredicateNodeRoles() { "id", address, Collections.emptyMap(), - new HashSet<>(Arrays.asList(DiscoveryNodeRole.INGEST_ROLE, DiscoveryNodeRole.MASTER_ROLE)), + new HashSet<>(Arrays.asList(DiscoveryNodeRole.INGEST_ROLE, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)), Version.CURRENT ); assertTrue(nodePredicate.test(masterIngest)); @@ -855,7 +855,7 @@ public void testGetNodePredicatesCombination() { TransportAddress address = new TransportAddress(TransportAddress.META_ADDRESS, 0); Settings settings = Settings.builder().put("cluster.remote.node.attr", "gateway").build(); Predicate nodePredicate = SniffConnectionStrategy.getNodePredicate(settings); - Set dedicatedMasterRoles = new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE)); + Set dedicatedMasterRoles = new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)); Set allRoles = DiscoveryNodeRole.BUILT_IN_ROLES; { DiscoveryNode node = new DiscoveryNode( diff --git a/test/framework/src/main/java/org/opensearch/cluster/OpenSearchAllocationTestCase.java b/test/framework/src/main/java/org/opensearch/cluster/OpenSearchAllocationTestCase.java index e806548cee088..e42dd42b18da5 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/OpenSearchAllocationTestCase.java +++ b/test/framework/src/main/java/org/opensearch/cluster/OpenSearchAllocationTestCase.java @@ -149,7 +149,7 @@ public static AllocationDeciders randomAllocationDeciders(Settings settings, Clu } protected static Set MASTER_DATA_ROLES = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE)) + new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE)) ); protected static DiscoveryNode newNode(String nodeId) { diff --git a/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java b/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java index 0e308e64617fe..291eee501c4df 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java +++ b/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java @@ -164,10 +164,10 @@ void reboot() { final Set roles = new HashSet<>(localNode.getRoles()); if (randomBoolean()) { - if (roles.contains(DiscoveryNodeRole.MASTER_ROLE)) { - roles.remove(DiscoveryNodeRole.MASTER_ROLE); + if (roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)) { + roles.remove(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } else { - roles.add(DiscoveryNodeRole.MASTER_ROLE); + roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } } diff --git a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java index 7461ebb9c8713..3a28ec2efdd4b 100644 --- a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java @@ -787,13 +787,13 @@ private static String getRoleSuffix(Settings settings) { String suffix = ""; // only add the suffixes if roles are explicitly defined if (settings.hasValue("nodes.roles")) { - if (DiscoveryNode.hasRole(settings, DiscoveryNodeRole.MASTER_ROLE)) { - suffix = suffix + DiscoveryNodeRole.MASTER_ROLE.roleNameAbbreviation(); + if (DiscoveryNode.isMasterNode(settings)) { + suffix = suffix + DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleNameAbbreviation(); } if (DiscoveryNode.isDataNode(settings)) { suffix = suffix + DiscoveryNodeRole.DATA_ROLE.roleNameAbbreviation(); } - if (DiscoveryNode.hasRole(settings, DiscoveryNodeRole.MASTER_ROLE) == false && DiscoveryNode.isDataNode(settings) == false) { + if (!DiscoveryNode.isMasterNode(settings) && !DiscoveryNode.isDataNode(settings)) { suffix = suffix + "c"; } } @@ -2150,7 +2150,7 @@ public List startMasterOnlyNodes(int numNodes) { } public List startMasterOnlyNodes(int numNodes, Settings settings) { - return startNodes(numNodes, Settings.builder().put(onlyRole(settings, DiscoveryNodeRole.MASTER_ROLE)).build()); + return startNodes(numNodes, Settings.builder().put(onlyRole(settings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)).build()); } public List startDataOnlyNodes(int numNodes) { diff --git a/test/framework/src/main/java/org/opensearch/test/NodeRoles.java b/test/framework/src/main/java/org/opensearch/test/NodeRoles.java index ed5f505e02304..64fd6b22e9805 100644 --- a/test/framework/src/main/java/org/opensearch/test/NodeRoles.java +++ b/test/framework/src/main/java/org/opensearch/test/NodeRoles.java @@ -80,6 +80,13 @@ public static Settings removeRoles(final Settings settings, final Set roles.contains(r) == false) + // TODO: Remove the below filter after removing MASTER_ROLE. + // It's used to remove both CLUSTER_MANAGER_ROLE and MASTER_ROLE, when requested to remove either. + .filter( + roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE) || roles.contains(DiscoveryNodeRole.MASTER_ROLE) + ? r -> !r.isClusterManager() + : r -> true + ) .map(DiscoveryNodeRole::roleName) .collect(Collectors.toList()) ) @@ -166,7 +173,7 @@ public static Settings masterNode() { } public static Settings masterNode(final Settings settings) { - return addRoles(settings, Collections.singleton(DiscoveryNodeRole.MASTER_ROLE)); + return addRoles(settings, Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)); } public static Settings masterOnlyNode() { @@ -174,7 +181,7 @@ public static Settings masterOnlyNode() { } public static Settings masterOnlyNode(final Settings settings) { - return onlyRole(settings, DiscoveryNodeRole.MASTER_ROLE); + return onlyRole(settings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } public static Settings nonMasterNode() { @@ -182,7 +189,7 @@ public static Settings nonMasterNode() { } public static Settings nonMasterNode(final Settings settings) { - return removeRoles(settings, Collections.singleton(DiscoveryNodeRole.MASTER_ROLE)); + return removeRoles(settings, Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)); } public static Settings remoteClusterClientNode() { diff --git a/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java b/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java index 7ffd96fb68911..f1aee04d92a19 100644 --- a/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java +++ b/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java @@ -398,17 +398,19 @@ public Path nodeConfigPath(int nodeOrdinal) { Function.identity() ); cluster.beforeTest(random()); + // TODO: Remove this line, and replace 'clusterManagerRole' with CLUSTER_MANAGER_ROLE, after MASTER_ROLE is removed. + // It is added in 2.0, along with the introduction of CLUSTER_MANAGER_ROLE, aims to test the 2 roles have the same effect. + DiscoveryNodeRole clusterManagerRole = randomFrom(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.MASTER_ROLE); List roles = new ArrayList<>(); for (int i = 0; i < numNodes; i++) { - final DiscoveryNodeRole role = i == numNodes - 1 && roles.contains(DiscoveryNodeRole.MASTER_ROLE) == false - ? DiscoveryNodeRole.MASTER_ROLE - : // last node and still no master - randomFrom(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.INGEST_ROLE); + final DiscoveryNodeRole role = i == numNodes - 1 && roles.contains(clusterManagerRole) == false + ? clusterManagerRole // last node and still no master + : randomFrom(clusterManagerRole, DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.INGEST_ROLE); roles.add(role); } cluster.setBootstrapMasterNodeIndex( - randomIntBetween(0, (int) roles.stream().filter(role -> role.equals(DiscoveryNodeRole.MASTER_ROLE)).count() - 1) + randomIntBetween(0, (int) roles.stream().filter(role -> role.equals(clusterManagerRole)).count() - 1) ); try { @@ -416,7 +418,7 @@ public Path nodeConfigPath(int nodeOrdinal) { for (int i = 0; i < numNodes; i++) { final DiscoveryNodeRole role = roles.get(i); final String node; - if (role == DiscoveryNodeRole.MASTER_ROLE) { + if (role == clusterManagerRole) { node = cluster.startMasterOnlyNode(); } else if (role == DiscoveryNodeRole.DATA_ROLE) { node = cluster.startDataOnlyNode(); @@ -438,7 +440,7 @@ public Path nodeConfigPath(int nodeOrdinal) { DiscoveryNode node = cluster.getInstance(ClusterService.class, name).localNode(); List paths = Arrays.stream(getNodePaths(cluster, name)).map(Path::toString).collect(Collectors.toList()); if (node.isMasterNode()) { - result.computeIfAbsent(DiscoveryNodeRole.MASTER_ROLE, k -> new HashSet<>()).addAll(paths); + result.computeIfAbsent(clusterManagerRole, k -> new HashSet<>()).addAll(paths); } else if (node.isDataNode()) { result.computeIfAbsent(DiscoveryNodeRole.DATA_ROLE, k -> new HashSet<>()).addAll(paths); } else { From e0f770643ca505292698a7bd7e1f8d699994b7db Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Fri, 18 Mar 2022 15:09:37 -0700 Subject: [PATCH 22/46] Add 'cluster_manager_node' into ClusterState Metric as an alternative to 'master_node' (#2415) * Add `cluster_manager_node` into `ClusterState Metric`, as an alternative to `master_node`. So that the request parameter "metric" in `Cluster reroute` and `Cluster state` API accept the new value `cluster_manager_node` * Deprecate the enum value of `Metric: MASTER_NODE("master_node")` * Add YAML REST tests for the new parameter value for "cluster state" and "cluster reroute" API Signed-off-by: Tianli Feng --- .../rest-api-spec/api/cluster.reroute.json | 1 + .../rest-api-spec/api/cluster.state.json | 1 + .../test/cluster.reroute/10_basic.yml | 15 +++++++++++++++ .../cluster.reroute/20_response_filtering.yml | 13 +++++++++++++ .../test/cluster.state/10_basic.yml | 15 +++++++++++++++ .../test/cluster.state/20_filtering.yml | 16 ++++++++++++++++ .../org/opensearch/cluster/ClusterState.java | 11 +++++++++++ .../cluster/RestClusterRerouteAction.java | 15 +++++++++++++++ .../admin/cluster/RestClusterStateAction.java | 19 ++++++++++++++++++- .../reroute/ClusterRerouteResponseTests.java | 5 +++-- .../opensearch/cluster/ClusterStateTests.java | 4 ++++ 11 files changed, 112 insertions(+), 3 deletions(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json index b0e8054fc9e53..bcf2704110664 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json @@ -37,6 +37,7 @@ "nodes", "routing_table", "master_node", + "cluster_manager_node", "version" ], "description":"Limit the information returned to the specified metrics. Defaults to all but metadata" diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.state.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.state.json index 017705082d189..c17e5b073e361 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.state.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.state.json @@ -55,6 +55,7 @@ "routing_table", "routing_nodes", "master_node", + "cluster_manager_node", "version" ], "description":"Limit the information returned to the specified metrics" diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/10_basic.yml index 771f647a952c7..1b45e19c24acf 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/10_basic.yml @@ -2,3 +2,18 @@ "Basic sanity check": - do: cluster.reroute: {} + +--- +"Cluster reroute returns cluster_manager_node": + - skip: + version: " - 1.4.99" + reason: "The metric cluster_manager_node is added to cluster state in version 2.0.0" + + - do: + cluster.reroute: {} + + - set: + state.cluster_manager_node: node_id + + - match: {state.master_node: $node_id} + - match: {state.cluster_manager_node: $node_id} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml index 437b78e6119a7..c05d1db51142e 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml @@ -3,6 +3,7 @@ - do: cluster.reroute: {} - is_false: state.metadata + --- "return metadata if requested": - do: @@ -12,3 +13,15 @@ - is_true: state.metadata - is_false: state.nodes +--- +"Filter the cluster reroute by cluster_manager_node only should work": + - skip: + version: " - 1.4.99" + reason: "The metric cluster_manager_node is added to cluster state in version 2.0.0" + + - do: + cluster.reroute: + metric: [ cluster_manager_node ] + + - is_true: state.cluster_manager_node + - is_false: state.master_node diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/10_basic.yml index b443e322f80f6..fa973454cfba5 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/10_basic.yml @@ -17,3 +17,18 @@ - is_true: cluster_uuid - is_true: master_node + +--- +"Get cluster state returns cluster_manager_node": + - skip: + version: " - 1.4.99" + reason: "The metric cluster_manager_node is added to cluster state in version 2.0.0" + + - do: + cluster.state: {} + + - set: + cluster_manager_node: node_id + + - match: {master_node: $node_id} + - match: {cluster_manager_node: $node_id} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/20_filtering.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/20_filtering.yml index 88da42ee876be..3d20f1d0f7e52 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/20_filtering.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/20_filtering.yml @@ -158,6 +158,7 @@ setup: - skip: version: " - 6.3.99" reason: "cluster state including cluster_uuid at the top level is new in v6.4.0 and higher" + features: allowed_warnings # Get the current cluster_uuid - do: @@ -167,6 +168,8 @@ setup: - do: cluster.state: metric: [ master_node, version ] + allowed_warnings: + - 'Deprecated value [master_node] used for parameter [metric]. To promote inclusive language, please use [cluster_manager_node] instead. It will be unsupported in a future major version.' - match: { cluster_uuid: $cluster_uuid } - is_true: master_node @@ -180,3 +183,16 @@ setup: - match: { cluster_uuid: $cluster_uuid } - is_true: routing_table + +--- +"Filter the cluster state by cluster_manager_node only should work": + - skip: + version: " - 1.4.99" + reason: "The metric cluster_manager_node is added to cluster state in version 2.0.0" + + - do: + cluster.state: + metric: [ cluster_manager_node ] + + - is_true: cluster_manager_node + - is_false: master_node diff --git a/server/src/main/java/org/opensearch/cluster/ClusterState.java b/server/src/main/java/org/opensearch/cluster/ClusterState.java index 6e17be690dd9d..459c0b9502acf 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterState.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterState.java @@ -402,7 +402,13 @@ public boolean supersedes(ClusterState other) { public enum Metric { VERSION("version"), + + /** + * @deprecated As of 2.0, because promoting inclusive language, replaced by {@link #CLUSTER_MANAGER_NODE} + */ + @Deprecated MASTER_NODE("master_node"), + CLUSTER_MANAGER_NODE("cluster_manager_node"), BLOCKS("blocks"), NODES("nodes"), METADATA("metadata"), @@ -467,6 +473,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field("master_node", nodes().getMasterNodeId()); } + // Value of the field is identical with the above, and aims to replace the above field. + if (metrics.contains(Metric.CLUSTER_MANAGER_NODE)) { + builder.field("cluster_manager_node", nodes().getMasterNodeId()); + } + if (metrics.contains(Metric.BLOCKS)) { builder.startObject("blocks"); diff --git a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java index 1d1feff36f239..f519da109ba09 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java @@ -39,6 +39,7 @@ import org.opensearch.cluster.routing.allocation.command.AllocationCommands; import org.opensearch.common.ParseField; import org.opensearch.common.Strings; +import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.SettingsFilter; import org.opensearch.common.xcontent.ObjectParser; @@ -78,6 +79,12 @@ public RestClusterRerouteAction(SettingsFilter settingsFilter) { this.settingsFilter = settingsFilter; } + // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. + // It's used to log deprecation when request parameter 'metric' contains 'master_node'. + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestClusterRerouteAction.class); + private static final String DEPRECATED_MESSAGE_MASTER_NODE = + "Deprecated value [master_node] used for parameter [metric]. To promote inclusive language, please use [cluster_manager_node] instead. It will be unsupported in a future major version."; + @Override public List routes() { return singletonList(new Route(POST, "/_cluster/reroute")); @@ -104,6 +111,14 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC final String metric = request.param("metric"); if (metric == null) { request.params().put("metric", DEFAULT_METRICS); + } else { + // TODO: Remove the statements in 'else' after removing MASTER_ROLE. + EnumSet metrics = ClusterState.Metric.parseString(request.param("metric"), true); + // Because "_all" value will add all Metric into metrics set, for prevent deprecation message shown in that case, + // add the check of validating metrics set doesn't contain all enum elements. + if (!metrics.equals(EnumSet.allOf(ClusterState.Metric.class)) && metrics.contains(ClusterState.Metric.MASTER_NODE)) { + deprecationLogger.deprecate("cluster_reroute_metric_parameter_master_node_value", DEPRECATED_MESSAGE_MASTER_NODE); + } } return channel -> client.admin().cluster().reroute(clusterRerouteRequest, new RestToXContentListener<>(channel)); } diff --git a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterStateAction.java b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterStateAction.java index 5056e29d47dce..32aa055c18300 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterStateAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterStateAction.java @@ -40,6 +40,7 @@ import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.Metadata; import org.opensearch.common.Strings; +import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.SettingsFilter; import org.opensearch.common.xcontent.ToXContent; @@ -71,6 +72,12 @@ public RestClusterStateAction(SettingsFilter settingsFilter) { this.settingsFilter = settingsFilter; } + // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. + // It's used to log deprecation when request parameter 'metric' contains 'master_node'. + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestClusterStateAction.class); + private static final String DEPRECATED_MESSAGE_MASTER_NODE = + "Deprecated value [master_node] used for parameter [metric]. To promote inclusive language, please use [cluster_manager_node] instead. It will be unsupported in a future major version."; + @Override public String getName() { return "cluster_state_action"; @@ -112,7 +119,17 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC if (request.hasParam("metric")) { EnumSet metrics = ClusterState.Metric.parseString(request.param("metric"), true); // do not ask for what we do not need. - clusterStateRequest.nodes(metrics.contains(ClusterState.Metric.NODES) || metrics.contains(ClusterState.Metric.MASTER_NODE)); + clusterStateRequest.nodes( + metrics.contains(ClusterState.Metric.NODES) + || metrics.contains(ClusterState.Metric.MASTER_NODE) + || metrics.contains(ClusterState.Metric.CLUSTER_MANAGER_NODE) + ); + // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. + // Because "_all" value will add all Metric into metrics set, for prevent deprecation message shown in that case, + // add the check of validating metrics set doesn't contain all enum elements. + if (!metrics.equals(EnumSet.allOf(ClusterState.Metric.class)) && metrics.contains(ClusterState.Metric.MASTER_NODE)) { + deprecationLogger.deprecate("cluster_state_metric_parameter_master_node_value", DEPRECATED_MESSAGE_MASTER_NODE); + } /* * there is no distinction in Java api between routing_table and routing_nodes, it's the same info set over the wire, one single * flag to ask for it diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java index f0384f249879d..7a7bc18876932 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java @@ -94,6 +94,7 @@ public void testToXContent() throws IOException { + clusterState.stateUUID() + "\",\n" + " \"master_node\" : \"node0\",\n" + + " \"cluster_manager_node\" : \"node0\",\n" + " \"blocks\" : { },\n" + " \"nodes\" : {\n" + " \"node0\" : {\n" @@ -173,7 +174,7 @@ public void testToXContent() throws IOException { XContentBuilder builder = JsonXContent.contentBuilder().prettyPrint(); Map params = new HashMap<>(); params.put("explain", "true"); - params.put("metric", "version,master_node"); + params.put("metric", "version,cluster_manager_node"); clusterRerouteResponse.toXContent(builder, new ToXContent.MapParams(params)); assertEquals( "{\n" @@ -184,7 +185,7 @@ public void testToXContent() throws IOException { + " \"state_uuid\" : \"" + clusterState.stateUUID() + "\",\n" - + " \"master_node\" : \"node0\"\n" + + " \"cluster_manager_node\" : \"node0\"\n" + " },\n" + " \"explanations\" : [\n" + " {\n" diff --git a/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java b/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java index 4cc3108d6bf85..7cbab104cd07a 100644 --- a/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java +++ b/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java @@ -147,6 +147,7 @@ public void testToXContent() throws IOException { + " \"version\" : 0,\n" + " \"state_uuid\" : \"stateUUID\",\n" + " \"master_node\" : \"masterNodeId\",\n" + + " \"cluster_manager_node\" : \"masterNodeId\",\n" + " \"blocks\" : {\n" + " \"global\" : {\n" + " \"1\" : {\n" @@ -352,6 +353,7 @@ public void testToXContent_FlatSettingTrue_ReduceMappingFalse() throws IOExcepti + " \"version\" : 0,\n" + " \"state_uuid\" : \"stateUUID\",\n" + " \"master_node\" : \"masterNodeId\",\n" + + " \"cluster_manager_node\" : \"masterNodeId\",\n" + " \"blocks\" : {\n" + " \"global\" : {\n" + " \"1\" : {\n" @@ -550,6 +552,7 @@ public void testToXContent_FlatSettingFalse_ReduceMappingTrue() throws IOExcepti + " \"version\" : 0,\n" + " \"state_uuid\" : \"stateUUID\",\n" + " \"master_node\" : \"masterNodeId\",\n" + + " \"cluster_manager_node\" : \"masterNodeId\",\n" + " \"blocks\" : {\n" + " \"global\" : {\n" + " \"1\" : {\n" @@ -772,6 +775,7 @@ public void testToXContentSameTypeName() throws IOException { + " \"version\" : 0,\n" + " \"state_uuid\" : \"stateUUID\",\n" + " \"master_node\" : null,\n" + + " \"cluster_manager_node\" : null,\n" + " \"blocks\" : { },\n" + " \"nodes\" : { },\n" + " \"metadata\" : {\n" From a85325363f01113bf3c9189bac42bab7cfe5e81f Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Sat, 19 Mar 2022 01:22:04 -0700 Subject: [PATCH 23/46] Use Hamcrest matchers and assertThat() in ReindexRenamedSettingTests (#2503) Signed-off-by: Tianli Feng --- .../reindex/ReindexRenamedSettingTests.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.java index 8ff84223d371e..00747d85221c6 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.java @@ -15,6 +15,9 @@ import java.util.Arrays; import java.util.List; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItems; + /** * A unit test to validate the former name of the setting 'reindex.remote.allowlist' still take effect, * after it is deprecated, so that the backwards compatibility is maintained. @@ -28,11 +31,10 @@ public class ReindexRenamedSettingTests extends OpenSearchTestCase { */ public void testReindexSettingsExist() { List> settings = plugin.getSettings(); - assertTrue( + assertThat( "Both 'reindex.remote.allowlist' and its predecessor should be supported settings of Reindex plugin", - settings.containsAll( - Arrays.asList(TransportReindexAction.REMOTE_CLUSTER_WHITELIST, TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST) - ) + settings, + hasItems(TransportReindexAction.REMOTE_CLUSTER_WHITELIST, TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST) ); } @@ -40,9 +42,9 @@ public void testReindexSettingsExist() { * Validate the default value of the both settings is the same. */ public void testSettingFallback() { - assertEquals( + assertThat( TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(Settings.EMPTY), - TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(Settings.EMPTY) + equalTo(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(Settings.EMPTY)) ); } @@ -51,10 +53,10 @@ public void testSettingFallback() { */ public void testSettingGetValue() { Settings settings = Settings.builder().put("reindex.remote.allowlist", "127.0.0.1:*").build(); - assertEquals(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), Arrays.asList("127.0.0.1:*")); - assertEquals( + assertThat(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), equalTo(Arrays.asList("127.0.0.1:*"))); + assertThat( TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings), - TransportReindexAction.REMOTE_CLUSTER_WHITELIST.getDefault(Settings.EMPTY) + equalTo(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.getDefault(Settings.EMPTY)) ); } @@ -63,7 +65,7 @@ public void testSettingGetValue() { */ public void testSettingGetValueWithFallback() { Settings settings = Settings.builder().put("reindex.remote.whitelist", "127.0.0.1:*").build(); - assertEquals(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), Arrays.asList("127.0.0.1:*")); + assertThat(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), equalTo(Arrays.asList("127.0.0.1:*"))); assertSettingDeprecationsAndWarnings(new Setting[] { TransportReindexAction.REMOTE_CLUSTER_WHITELIST }); } @@ -75,8 +77,8 @@ public void testSettingGetValueWhenBothAreConfigured() { .put("reindex.remote.allowlist", "127.0.0.1:*") .put("reindex.remote.whitelist", "[::1]:*, 127.0.0.1:*") .build(); - assertEquals(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), Arrays.asList("127.0.0.1:*")); - assertEquals(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings), Arrays.asList("[::1]:*", "127.0.0.1:*")); + assertThat(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), equalTo(Arrays.asList("127.0.0.1:*"))); + assertThat(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings), equalTo(Arrays.asList("[::1]:*", "127.0.0.1:*"))); assertSettingDeprecationsAndWarnings(new Setting[] { TransportReindexAction.REMOTE_CLUSTER_WHITELIST }); } From cdd74deeef039d803014cf372c26e4dc5534ed4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 19 Mar 2022 13:01:59 -0700 Subject: [PATCH 24/46] Bump jsr305 from 1.3.9 to 3.0.2 in /plugins/discovery-gce (#2137) * Bump jsr305 from 1.3.9 to 3.0.2 in /plugins/discovery-gce Bumps jsr305 from 1.3.9 to 3.0.2. --- updated-dependencies: - dependency-name: com.google.code.findbugs:jsr305 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Updating SHAs Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- plugins/discovery-gce/build.gradle | 2 +- plugins/discovery-gce/licenses/jsr305-1.3.9.jar.sha1 | 1 - plugins/discovery-gce/licenses/jsr305-3.0.2.jar.sha1 | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 plugins/discovery-gce/licenses/jsr305-1.3.9.jar.sha1 create mode 100644 plugins/discovery-gce/licenses/jsr305-3.0.2.jar.sha1 diff --git a/plugins/discovery-gce/build.gradle b/plugins/discovery-gce/build.gradle index 01c48f9a9df83..14827eb180e9f 100644 --- a/plugins/discovery-gce/build.gradle +++ b/plugins/discovery-gce/build.gradle @@ -27,7 +27,7 @@ dependencies { api "com.google.oauth-client:google-oauth-client:1.31.0" api "com.google.http-client:google-http-client:${versions.google}" api "com.google.http-client:google-http-client-jackson2:${versions.google}" - api 'com.google.code.findbugs:jsr305:1.3.9' + api 'com.google.code.findbugs:jsr305:3.0.2' api "org.apache.httpcomponents:httpclient:${versions.httpclient}" api "org.apache.httpcomponents:httpcore:${versions.httpcore}" api "commons-logging:commons-logging:${versions.commonslogging}" diff --git a/plugins/discovery-gce/licenses/jsr305-1.3.9.jar.sha1 b/plugins/discovery-gce/licenses/jsr305-1.3.9.jar.sha1 deleted file mode 100644 index c04a4299d5e36..0000000000000 --- a/plugins/discovery-gce/licenses/jsr305-1.3.9.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -40719ea6961c0cb6afaeb6a921eaa1f6afd4cfdf diff --git a/plugins/discovery-gce/licenses/jsr305-3.0.2.jar.sha1 b/plugins/discovery-gce/licenses/jsr305-3.0.2.jar.sha1 new file mode 100644 index 0000000000000..c5c92d87b9d6c --- /dev/null +++ b/plugins/discovery-gce/licenses/jsr305-3.0.2.jar.sha1 @@ -0,0 +1 @@ +25ea2e8b0c338a877313bd4672d3fe056ea78f0d \ No newline at end of file From 84cba7b0f6d74d555c372f244adac0bab2af8690 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 19 Mar 2022 14:47:56 -0700 Subject: [PATCH 25/46] Bump jna from 5.5.0 to 5.10.0 in /buildSrc (#2512) Bumps [jna](https://github.com/java-native-access/jna) from 5.5.0 to 5.10.0. - [Release notes](https://github.com/java-native-access/jna/releases) - [Changelog](https://github.com/java-native-access/jna/blob/master/CHANGES.md) - [Commits](https://github.com/java-native-access/jna/compare/5.5.0...5.10.0) --- updated-dependencies: - dependency-name: net.java.dev.jna:jna dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- buildSrc/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 5925d1a4d8164..a637782ed3cf7 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -110,7 +110,7 @@ dependencies { api 'com.netflix.nebula:gradle-info-plugin:7.1.3' api 'org.apache.rat:apache-rat:0.13' api 'commons-io:commons-io:2.7' - api "net.java.dev.jna:jna:5.5.0" + api "net.java.dev.jna:jna:5.10.0" api 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2' api 'de.thetaphi:forbiddenapis:3.2' api 'com.avast.gradle:gradle-docker-compose-plugin:0.14.12' From 5dfd05c71362a6358d6bc08a87f89453045945d5 Mon Sep 17 00:00:00 2001 From: Viggo Date: Tue, 22 Mar 2022 02:36:52 +0800 Subject: [PATCH 26/46] Clear up some confusing code in IndexShardHotSpotTests (#1534) * clear up some useless but confusing test code Signed-off-by: Weiguo Chen * remove useless comment Signed-off-by: Weiguo Chen --- .../allocation/IndexShardHotSpotTests.java | 52 ++----------------- 1 file changed, 5 insertions(+), 47 deletions(-) diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/IndexShardHotSpotTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/IndexShardHotSpotTests.java index 875432c9e6e11..2efbb256e36bc 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/IndexShardHotSpotTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/IndexShardHotSpotTests.java @@ -20,14 +20,7 @@ public void testNodeReplacement() { terminateNodes("node_1"); assertForIndexShardHotSpots(false, 4); addNodesWithoutIndexing(1, "new_node_"); - int movesForModeNone = allocateAndCheckIndexShardHotSpots(false, 5, "new_node_0"); - - setupInitialCluster(5, 1, 5, 1); - terminateNodes("node_1"); - assertForIndexShardHotSpots(false, 4); - addNodesWithoutIndexing(1, "new_node_"); - int movesForModeUnassigned = allocateAndCheckIndexShardHotSpots(false, 5, "new_node_0"); - assertTrue(movesForModeUnassigned <= movesForModeNone); + allocateAndCheckIndexShardHotSpots(false, 5, "new_node_0"); } /** @@ -39,15 +32,7 @@ public void testNodeReplacementWithIndexing() { terminateNodes("node_1"); assertForIndexShardHotSpots(false, 4); addNodesWithIndexing(1, "new_node_", 3, 20, 1); - int movesForModeNone = allocateAndCheckIndexShardHotSpots(false, 5, "new_node_0"); - - resetCluster(); - buildAllocationService(); - terminateNodes("node_1"); - assertForIndexShardHotSpots(false, 4); - addNodesWithIndexing(1, "new_node_", 3, 20, 1); - int movesForModeUnassigned = allocateAndCheckIndexShardHotSpots(false, 5, "new_node_0"); - assertTrue(movesForModeUnassigned <= movesForModeNone); + allocateAndCheckIndexShardHotSpots(false, 5, "new_node_0"); } /** @@ -57,32 +42,17 @@ public void testSkewedClusterScaleOut() { setupInitialCluster(3, 30, 10, 1); buildAllocationService(); addNodesWithIndexing(1, "new_node_", 8, 10, 1); - int movesForModeNone = allocateAndCheckIndexShardHotSpots(false, 4, "new_node_0"); - - resetCluster(); - buildAllocationService(); - addNodesWithIndexing(1, "new_node_", 8, 10, 1); - int movesForModeUnassigned = allocateAndCheckIndexShardHotSpots(false, 4, "new_node_0"); - assertTrue(movesForModeUnassigned <= movesForModeNone); + allocateAndCheckIndexShardHotSpots(false, 4, "new_node_0"); } /** * Test under replicated yellow cluster scale out to green. - * - * This scenario is not expected to create hotspots even without constraints enabled. The - * test is a sanity check to ensure allocation constraints don't worsen the situation. */ public void testUnderReplicatedClusterScaleOut() { setupInitialCluster(3, 30, 10, 3); buildAllocationService(); addNodesWithoutIndexing(1, "new_node_"); - int movesForModeNone = allocateAndCheckIndexShardHotSpots(false, 4, "new_node_0"); - - resetCluster(); - buildAllocationService(); - addNodesWithoutIndexing(1, "new_node_"); - int movesForModeUnassigned = allocateAndCheckIndexShardHotSpots(false, 4, "new_node_0"); - assertTrue(movesForModeUnassigned <= movesForModeNone); + allocateAndCheckIndexShardHotSpots(false, 4, "new_node_0"); } /** @@ -91,19 +61,12 @@ public void testUnderReplicatedClusterScaleOut() { * * During moveShards(), shards are picked from across indexes in an interleaved manner. * This prevents hot spots by evenly picking up shards. Since shard order can change - * in subsequent runs, we are not guaranteed to less moves than no allocation constraint run. - * - * Move tests are hence just a sanity test, to ensure we don't create any unexpected hot spots with - * allocation settings. + * in subsequent runs. */ public void testClusterScaleIn() { setupInitialCluster(4, 30, 10, 1); buildAllocationService("node_0,node_1"); allocateAndCheckIndexShardHotSpots(false, 2, "node_2", "node_3"); - - resetCluster(); - buildAllocationService("node_0,node_1"); - allocateAndCheckIndexShardHotSpots(false, 2, "node_2", "node_3"); } /** @@ -115,10 +78,5 @@ public void testClusterScaleInWithSkew() { buildAllocationService("node_0,node_1"); addNodesWithoutIndexing(1, "new_node_"); allocateAndCheckIndexShardHotSpots(false, 3, "node_2", "node_3", "new_node_0"); - - resetCluster(); - buildAllocationService("node_0,node_1"); - addNodesWithoutIndexing(1, "new_node_"); - allocateAndCheckIndexShardHotSpots(false, 3, "node_2", "node_3", "new_node_0"); } } From ce0d2ca7bcd2ebc4a76d5c2a5fdbffcc8aae7014 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Mon, 21 Mar 2022 13:40:18 -0500 Subject: [PATCH 27/46] Fix bwcVersions after bumping version 1.3.1 (#2532) Signed-off-by: Nicholas Walter Knize --- .ci/bwcVersions | 3 ++- server/src/main/java/org/opensearch/Version.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.ci/bwcVersions b/.ci/bwcVersions index dd51082981ffc..ddc36af48d674 100644 --- a/.ci/bwcVersions +++ b/.ci/bwcVersions @@ -37,4 +37,5 @@ BWC_VERSION: - "1.2.4" - "1.2.5" - "1.3.0" - - "1.4.0" \ No newline at end of file + - "1.3.1" + - "1.4.0" diff --git a/server/src/main/java/org/opensearch/Version.java b/server/src/main/java/org/opensearch/Version.java index 860bb2c5ada69..f74e529c442bb 100644 --- a/server/src/main/java/org/opensearch/Version.java +++ b/server/src/main/java/org/opensearch/Version.java @@ -79,6 +79,7 @@ public class Version implements Comparable, ToXContentFragment { public static final Version V_1_2_4 = new Version(1020499, org.apache.lucene.util.Version.LUCENE_8_10_1); public static final Version V_1_2_5 = new Version(1020599, org.apache.lucene.util.Version.LUCENE_8_10_1); public static final Version V_1_3_0 = new Version(1030099, org.apache.lucene.util.Version.LUCENE_8_10_1); + public static final Version V_1_3_1 = new Version(1030199, org.apache.lucene.util.Version.LUCENE_8_10_1); public static final Version V_1_4_0 = new Version(1040099, org.apache.lucene.util.Version.LUCENE_8_10_1); public static final Version V_2_0_0 = new Version(2000099, org.apache.lucene.util.Version.LUCENE_9_1_0); public static final Version CURRENT = V_2_0_0; From 6a2b47146aaab0569aa56b64d18a1952fc15f57a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 15:05:08 -0400 Subject: [PATCH 28/46] Bump asm-commons from 7.2 to 9.2 in /modules/lang-painless (#2234) * Bump asm-commons from 7.2 to 9.2 in /modules/lang-painless Bumps asm-commons from 7.2 to 9.2. --- updated-dependencies: - dependency-name: org.ow2.asm:asm-commons dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Updating SHAs Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- modules/lang-painless/build.gradle | 2 +- modules/lang-painless/licenses/asm-commons-7.2.jar.sha1 | 1 - modules/lang-painless/licenses/asm-commons-9.2.jar.sha1 | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 modules/lang-painless/licenses/asm-commons-7.2.jar.sha1 create mode 100644 modules/lang-painless/licenses/asm-commons-9.2.jar.sha1 diff --git a/modules/lang-painless/build.gradle b/modules/lang-painless/build.gradle index eb93cdc77fb9c..a85f83f762526 100644 --- a/modules/lang-painless/build.gradle +++ b/modules/lang-painless/build.gradle @@ -48,7 +48,7 @@ dependencies { api 'org.antlr:antlr4-runtime:4.5.3' api 'org.ow2.asm:asm-util:9.2' api 'org.ow2.asm:asm-tree:7.2' - api 'org.ow2.asm:asm-commons:7.2' + api 'org.ow2.asm:asm-commons:9.2' api 'org.ow2.asm:asm-analysis:7.2' api 'org.ow2.asm:asm:9.2' api project('spi') diff --git a/modules/lang-painless/licenses/asm-commons-7.2.jar.sha1 b/modules/lang-painless/licenses/asm-commons-7.2.jar.sha1 deleted file mode 100644 index b634981fc89ac..0000000000000 --- a/modules/lang-painless/licenses/asm-commons-7.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -ca2954e8d92a05bacc28ff465b25c70e0f512497 \ No newline at end of file diff --git a/modules/lang-painless/licenses/asm-commons-9.2.jar.sha1 b/modules/lang-painless/licenses/asm-commons-9.2.jar.sha1 new file mode 100644 index 0000000000000..7beb3d29afe86 --- /dev/null +++ b/modules/lang-painless/licenses/asm-commons-9.2.jar.sha1 @@ -0,0 +1 @@ +f4d7f0fc9054386f2893b602454d48e07d4fbead \ No newline at end of file From 8737b677a01279ae108a6ceeaded18272c012f13 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 15:05:26 -0400 Subject: [PATCH 29/46] Bump asm-analysis from 7.1 to 9.2 in /test/logger-usage (#2273) Bumps asm-analysis from 7.1 to 9.2. --- updated-dependencies: - dependency-name: org.ow2.asm:asm-analysis dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/logger-usage/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/logger-usage/build.gradle b/test/logger-usage/build.gradle index 2cf271a0f601b..ecfccc9338410 100644 --- a/test/logger-usage/build.gradle +++ b/test/logger-usage/build.gradle @@ -33,7 +33,7 @@ apply plugin: 'opensearch.java' dependencies { api 'org.ow2.asm:asm:9.2' api 'org.ow2.asm:asm-tree:9.2' - api 'org.ow2.asm:asm-analysis:7.1' + api 'org.ow2.asm:asm-analysis:9.2' api "org.apache.logging.log4j:log4j-api:${versions.log4j}" testImplementation project(":test:framework") } From 91969ce08c44a264d78dcf3128eade6cef7f2cad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 12:43:13 -0700 Subject: [PATCH 30/46] Bump commons-io from 2.7 to 2.11.0 in /plugins/discovery-azure-classic (#2527) * Bump commons-io from 2.7 to 2.11.0 in /plugins/discovery-azure-classic Bumps commons-io from 2.7 to 2.11.0. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Updating SHAs Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- plugins/discovery-azure-classic/build.gradle | 2 +- .../discovery-azure-classic/licenses/commons-io-2.11.0.jar.sha1 | 1 + .../discovery-azure-classic/licenses/commons-io-2.7.jar.sha1 | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 plugins/discovery-azure-classic/licenses/commons-io-2.11.0.jar.sha1 delete mode 100644 plugins/discovery-azure-classic/licenses/commons-io-2.7.jar.sha1 diff --git a/plugins/discovery-azure-classic/build.gradle b/plugins/discovery-azure-classic/build.gradle index 968f4efb3fa1e..28cbc647ac31a 100644 --- a/plugins/discovery-azure-classic/build.gradle +++ b/plugins/discovery-azure-classic/build.gradle @@ -53,7 +53,7 @@ dependencies { api "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}" api "commons-codec:commons-codec:${versions.commonscodec}" api "commons-lang:commons-lang:2.6" - api "commons-io:commons-io:2.7" + api "commons-io:commons-io:2.11.0" api 'javax.mail:mail:1.4.7' api 'javax.inject:javax.inject:1' api "com.sun.jersey:jersey-client:${versions.jersey}" diff --git a/plugins/discovery-azure-classic/licenses/commons-io-2.11.0.jar.sha1 b/plugins/discovery-azure-classic/licenses/commons-io-2.11.0.jar.sha1 new file mode 100644 index 0000000000000..8adec30bade49 --- /dev/null +++ b/plugins/discovery-azure-classic/licenses/commons-io-2.11.0.jar.sha1 @@ -0,0 +1 @@ +a2503f302b11ebde7ebc3df41daebe0e4eea3689 \ No newline at end of file diff --git a/plugins/discovery-azure-classic/licenses/commons-io-2.7.jar.sha1 b/plugins/discovery-azure-classic/licenses/commons-io-2.7.jar.sha1 deleted file mode 100644 index bbb1b15dd1e1e..0000000000000 --- a/plugins/discovery-azure-classic/licenses/commons-io-2.7.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -3f2bd4ba11c4162733c13cc90ca7c7ea09967102 \ No newline at end of file From 7a6311e652b4c252a91180fbbd21b5263aea0151 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 12:50:56 -0700 Subject: [PATCH 31/46] Bump com.gradle.enterprise from 3.8.1 to 3.9 (#2523) Bumps com.gradle.enterprise from 3.8.1 to 3.9. --- updated-dependencies: - dependency-name: com.gradle.enterprise dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 14b850b5340b9..cb8167ee02efe 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,7 +10,7 @@ */ plugins { - id "com.gradle.enterprise" version "3.8.1" + id "com.gradle.enterprise" version "3.9" } rootProject.name = "OpenSearch" From 1a3dbb70e09b55ffa7481da0fc78f75ab0fe1510 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Mon, 21 Mar 2022 15:57:42 -0400 Subject: [PATCH 32/46] ignore_malformed parameter on ip_range data_type throws mapper_parsing_exception (#2429) Signed-off-by: Andriy Redko --- .../index/mapper/RangeFieldMapper.java | 101 +++++++++++++----- .../index/mapper/IpRangeFieldMapperTests.java | 96 +++++++++++++++-- 2 files changed, 163 insertions(+), 34 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/mapper/RangeFieldMapper.java b/server/src/main/java/org/opensearch/index/mapper/RangeFieldMapper.java index 6ddb6d21ed5c1..2568009cfc0d5 100644 --- a/server/src/main/java/org/opensearch/index/mapper/RangeFieldMapper.java +++ b/server/src/main/java/org/opensearch/index/mapper/RangeFieldMapper.java @@ -118,16 +118,36 @@ public static class Builder extends ParametrizedFieldMapper.Builder { private final RangeType type; private final Version indexCreatedVersion; + private final boolean ignoreMalformedByDefault; + private final Parameter ignoreMalformed; public Builder(String name, RangeType type, Settings settings) { - this(name, type, COERCE_SETTING.get(settings), hasIndexCreated(settings) ? Version.indexCreated(settings) : null); + this( + name, + type, + COERCE_SETTING.get(settings), + IGNORE_MALFORMED_SETTING.get(settings), + hasIndexCreated(settings) ? Version.indexCreated(settings) : null + ); } public Builder(String name, RangeType type, boolean coerceByDefault, Version indexCreatedVersion) { + this(name, type, coerceByDefault, false /* ignoreMalformedByDefault */, indexCreatedVersion); + } + + public Builder( + String name, + RangeType type, + boolean coerceByDefault, + boolean ignoreMalformedByDefault, + Version indexCreatedVersion + ) { super(name); this.type = type; this.coerce = Parameter.explicitBoolParam("coerce", true, m -> toType(m).coerce, coerceByDefault); this.indexCreatedVersion = indexCreatedVersion; + this.ignoreMalformedByDefault = ignoreMalformedByDefault; + this.ignoreMalformed = Parameter.boolParam("ignore_malformed", true, m -> toType(m).ignoreMalformed, ignoreMalformedByDefault); if (this.type != RangeType.DATE) { format.neverSerialize(); locale.neverSerialize(); @@ -145,7 +165,7 @@ Builder format(String format) { @Override protected List> getParameters() { - return Arrays.asList(index, hasDocValues, store, coerce, format, locale, boost, meta); + return Arrays.asList(index, hasDocValues, store, coerce, format, locale, boost, meta, ignoreMalformed); } protected RangeFieldType setupFieldType(BuilderContext context) { @@ -378,6 +398,8 @@ public Query rangeQuery( private final boolean coerceByDefault; private final Version indexCreatedVersion; + private final boolean ignoreMalformed; + private final boolean ignoreMalformedByDefault; private RangeFieldMapper( String simpleName, @@ -397,6 +419,8 @@ private RangeFieldMapper( this.locale = builder.locale.getValue(); this.coerceByDefault = builder.coerce.getDefaultValue().value(); this.indexCreatedVersion = builder.indexCreatedVersion; + this.ignoreMalformed = builder.ignoreMalformed.getValue(); + this.ignoreMalformedByDefault = builder.ignoreMalformedByDefault; } boolean coerce() { @@ -405,7 +429,7 @@ boolean coerce() { @Override public ParametrizedFieldMapper.Builder getMergeBuilder() { - return new Builder(simpleName(), type, coerceByDefault, indexCreatedVersion).init(this); + return new Builder(simpleName(), type, coerceByDefault, ignoreMalformedByDefault, indexCreatedVersion).init(this); } @Override @@ -442,40 +466,65 @@ protected void parseCreateField(ParseContext context) throws IOException { boolean includeFrom = DEFAULT_INCLUDE_LOWER; boolean includeTo = DEFAULT_INCLUDE_UPPER; XContentParser.Token token; + boolean rangeIsMalformed = false; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { fieldName = parser.currentName(); } else { - if (fieldName.equals(GT_FIELD.getPreferredName())) { - includeFrom = false; - if (parser.currentToken() != XContentParser.Token.VALUE_NULL) { - from = rangeType.parseFrom(fieldType, parser, coerce.value(), includeFrom); - } - } else if (fieldName.equals(GTE_FIELD.getPreferredName())) { - includeFrom = true; - if (parser.currentToken() != XContentParser.Token.VALUE_NULL) { - from = rangeType.parseFrom(fieldType, parser, coerce.value(), includeFrom); + try { + if (fieldName.equals(GT_FIELD.getPreferredName())) { + includeFrom = false; + if (parser.currentToken() != XContentParser.Token.VALUE_NULL) { + from = rangeType.parseFrom(fieldType, parser, coerce.value(), includeFrom); + } + } else if (fieldName.equals(GTE_FIELD.getPreferredName())) { + includeFrom = true; + if (parser.currentToken() != XContentParser.Token.VALUE_NULL) { + from = rangeType.parseFrom(fieldType, parser, coerce.value(), includeFrom); + } + } else if (fieldName.equals(LT_FIELD.getPreferredName())) { + includeTo = false; + if (parser.currentToken() != XContentParser.Token.VALUE_NULL) { + to = rangeType.parseTo(fieldType, parser, coerce.value(), includeTo); + } + } else if (fieldName.equals(LTE_FIELD.getPreferredName())) { + includeTo = true; + if (parser.currentToken() != XContentParser.Token.VALUE_NULL) { + to = rangeType.parseTo(fieldType, parser, coerce.value(), includeTo); + } + } else { + throw new MapperParsingException( + "error parsing field [" + name() + "], with unknown parameter [" + fieldName + "]" + ); } - } else if (fieldName.equals(LT_FIELD.getPreferredName())) { - includeTo = false; - if (parser.currentToken() != XContentParser.Token.VALUE_NULL) { - to = rangeType.parseTo(fieldType, parser, coerce.value(), includeTo); + } catch (final IllegalArgumentException e) { + // We have to consume the JSON object in full + if (ignoreMalformed) { + rangeIsMalformed = true; + } else { + throw e; } - } else if (fieldName.equals(LTE_FIELD.getPreferredName())) { - includeTo = true; - if (parser.currentToken() != XContentParser.Token.VALUE_NULL) { - to = rangeType.parseTo(fieldType, parser, coerce.value(), includeTo); - } - } else { - throw new MapperParsingException( - "error parsing field [" + name() + "], with unknown parameter [" + fieldName + "]" - ); } } } + + if (rangeIsMalformed) { + context.addIgnoredField(fieldType().name()); + return; + } + range = new Range(rangeType, from, to, includeFrom, includeTo); } else if (fieldType().rangeType == RangeType.IP && start == XContentParser.Token.VALUE_STRING) { - range = parseIpRangeFromCidr(parser); + try { + range = parseIpRangeFromCidr(parser); + } catch (IllegalArgumentException e) { + if (ignoreMalformed) { + context.addIgnoredField(fieldType().name()); + return; + } else { + throw e; + } + } } else { throw new MapperParsingException( "error parsing field [" + name() + "], expected an object but got " + parser.currentName() diff --git a/server/src/test/java/org/opensearch/index/mapper/IpRangeFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/IpRangeFieldMapperTests.java index 07fa602272b3d..ce444f76eac17 100644 --- a/server/src/test/java/org/opensearch/index/mapper/IpRangeFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/IpRangeFieldMapperTests.java @@ -33,6 +33,7 @@ import org.apache.lucene.index.DocValuesType; import org.apache.lucene.index.IndexableField; +import org.opensearch.common.CheckedConsumer; import org.opensearch.common.Strings; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.compress.CompressedXContent; @@ -40,10 +41,13 @@ import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.IndexService; +import org.opensearch.index.termvectors.TermVectorsService; import org.opensearch.test.OpenSearchSingleNodeTestCase; import org.junit.Before; +import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -76,14 +80,7 @@ public void testStoreCidr() throws Exception { cases.put("192.168.0.0/16", "192.168.255.255"); cases.put("192.168.0.0/17", "192.168.127.255"); for (final Map.Entry entry : cases.entrySet()) { - ParsedDocument doc = mapper.parse( - new SourceToParse( - "test", - "1", - BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("field", entry.getKey()).endObject()), - XContentType.JSON - ) - ); + ParsedDocument doc = mapper.parse(source(b -> b.field("field", entry.getKey()))); IndexableField[] fields = doc.rootDoc().getFields("field"); assertEquals(3, fields.length); IndexableField dvField = fields[0]; @@ -97,5 +94,88 @@ public void testStoreCidr() throws Exception { + InetAddresses.toAddrString(InetAddresses.forString(entry.getValue())); assertThat(storedField.stringValue(), containsString(strVal)); } + + // Use alternative form to populate the value: + // + // { + // "field": { + // "gte": "192.168.1.10", + // "lte": "192.168.1.15" + // } + // } + final Map params = new HashMap<>(); + params.put("gte", "192.168.1.1"); + params.put("lte", "192.168.1.15"); + + final ParsedDocument doc = mapper.parse(source(b -> b.field("field", params))); + final IndexableField[] fields = doc.rootDoc().getFields("field"); + assertEquals(3, fields.length); + + final IndexableField storedField = fields[2]; + assertThat(storedField.stringValue(), containsString("192.168.1.1 : 192.168.1.15")); + } + + public void testIgnoreMalformed() throws Exception { + final DocumentMapper mapper = parser.parse( + "type", + new CompressedXContent( + Strings.toString( + XContentFactory.jsonBuilder() + .startObject() + .startObject("type") + .startObject("properties") + .startObject("field") + .field("type", "ip_range") + .endObject() + .endObject() + .endObject() + .endObject() + ) + ) + ); + + final ThrowingRunnable runnable = () -> mapper.parse(source(b -> b.field("field", ":1"))); + final MapperParsingException e = expectThrows(MapperParsingException.class, runnable); + assertThat(e.getCause().getMessage(), containsString("Expected [ip/prefix] but was [:1]")); + + final DocumentMapper mapper2 = parser.parse( + "type", + new CompressedXContent( + Strings.toString( + XContentFactory.jsonBuilder() + .startObject() + .startObject("type") + .startObject("properties") + .startObject("field") + .field("type", "ip_range") + .field("ignore_malformed", true) + .endObject() + .endObject() + .endObject() + .endObject() + ) + ) + ); + + ParsedDocument doc = mapper2.parse(source(b -> b.field("field", ":1"))); + IndexableField[] fields = doc.rootDoc().getFields("field"); + assertEquals(0, fields.length); + assertArrayEquals(new String[] { "field" }, TermVectorsService.getValues(doc.rootDoc().getFields("_ignored"))); + + final Map params = new HashMap<>(); + params.put("gte", "x.x.x.x"); + params.put("lte", "192.168.1.15"); + + doc = mapper2.parse(source(b -> b.field("field", params))); + fields = doc.rootDoc().getFields("field"); + assertEquals(0, fields.length); + assertArrayEquals(new String[] { "field" }, TermVectorsService.getValues(doc.rootDoc().getFields("_ignored"))); + } + + private final SourceToParse source(CheckedConsumer build) throws IOException { + XContentBuilder builder = JsonXContent.contentBuilder().startObject(); + build.accept(builder); + builder.endObject(); + return new SourceToParse("test", "1", BytesReference.bytes(builder), XContentType.JSON); } } From 17f782147ad369196f4c1fbb79d995decc6e389b Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Mon, 21 Mar 2022 15:49:13 -0500 Subject: [PATCH 33/46] [Unmute] NumberFieldTypeTests (#2531) After merging Lucene 9.1 NumberFieldTypeTests is now passing. Unmute test. Signed-off-by: Nicholas Walter Knize --- .../java/org/opensearch/index/mapper/NumberFieldTypeTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/test/java/org/opensearch/index/mapper/NumberFieldTypeTests.java b/server/src/test/java/org/opensearch/index/mapper/NumberFieldTypeTests.java index 3b6d757c81b83..868261130135c 100644 --- a/server/src/test/java/org/opensearch/index/mapper/NumberFieldTypeTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/NumberFieldTypeTests.java @@ -531,7 +531,6 @@ public void doTestDocValueRangeQueries(NumberType type, Supplier valueSu dir.close(); } - @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/2063") public void testIndexSortIntRange() throws Exception { doTestIndexSortRangeQueries(NumberType.INTEGER, random()::nextInt); } From e87d7b3ee03b35121256e0adb0782a0fbf8c05ee Mon Sep 17 00:00:00 2001 From: "Kyle J. Davis" Date: Mon, 21 Mar 2022 15:29:37 -0600 Subject: [PATCH 34/46] adds ToC (#2546) Signed-off-by: Kyle J. Davis --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ec9cae6e432b2..6a9a2a69d7367 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ - [Security](#security) - [License](#license) - [Copyright](#copyright) +- [Trademark](#trademark) ## Welcome! From a9932058cded53195b6085f1d6e4da3bf27dbcee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 17:51:16 -0400 Subject: [PATCH 35/46] Bump wiremock-jre8-standalone from 2.23.2 to 2.32.0 in /buildSrc (#2525) Bumps [wiremock-jre8-standalone](https://github.com/wiremock/wiremock) from 2.23.2 to 2.32.0. - [Release notes](https://github.com/wiremock/wiremock/releases) - [Commits](https://github.com/wiremock/wiremock/compare/2.23.2...2.32.0) --- updated-dependencies: - dependency-name: com.github.tomakehurst:wiremock-jre8-standalone dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- buildSrc/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index a637782ed3cf7..f940eec593306 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -122,7 +122,7 @@ dependencies { testFixturesApi "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}" testFixturesApi gradleApi() testFixturesApi gradleTestKit() - testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone:2.23.2' + testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone:2.32.0' testImplementation "org.mockito:mockito-core:${props.getProperty('mockito')}" integTestImplementation('org.spockframework:spock-core:2.1-groovy-3.0') { exclude module: "groovy" From d43235c5cfc3f6253530bf51cb6fb4d6dd7e0154 Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Mon, 21 Mar 2022 18:44:13 -0500 Subject: [PATCH 36/46] Move Jackson-databind to 2.13.2 (#2548) Resolves CVE-2020-36518 Signed-off-by: Peter Nied --- buildSrc/version.properties | 2 +- client/sniffer/licenses/jackson-core-2.12.6.jar.sha1 | 1 - client/sniffer/licenses/jackson-core-2.13.2.jar.sha1 | 1 + .../upgrade-cli/licenses/jackson-annotations-2.12.6.jar.sha1 | 1 - .../upgrade-cli/licenses/jackson-annotations-2.13.2.jar.sha1 | 1 + .../tools/upgrade-cli/licenses/jackson-databind-2.12.6.jar.sha1 | 1 - .../tools/upgrade-cli/licenses/jackson-databind-2.13.2.jar.sha1 | 1 + libs/x-content/licenses/jackson-core-2.12.6.jar.sha1 | 1 - libs/x-content/licenses/jackson-core-2.13.2.jar.sha1 | 1 + libs/x-content/licenses/jackson-dataformat-cbor-2.12.6.jar.sha1 | 1 - libs/x-content/licenses/jackson-dataformat-cbor-2.13.2.jar.sha1 | 1 + .../x-content/licenses/jackson-dataformat-smile-2.12.6.jar.sha1 | 1 - .../x-content/licenses/jackson-dataformat-smile-2.13.2.jar.sha1 | 1 + libs/x-content/licenses/jackson-dataformat-yaml-2.12.6.jar.sha1 | 1 - libs/x-content/licenses/jackson-dataformat-yaml-2.13.2.jar.sha1 | 1 + .../ingest-geoip/licenses/jackson-annotations-2.12.6.jar.sha1 | 1 - .../ingest-geoip/licenses/jackson-annotations-2.13.2.jar.sha1 | 1 + modules/ingest-geoip/licenses/jackson-databind-2.12.6.jar.sha1 | 1 - modules/ingest-geoip/licenses/jackson-databind-2.13.2.jar.sha1 | 1 + .../discovery-ec2/licenses/jackson-annotations-2.12.6.jar.sha1 | 1 - .../discovery-ec2/licenses/jackson-annotations-2.13.2.jar.sha1 | 1 + plugins/discovery-ec2/licenses/jackson-databind-2.12.6.jar.sha1 | 1 - plugins/discovery-ec2/licenses/jackson-databind-2.13.2.jar.sha1 | 1 + .../licenses/jackson-annotations-2.12.6.jar.sha1 | 1 - .../licenses/jackson-annotations-2.13.2.jar.sha1 | 1 + .../repository-azure/licenses/jackson-databind-2.12.6.jar.sha1 | 1 - .../repository-azure/licenses/jackson-databind-2.13.2.jar.sha1 | 1 + .../licenses/jackson-dataformat-xml-2.12.6.jar.sha1 | 1 - .../licenses/jackson-dataformat-xml-2.13.2.jar.sha1 | 1 + .../licenses/jackson-datatype-jsr310-2.12.6.jar.sha1 | 1 - .../licenses/jackson-datatype-jsr310-2.13.2.jar.sha1 | 1 + .../licenses/jackson-module-jaxb-annotations-2.12.6.jar.sha1 | 1 - .../licenses/jackson-module-jaxb-annotations-2.13.2.jar.sha1 | 1 + .../repository-hdfs/licenses/jackson-databind-2.12.6.jar.sha1 | 1 - .../repository-hdfs/licenses/jackson-databind-2.13.2.jar.sha1 | 1 + .../repository-s3/licenses/jackson-annotations-2.12.6.jar.sha1 | 1 - .../repository-s3/licenses/jackson-annotations-2.13.2.jar.sha1 | 1 + plugins/repository-s3/licenses/jackson-databind-2.12.6.jar.sha1 | 1 - plugins/repository-s3/licenses/jackson-databind-2.13.2.jar.sha1 | 1 + 39 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 client/sniffer/licenses/jackson-core-2.12.6.jar.sha1 create mode 100644 client/sniffer/licenses/jackson-core-2.13.2.jar.sha1 delete mode 100644 distribution/tools/upgrade-cli/licenses/jackson-annotations-2.12.6.jar.sha1 create mode 100644 distribution/tools/upgrade-cli/licenses/jackson-annotations-2.13.2.jar.sha1 delete mode 100644 distribution/tools/upgrade-cli/licenses/jackson-databind-2.12.6.jar.sha1 create mode 100644 distribution/tools/upgrade-cli/licenses/jackson-databind-2.13.2.jar.sha1 delete mode 100644 libs/x-content/licenses/jackson-core-2.12.6.jar.sha1 create mode 100644 libs/x-content/licenses/jackson-core-2.13.2.jar.sha1 delete mode 100644 libs/x-content/licenses/jackson-dataformat-cbor-2.12.6.jar.sha1 create mode 100644 libs/x-content/licenses/jackson-dataformat-cbor-2.13.2.jar.sha1 delete mode 100644 libs/x-content/licenses/jackson-dataformat-smile-2.12.6.jar.sha1 create mode 100644 libs/x-content/licenses/jackson-dataformat-smile-2.13.2.jar.sha1 delete mode 100644 libs/x-content/licenses/jackson-dataformat-yaml-2.12.6.jar.sha1 create mode 100644 libs/x-content/licenses/jackson-dataformat-yaml-2.13.2.jar.sha1 delete mode 100644 modules/ingest-geoip/licenses/jackson-annotations-2.12.6.jar.sha1 create mode 100644 modules/ingest-geoip/licenses/jackson-annotations-2.13.2.jar.sha1 delete mode 100644 modules/ingest-geoip/licenses/jackson-databind-2.12.6.jar.sha1 create mode 100644 modules/ingest-geoip/licenses/jackson-databind-2.13.2.jar.sha1 delete mode 100644 plugins/discovery-ec2/licenses/jackson-annotations-2.12.6.jar.sha1 create mode 100644 plugins/discovery-ec2/licenses/jackson-annotations-2.13.2.jar.sha1 delete mode 100644 plugins/discovery-ec2/licenses/jackson-databind-2.12.6.jar.sha1 create mode 100644 plugins/discovery-ec2/licenses/jackson-databind-2.13.2.jar.sha1 delete mode 100644 plugins/repository-azure/licenses/jackson-annotations-2.12.6.jar.sha1 create mode 100644 plugins/repository-azure/licenses/jackson-annotations-2.13.2.jar.sha1 delete mode 100644 plugins/repository-azure/licenses/jackson-databind-2.12.6.jar.sha1 create mode 100644 plugins/repository-azure/licenses/jackson-databind-2.13.2.jar.sha1 delete mode 100644 plugins/repository-azure/licenses/jackson-dataformat-xml-2.12.6.jar.sha1 create mode 100644 plugins/repository-azure/licenses/jackson-dataformat-xml-2.13.2.jar.sha1 delete mode 100644 plugins/repository-azure/licenses/jackson-datatype-jsr310-2.12.6.jar.sha1 create mode 100644 plugins/repository-azure/licenses/jackson-datatype-jsr310-2.13.2.jar.sha1 delete mode 100644 plugins/repository-azure/licenses/jackson-module-jaxb-annotations-2.12.6.jar.sha1 create mode 100644 plugins/repository-azure/licenses/jackson-module-jaxb-annotations-2.13.2.jar.sha1 delete mode 100644 plugins/repository-hdfs/licenses/jackson-databind-2.12.6.jar.sha1 create mode 100644 plugins/repository-hdfs/licenses/jackson-databind-2.13.2.jar.sha1 delete mode 100644 plugins/repository-s3/licenses/jackson-annotations-2.12.6.jar.sha1 create mode 100644 plugins/repository-s3/licenses/jackson-annotations-2.13.2.jar.sha1 delete mode 100644 plugins/repository-s3/licenses/jackson-databind-2.12.6.jar.sha1 create mode 100644 plugins/repository-s3/licenses/jackson-databind-2.13.2.jar.sha1 diff --git a/buildSrc/version.properties b/buildSrc/version.properties index 1486ce4b6e44c..b5e14cd24bd93 100644 --- a/buildSrc/version.properties +++ b/buildSrc/version.properties @@ -9,7 +9,7 @@ bundled_jdk = 17.0.2+8 # optional dependencies spatial4j = 0.7 jts = 1.15.0 -jackson = 2.12.6 +jackson = 2.13.2 snakeyaml = 1.26 icu4j = 70.1 supercsv = 2.4.0 diff --git a/client/sniffer/licenses/jackson-core-2.12.6.jar.sha1 b/client/sniffer/licenses/jackson-core-2.12.6.jar.sha1 deleted file mode 100644 index d62c70d6b0f11..0000000000000 --- a/client/sniffer/licenses/jackson-core-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -5bf206c0b5982cfcd868b3d9349dc5190db8bab5 \ No newline at end of file diff --git a/client/sniffer/licenses/jackson-core-2.13.2.jar.sha1 b/client/sniffer/licenses/jackson-core-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..eb8a8bc45f041 --- /dev/null +++ b/client/sniffer/licenses/jackson-core-2.13.2.jar.sha1 @@ -0,0 +1 @@ +0a6a0e0620d51833feffc67bccb51937b2345763 \ No newline at end of file diff --git a/distribution/tools/upgrade-cli/licenses/jackson-annotations-2.12.6.jar.sha1 b/distribution/tools/upgrade-cli/licenses/jackson-annotations-2.12.6.jar.sha1 deleted file mode 100644 index 48ee3bf53c630..0000000000000 --- a/distribution/tools/upgrade-cli/licenses/jackson-annotations-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -9487231edd6b0b1f14692c9cba9e0462809215d1 \ No newline at end of file diff --git a/distribution/tools/upgrade-cli/licenses/jackson-annotations-2.13.2.jar.sha1 b/distribution/tools/upgrade-cli/licenses/jackson-annotations-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..ecd3fb49d5b12 --- /dev/null +++ b/distribution/tools/upgrade-cli/licenses/jackson-annotations-2.13.2.jar.sha1 @@ -0,0 +1 @@ +ec18851f1976d5b810ae1a5fcc32520d2d38f77a \ No newline at end of file diff --git a/distribution/tools/upgrade-cli/licenses/jackson-databind-2.12.6.jar.sha1 b/distribution/tools/upgrade-cli/licenses/jackson-databind-2.12.6.jar.sha1 deleted file mode 100644 index f74842887d31b..0000000000000 --- a/distribution/tools/upgrade-cli/licenses/jackson-databind-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fac216b606c1086e36acea6e572ee61572ad1670 \ No newline at end of file diff --git a/distribution/tools/upgrade-cli/licenses/jackson-databind-2.13.2.jar.sha1 b/distribution/tools/upgrade-cli/licenses/jackson-databind-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..5d356f3fd045f --- /dev/null +++ b/distribution/tools/upgrade-cli/licenses/jackson-databind-2.13.2.jar.sha1 @@ -0,0 +1 @@ +926e48c451166a291f1ce6c6276d9abbefa7c00f \ No newline at end of file diff --git a/libs/x-content/licenses/jackson-core-2.12.6.jar.sha1 b/libs/x-content/licenses/jackson-core-2.12.6.jar.sha1 deleted file mode 100644 index d62c70d6b0f11..0000000000000 --- a/libs/x-content/licenses/jackson-core-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -5bf206c0b5982cfcd868b3d9349dc5190db8bab5 \ No newline at end of file diff --git a/libs/x-content/licenses/jackson-core-2.13.2.jar.sha1 b/libs/x-content/licenses/jackson-core-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..eb8a8bc45f041 --- /dev/null +++ b/libs/x-content/licenses/jackson-core-2.13.2.jar.sha1 @@ -0,0 +1 @@ +0a6a0e0620d51833feffc67bccb51937b2345763 \ No newline at end of file diff --git a/libs/x-content/licenses/jackson-dataformat-cbor-2.12.6.jar.sha1 b/libs/x-content/licenses/jackson-dataformat-cbor-2.12.6.jar.sha1 deleted file mode 100644 index 9fdb5a5012b8d..0000000000000 --- a/libs/x-content/licenses/jackson-dataformat-cbor-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -3cd2e6a538f73483c6c59c354ce2276bcdc5ba7b \ No newline at end of file diff --git a/libs/x-content/licenses/jackson-dataformat-cbor-2.13.2.jar.sha1 b/libs/x-content/licenses/jackson-dataformat-cbor-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..3a4f0e1b17565 --- /dev/null +++ b/libs/x-content/licenses/jackson-dataformat-cbor-2.13.2.jar.sha1 @@ -0,0 +1 @@ +4fc77e1ec6922fc48bf1181e4b38f600dac222ff \ No newline at end of file diff --git a/libs/x-content/licenses/jackson-dataformat-smile-2.12.6.jar.sha1 b/libs/x-content/licenses/jackson-dataformat-smile-2.12.6.jar.sha1 deleted file mode 100644 index a8eb043684fac..0000000000000 --- a/libs/x-content/licenses/jackson-dataformat-smile-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -bc9b6bcf12a14382424324ee067456ee354a0dfb \ No newline at end of file diff --git a/libs/x-content/licenses/jackson-dataformat-smile-2.13.2.jar.sha1 b/libs/x-content/licenses/jackson-dataformat-smile-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..86a53f72de66e --- /dev/null +++ b/libs/x-content/licenses/jackson-dataformat-smile-2.13.2.jar.sha1 @@ -0,0 +1 @@ +984bb22f310ebbedc967d206e672f8acf766a98e \ No newline at end of file diff --git a/libs/x-content/licenses/jackson-dataformat-yaml-2.12.6.jar.sha1 b/libs/x-content/licenses/jackson-dataformat-yaml-2.12.6.jar.sha1 deleted file mode 100644 index e2ed10942b3b6..0000000000000 --- a/libs/x-content/licenses/jackson-dataformat-yaml-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -cfba448bc4e92b8656968756a9c4af1ad8e502e4 \ No newline at end of file diff --git a/libs/x-content/licenses/jackson-dataformat-yaml-2.13.2.jar.sha1 b/libs/x-content/licenses/jackson-dataformat-yaml-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..1cba175acf2ae --- /dev/null +++ b/libs/x-content/licenses/jackson-dataformat-yaml-2.13.2.jar.sha1 @@ -0,0 +1 @@ +5601496b5b6e43d947aeeffbffadb2b18961c731 \ No newline at end of file diff --git a/modules/ingest-geoip/licenses/jackson-annotations-2.12.6.jar.sha1 b/modules/ingest-geoip/licenses/jackson-annotations-2.12.6.jar.sha1 deleted file mode 100644 index 48ee3bf53c630..0000000000000 --- a/modules/ingest-geoip/licenses/jackson-annotations-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -9487231edd6b0b1f14692c9cba9e0462809215d1 \ No newline at end of file diff --git a/modules/ingest-geoip/licenses/jackson-annotations-2.13.2.jar.sha1 b/modules/ingest-geoip/licenses/jackson-annotations-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..ecd3fb49d5b12 --- /dev/null +++ b/modules/ingest-geoip/licenses/jackson-annotations-2.13.2.jar.sha1 @@ -0,0 +1 @@ +ec18851f1976d5b810ae1a5fcc32520d2d38f77a \ No newline at end of file diff --git a/modules/ingest-geoip/licenses/jackson-databind-2.12.6.jar.sha1 b/modules/ingest-geoip/licenses/jackson-databind-2.12.6.jar.sha1 deleted file mode 100644 index f74842887d31b..0000000000000 --- a/modules/ingest-geoip/licenses/jackson-databind-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fac216b606c1086e36acea6e572ee61572ad1670 \ No newline at end of file diff --git a/modules/ingest-geoip/licenses/jackson-databind-2.13.2.jar.sha1 b/modules/ingest-geoip/licenses/jackson-databind-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..5d356f3fd045f --- /dev/null +++ b/modules/ingest-geoip/licenses/jackson-databind-2.13.2.jar.sha1 @@ -0,0 +1 @@ +926e48c451166a291f1ce6c6276d9abbefa7c00f \ No newline at end of file diff --git a/plugins/discovery-ec2/licenses/jackson-annotations-2.12.6.jar.sha1 b/plugins/discovery-ec2/licenses/jackson-annotations-2.12.6.jar.sha1 deleted file mode 100644 index 48ee3bf53c630..0000000000000 --- a/plugins/discovery-ec2/licenses/jackson-annotations-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -9487231edd6b0b1f14692c9cba9e0462809215d1 \ No newline at end of file diff --git a/plugins/discovery-ec2/licenses/jackson-annotations-2.13.2.jar.sha1 b/plugins/discovery-ec2/licenses/jackson-annotations-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..ecd3fb49d5b12 --- /dev/null +++ b/plugins/discovery-ec2/licenses/jackson-annotations-2.13.2.jar.sha1 @@ -0,0 +1 @@ +ec18851f1976d5b810ae1a5fcc32520d2d38f77a \ No newline at end of file diff --git a/plugins/discovery-ec2/licenses/jackson-databind-2.12.6.jar.sha1 b/plugins/discovery-ec2/licenses/jackson-databind-2.12.6.jar.sha1 deleted file mode 100644 index f74842887d31b..0000000000000 --- a/plugins/discovery-ec2/licenses/jackson-databind-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fac216b606c1086e36acea6e572ee61572ad1670 \ No newline at end of file diff --git a/plugins/discovery-ec2/licenses/jackson-databind-2.13.2.jar.sha1 b/plugins/discovery-ec2/licenses/jackson-databind-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..5d356f3fd045f --- /dev/null +++ b/plugins/discovery-ec2/licenses/jackson-databind-2.13.2.jar.sha1 @@ -0,0 +1 @@ +926e48c451166a291f1ce6c6276d9abbefa7c00f \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-annotations-2.12.6.jar.sha1 b/plugins/repository-azure/licenses/jackson-annotations-2.12.6.jar.sha1 deleted file mode 100644 index 48ee3bf53c630..0000000000000 --- a/plugins/repository-azure/licenses/jackson-annotations-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -9487231edd6b0b1f14692c9cba9e0462809215d1 \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-annotations-2.13.2.jar.sha1 b/plugins/repository-azure/licenses/jackson-annotations-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..ecd3fb49d5b12 --- /dev/null +++ b/plugins/repository-azure/licenses/jackson-annotations-2.13.2.jar.sha1 @@ -0,0 +1 @@ +ec18851f1976d5b810ae1a5fcc32520d2d38f77a \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-databind-2.12.6.jar.sha1 b/plugins/repository-azure/licenses/jackson-databind-2.12.6.jar.sha1 deleted file mode 100644 index f74842887d31b..0000000000000 --- a/plugins/repository-azure/licenses/jackson-databind-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fac216b606c1086e36acea6e572ee61572ad1670 \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-databind-2.13.2.jar.sha1 b/plugins/repository-azure/licenses/jackson-databind-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..5d356f3fd045f --- /dev/null +++ b/plugins/repository-azure/licenses/jackson-databind-2.13.2.jar.sha1 @@ -0,0 +1 @@ +926e48c451166a291f1ce6c6276d9abbefa7c00f \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-dataformat-xml-2.12.6.jar.sha1 b/plugins/repository-azure/licenses/jackson-dataformat-xml-2.12.6.jar.sha1 deleted file mode 100644 index 43ee9816d99e3..0000000000000 --- a/plugins/repository-azure/licenses/jackson-dataformat-xml-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fecb8514c3a89102bd619b6c624f906a6098b588 \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-dataformat-xml-2.13.2.jar.sha1 b/plugins/repository-azure/licenses/jackson-dataformat-xml-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..7d020f81a91ba --- /dev/null +++ b/plugins/repository-azure/licenses/jackson-dataformat-xml-2.13.2.jar.sha1 @@ -0,0 +1 @@ +cb6a722f128ff0ce2494384d419b6ff20fad25ab \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-datatype-jsr310-2.12.6.jar.sha1 b/plugins/repository-azure/licenses/jackson-datatype-jsr310-2.12.6.jar.sha1 deleted file mode 100644 index d005cc1bd5f11..0000000000000 --- a/plugins/repository-azure/licenses/jackson-datatype-jsr310-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -0f7d0d854f24c4254885c275a09fb885ef578b48 \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-datatype-jsr310-2.13.2.jar.sha1 b/plugins/repository-azure/licenses/jackson-datatype-jsr310-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..979d38bb38784 --- /dev/null +++ b/plugins/repository-azure/licenses/jackson-datatype-jsr310-2.13.2.jar.sha1 @@ -0,0 +1 @@ +cddd9380efd4b81ea01e98be8fbdc9765a81793b \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-module-jaxb-annotations-2.12.6.jar.sha1 b/plugins/repository-azure/licenses/jackson-module-jaxb-annotations-2.12.6.jar.sha1 deleted file mode 100644 index 686d813e002c8..0000000000000 --- a/plugins/repository-azure/licenses/jackson-module-jaxb-annotations-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -a0bea2c6f98eb0dc24208b54a53da80ea459c156 \ No newline at end of file diff --git a/plugins/repository-azure/licenses/jackson-module-jaxb-annotations-2.13.2.jar.sha1 b/plugins/repository-azure/licenses/jackson-module-jaxb-annotations-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..c71c4fe5ee90c --- /dev/null +++ b/plugins/repository-azure/licenses/jackson-module-jaxb-annotations-2.13.2.jar.sha1 @@ -0,0 +1 @@ +e2f198c512f0f0ccbd6d618baecc9dde9975eadf \ No newline at end of file diff --git a/plugins/repository-hdfs/licenses/jackson-databind-2.12.6.jar.sha1 b/plugins/repository-hdfs/licenses/jackson-databind-2.12.6.jar.sha1 deleted file mode 100644 index f74842887d31b..0000000000000 --- a/plugins/repository-hdfs/licenses/jackson-databind-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fac216b606c1086e36acea6e572ee61572ad1670 \ No newline at end of file diff --git a/plugins/repository-hdfs/licenses/jackson-databind-2.13.2.jar.sha1 b/plugins/repository-hdfs/licenses/jackson-databind-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..5d356f3fd045f --- /dev/null +++ b/plugins/repository-hdfs/licenses/jackson-databind-2.13.2.jar.sha1 @@ -0,0 +1 @@ +926e48c451166a291f1ce6c6276d9abbefa7c00f \ No newline at end of file diff --git a/plugins/repository-s3/licenses/jackson-annotations-2.12.6.jar.sha1 b/plugins/repository-s3/licenses/jackson-annotations-2.12.6.jar.sha1 deleted file mode 100644 index 48ee3bf53c630..0000000000000 --- a/plugins/repository-s3/licenses/jackson-annotations-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -9487231edd6b0b1f14692c9cba9e0462809215d1 \ No newline at end of file diff --git a/plugins/repository-s3/licenses/jackson-annotations-2.13.2.jar.sha1 b/plugins/repository-s3/licenses/jackson-annotations-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..ecd3fb49d5b12 --- /dev/null +++ b/plugins/repository-s3/licenses/jackson-annotations-2.13.2.jar.sha1 @@ -0,0 +1 @@ +ec18851f1976d5b810ae1a5fcc32520d2d38f77a \ No newline at end of file diff --git a/plugins/repository-s3/licenses/jackson-databind-2.12.6.jar.sha1 b/plugins/repository-s3/licenses/jackson-databind-2.12.6.jar.sha1 deleted file mode 100644 index f74842887d31b..0000000000000 --- a/plugins/repository-s3/licenses/jackson-databind-2.12.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fac216b606c1086e36acea6e572ee61572ad1670 \ No newline at end of file diff --git a/plugins/repository-s3/licenses/jackson-databind-2.13.2.jar.sha1 b/plugins/repository-s3/licenses/jackson-databind-2.13.2.jar.sha1 new file mode 100644 index 0000000000000..5d356f3fd045f --- /dev/null +++ b/plugins/repository-s3/licenses/jackson-databind-2.13.2.jar.sha1 @@ -0,0 +1 @@ +926e48c451166a291f1ce6c6276d9abbefa7c00f \ No newline at end of file From 42aa7ab68aed7548136c0dd61abd6d37eeca262c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 18:46:53 -0500 Subject: [PATCH 37/46] Bump google-cloud-core from 1.93.3 to 2.5.10 in /plugins/repository-gcs (#2536) Bumps [google-cloud-core](https://github.com/googleapis/java-core) from 1.93.3 to 2.5.10. - [Release notes](https://github.com/googleapis/java-core/releases) - [Changelog](https://github.com/googleapis/java-core/blob/main/CHANGELOG.md) - [Commits](https://github.com/googleapis/java-core/compare/v1.93.3...v2.5.10) --- updated-dependencies: - dependency-name: com.google.cloud:google-cloud-core dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: Vacha Shah Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] Co-authored-by: Vacha Shah --- plugins/repository-gcs/build.gradle | 3 ++- .../repository-gcs/licenses/google-cloud-core-1.93.3.jar.sha1 | 1 - .../repository-gcs/licenses/google-cloud-core-2.5.10.jar.sha1 | 1 + .../licenses/google-http-client-gson-1.41.4.jar.sha1 | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 plugins/repository-gcs/licenses/google-cloud-core-1.93.3.jar.sha1 create mode 100644 plugins/repository-gcs/licenses/google-cloud-core-2.5.10.jar.sha1 create mode 100644 plugins/repository-gcs/licenses/google-http-client-gson-1.41.4.jar.sha1 diff --git a/plugins/repository-gcs/build.gradle b/plugins/repository-gcs/build.gradle index c7e7bc5f40cce..67943c069d633 100644 --- a/plugins/repository-gcs/build.gradle +++ b/plugins/repository-gcs/build.gradle @@ -51,7 +51,7 @@ opensearchplugin { dependencies { api 'com.google.cloud:google-cloud-storage:1.113.1' - api 'com.google.cloud:google-cloud-core:1.93.3' + api 'com.google.cloud:google-cloud-core:2.5.10' runtimeOnly 'com.google.guava:guava:30.1.1-jre' api 'com.google.guava:failureaccess:1.0.1' api 'com.google.http-client:google-http-client:1.35.0' @@ -73,6 +73,7 @@ dependencies { api 'com.google.api-client:google-api-client:1.30.10' api 'com.google.http-client:google-http-client-appengine:1.35.0' api 'com.google.http-client:google-http-client-jackson2:1.35.0' + api 'com.google.http-client:google-http-client-gson:1.41.4' api 'com.google.api:gax-httpjson:0.62.0' api 'io.grpc:grpc-context:1.29.0' api 'io.opencensus:opencensus-api:0.18.0' diff --git a/plugins/repository-gcs/licenses/google-cloud-core-1.93.3.jar.sha1 b/plugins/repository-gcs/licenses/google-cloud-core-1.93.3.jar.sha1 deleted file mode 100644 index fbbcf804bc541..0000000000000 --- a/plugins/repository-gcs/licenses/google-cloud-core-1.93.3.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -6fc017c0908456c0867d21c85d1b906662d4b5f1 \ No newline at end of file diff --git a/plugins/repository-gcs/licenses/google-cloud-core-2.5.10.jar.sha1 b/plugins/repository-gcs/licenses/google-cloud-core-2.5.10.jar.sha1 new file mode 100644 index 0000000000000..34c3dc6805500 --- /dev/null +++ b/plugins/repository-gcs/licenses/google-cloud-core-2.5.10.jar.sha1 @@ -0,0 +1 @@ +4d979bfe28551eb78cddae9282833ede147a9331 \ No newline at end of file diff --git a/plugins/repository-gcs/licenses/google-http-client-gson-1.41.4.jar.sha1 b/plugins/repository-gcs/licenses/google-http-client-gson-1.41.4.jar.sha1 new file mode 100644 index 0000000000000..17960a99abea2 --- /dev/null +++ b/plugins/repository-gcs/licenses/google-http-client-gson-1.41.4.jar.sha1 @@ -0,0 +1 @@ +fa665c1c573765dd858bc34931ad747e4ed11efe \ No newline at end of file From 4bb8add982bb2b192d1a1675ddb01ad5ddb95309 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Mon, 21 Mar 2022 18:47:49 -0500 Subject: [PATCH 38/46] Support for geo_distance queries on geo_shape fields (#2516) Adds support for using the geo_distance query on geo_shape field types by lifting the geo_point restriction in the QueryBuilder. Distance query integration tests are abstracted to test both geo_point and geo_shape field types. Signed-off-by: Nicholas Walter Knize --- ...anceIT.java => AbstractGeoDistanceIT.java} | 107 ++++++++++++++---- .../geo/GeoDistanceQueryGeoPointsIT.java | 28 +++++ .../geo/GeoDistanceQueryGeoShapesIT.java | 44 +++++++ .../index/query/GeoDistanceQueryBuilder.java | 38 ++++--- .../query/GeoDistanceQueryBuilderTests.java | 15 ++- 5 files changed, 194 insertions(+), 38 deletions(-) rename server/src/internalClusterTest/java/org/opensearch/search/geo/{GeoDistanceIT.java => AbstractGeoDistanceIT.java} (71%) create mode 100644 server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceQueryGeoPointsIT.java create mode 100644 server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceQueryGeoShapesIT.java diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/AbstractGeoDistanceIT.java similarity index 71% rename from server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceIT.java rename to server/src/internalClusterTest/java/org/opensearch/search/geo/AbstractGeoDistanceIT.java index ba7af0ecfcb06..d28410ec170d4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/AbstractGeoDistanceIT.java @@ -44,18 +44,19 @@ import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.geometry.utils.Geohash; import org.opensearch.index.fielddata.ScriptDocValues; +import org.opensearch.index.query.IdsQueryBuilder; import org.opensearch.index.query.QueryBuilders; import org.opensearch.plugins.Plugin; import org.opensearch.script.MockScriptPlugin; import org.opensearch.script.Script; import org.opensearch.script.ScriptType; +import org.opensearch.search.SearchHit; import org.opensearch.search.aggregations.AggregationBuilders; import org.opensearch.search.aggregations.Aggregations; import org.opensearch.search.aggregations.bucket.range.InternalGeoDistance; import org.opensearch.search.aggregations.bucket.range.Range; import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.test.VersionUtils; -import org.junit.Before; import java.io.IOException; import java.util.Collection; @@ -65,11 +66,14 @@ import java.util.Map; import java.util.function.Function; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.equalTo; import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; import static org.hamcrest.Matchers.closeTo; -public class GeoDistanceIT extends OpenSearchIntegTestCase { +/** base class for testing geo_distance queries on geo_ field types */ +abstract class AbstractGeoDistanceIT extends OpenSearchIntegTestCase { private static final double src_lat = 32.798; private static final double src_lon = -117.151; @@ -118,30 +122,89 @@ protected boolean forbidPrivateIndexSettings() { return false; } - @Before - public void setupTestIndex() throws IOException { + protected void indexSetup() throws IOException { Version version = VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() - .startObject() - .startObject("properties") - .startObject("location") - .field("type", "geo_point"); - xContentBuilder.endObject().endObject().endObject(); + XContentBuilder xContentBuilder = getMapping(); assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder)); ensureGreen(); + + client().prepareIndex("test") + .setId("1") + .setSource(jsonBuilder().startObject().field("name", "New York").field("location", "POINT(-74.0059731 40.7143528)").endObject()) + .get(); + + // to NY: 5.286 km + client().prepareIndex("test") + .setId("2") + .setSource( + jsonBuilder().startObject().field("name", "Times Square").field("location", "POINT(-73.9844722 40.759011)").endObject() + ) + .get(); + + // to NY: 0.4621 km + client().prepareIndex("test") + .setId("3") + .setSource(jsonBuilder().startObject().field("name", "Tribeca").field("location", "POINT(-74.007819 40.718266)").endObject()) + .get(); + + // to NY: 1.055 km + client().prepareIndex("test") + .setId("4") + .setSource( + jsonBuilder().startObject().field("name", "Wall Street").field("location", "POINT(-74.0088305 40.7051157)").endObject() + ) + .get(); + + // to NY: 1.258 km + client().prepareIndex("test") + .setId("5") + .setSource(jsonBuilder().startObject().field("name", "Soho").field("location", "POINT(-74 40.7247222)").endObject()) + .get(); + + // to NY: 2.029 km + client().prepareIndex("test") + .setId("6") + .setSource( + jsonBuilder().startObject().field("name", "Greenwich Village").field("location", "POINT(-73.9962255 40.731033)").endObject() + ) + .get(); + + // to NY: 8.572 km + client().prepareIndex("test") + .setId("7") + .setSource(jsonBuilder().startObject().field("name", "Brooklyn").field("location", "POINT(-73.95 40.65)").endObject()) + .get(); + + client().admin().indices().prepareRefresh().get(); + } + + public abstract XContentBuilder addGeoMapping(XContentBuilder parentMapping) throws IOException; + + public XContentBuilder getMapping() throws IOException { + XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties"); + mapping = addGeoMapping(mapping); + return mapping.endObject().endObject(); + } + + public void testSimpleDistanceQuery() { + SearchResponse searchResponse = client().prepareSearch() // from NY + .setQuery(QueryBuilders.geoDistanceQuery("location").point(40.5, -73.9).distance(25, DistanceUnit.KILOMETERS)) + .get(); + assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L)); + assertThat(searchResponse.getHits().getHits().length, equalTo(2)); + for (SearchHit hit : searchResponse.getHits()) { + assertThat(hit.getId(), anyOf(equalTo("7"), equalTo("4"))); + } } public void testDistanceScript() throws Exception { client().prepareIndex("test") - .setId("1") + .setId("8") .setSource( jsonBuilder().startObject() .field("name", "TestPosition") - .startObject("location") - .field("lat", src_lat) - .field("lon", src_lon) - .endObject() + .field("location", "POINT(" + src_lon + " " + src_lat + ")") .endObject() ) .get(); @@ -150,6 +213,7 @@ public void testDistanceScript() throws Exception { // Test doc['location'].arcDistance(lat, lon) SearchResponse searchResponse1 = client().prepareSearch() + .setQuery(new IdsQueryBuilder().addIds("8")) .addStoredField("_source") .addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance", Collections.emptyMap())) .get(); @@ -158,6 +222,7 @@ public void testDistanceScript() throws Exception { // Test doc['location'].planeDistance(lat, lon) SearchResponse searchResponse2 = client().prepareSearch() + .setQuery(new IdsQueryBuilder().addIds("8")) .addStoredField("_source") .addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "planeDistance", Collections.emptyMap())) .get(); @@ -166,6 +231,7 @@ public void testDistanceScript() throws Exception { // Test doc['location'].geohashDistance(lat, lon) SearchResponse searchResponse4 = client().prepareSearch() + .setQuery(new IdsQueryBuilder().addIds("8")) .addStoredField("_source") .addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "geohashDistance", Collections.emptyMap())) .get(); @@ -180,6 +246,7 @@ public void testDistanceScript() throws Exception { // Test doc['location'].arcDistance(lat, lon + 360)/1000d SearchResponse searchResponse5 = client().prepareSearch() + .setQuery(new IdsQueryBuilder().addIds("8")) .addStoredField("_source") .addScriptField( "distance", @@ -191,6 +258,7 @@ public void testDistanceScript() throws Exception { // Test doc['location'].arcDistance(lat + 360, lon)/1000d SearchResponse searchResponse6 = client().prepareSearch() + .setQuery(new IdsQueryBuilder().addIds("8")) .addStoredField("_source") .addScriptField( "distance", @@ -207,10 +275,7 @@ public void testGeoDistanceAggregation() throws IOException { .setSource( jsonBuilder().startObject() .field("name", "TestPosition") - .startObject("location") - .field("lat", src_lat) - .field("lon", src_lon) - .endObject() + .field("location", "POINT(" + src_lon + " " + src_lat + ")") .endObject() ) .get(); @@ -225,7 +290,7 @@ public void testGeoDistanceAggregation() throws IOException { AggregationBuilders.geoDistance(name, new GeoPoint(tgt_lat, tgt_lon)) .field("location") .unit(DistanceUnit.MILES) - .addRange(0, 25000) + .addRange(0, 25000) // limits the distance (expected to omit one point outside this range) ); search.setSize(0); // no hits please @@ -239,6 +304,6 @@ public void testGeoDistanceAggregation() throws IOException { List buckets = ((Range) geoDistance).getBuckets(); assertNotNull("Buckets should not be null", buckets); assertEquals("Unexpected number of buckets", 1, buckets.size()); - assertEquals("Unexpected doc count for geo distance", 1, buckets.get(0).getDocCount()); + assertEquals("Unexpected doc count for geo distance", 7, buckets.get(0).getDocCount()); } } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceQueryGeoPointsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceQueryGeoPointsIT.java new file mode 100644 index 0000000000000..af19763577666 --- /dev/null +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceQueryGeoPointsIT.java @@ -0,0 +1,28 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.search.geo; + +import org.junit.Before; +import org.opensearch.common.xcontent.XContentBuilder; + +import java.io.IOException; + +/** Tests geo_distance queries on geo_point field types */ +public class GeoDistanceQueryGeoPointsIT extends AbstractGeoDistanceIT { + + @Before + public void setupTestIndex() throws IOException { + indexSetup(); + } + + @Override + public XContentBuilder addGeoMapping(XContentBuilder parentMapping) throws IOException { + return parentMapping.startObject("location").field("type", "geo_point").endObject(); + } +} diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceQueryGeoShapesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceQueryGeoShapesIT.java new file mode 100644 index 0000000000000..f7e0b7dda4b2c --- /dev/null +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceQueryGeoShapesIT.java @@ -0,0 +1,44 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.search.geo; + +import org.junit.Before; +import org.opensearch.common.xcontent.XContentBuilder; + +import java.io.IOException; + +/** Tests geo_distance queries on geo_shape field types */ +public class GeoDistanceQueryGeoShapesIT extends AbstractGeoDistanceIT { + + @Before + public void setupTestIndex() throws IOException { + indexSetup(); + } + + @Override + public XContentBuilder addGeoMapping(XContentBuilder parentMapping) throws IOException { + parentMapping = parentMapping.startObject("location").field("type", "geo_shape"); + if (randomBoolean()) { + parentMapping.field("strategy", "recursive"); + } + return parentMapping.endObject(); + } + + @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/2515") + @Override + public void testDistanceScript() { + // no-op; todo script support for distance calculation on shapes cannot be added until GeoShapeDocValues is added + } + + @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/2515") + @Override + public void testGeoDistanceAggregation() { + // no-op; todo aggregation support for distance calculation on shapes cannot be added until GeoShapeDocValues is added + } +} diff --git a/server/src/main/java/org/opensearch/index/query/GeoDistanceQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/GeoDistanceQueryBuilder.java index e3b1ad32fdfb3..9fb3ef262ab63 100644 --- a/server/src/main/java/org/opensearch/index/query/GeoDistanceQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/GeoDistanceQueryBuilder.java @@ -32,9 +32,6 @@ package org.opensearch.index.query; -import org.apache.lucene.document.LatLonDocValuesField; -import org.apache.lucene.document.LatLonPoint; -import org.apache.lucene.search.IndexOrDocValuesQuery; import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; import org.opensearch.common.ParseField; @@ -43,12 +40,17 @@ import org.opensearch.common.geo.GeoDistance; import org.opensearch.common.geo.GeoPoint; import org.opensearch.common.geo.GeoUtils; +import org.opensearch.common.geo.ShapeRelation; +import org.opensearch.common.geo.SpatialStrategy; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.unit.DistanceUnit; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentParser; -import org.opensearch.index.mapper.GeoPointFieldMapper.GeoPointFieldType; +import org.opensearch.geometry.Circle; +import org.opensearch.index.mapper.GeoPointFieldMapper; +import org.opensearch.index.mapper.GeoShapeFieldMapper; +import org.opensearch.index.mapper.GeoShapeQueryable; import org.opensearch.index.mapper.MappedFieldType; import java.io.IOException; @@ -245,12 +247,25 @@ protected Query doToQuery(QueryShardContext shardContext) throws IOException { if (ignoreUnmapped) { return new MatchNoDocsQuery(); } else { - throw new QueryShardException(shardContext, "failed to find geo_point field [" + fieldName + "]"); + throw new QueryShardException(shardContext, "failed to find geo field [" + fieldName + "]"); } } - if (!(fieldType instanceof GeoPointFieldType)) { - throw new QueryShardException(shardContext, "field [" + fieldName + "] is not a geo_point field"); + if (fieldType instanceof GeoShapeQueryable == false) { + throw new QueryShardException( + shardContext, + "type [" + + fieldType + + "] for field [" + + fieldName + + "] is not supported for [" + + NAME + + "] queries. Must be one of [" + + GeoPointFieldMapper.CONTENT_TYPE + + "] or [" + + GeoShapeFieldMapper.CONTENT_TYPE + + "]" + ); } QueryValidationException exception = checkLatLon(); @@ -262,12 +277,9 @@ protected Query doToQuery(QueryShardContext shardContext) throws IOException { GeoUtils.normalizePoint(center, true, true); } - Query query = LatLonPoint.newDistanceQuery(fieldType.name(), center.lat(), center.lon(), this.distance); - if (fieldType.hasDocValues()) { - Query dvQuery = LatLonDocValuesField.newSlowDistanceQuery(fieldType.name(), center.lat(), center.lon(), this.distance); - query = new IndexOrDocValuesQuery(query, dvQuery); - } - return query; + final GeoShapeQueryable geoShapeQueryable = (GeoShapeQueryable) fieldType; + final Circle circle = new Circle(center.lon(), center.lat(), this.distance); + return geoShapeQueryable.geoShapeQuery(circle, fieldType.name(), SpatialStrategy.RECURSIVE, ShapeRelation.INTERSECTS, shardContext); } @Override diff --git a/server/src/test/java/org/opensearch/index/query/GeoDistanceQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/GeoDistanceQueryBuilderTests.java index 8385a25a29a1d..8ef34fcb8225b 100644 --- a/server/src/test/java/org/opensearch/index/query/GeoDistanceQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/GeoDistanceQueryBuilderTests.java @@ -41,6 +41,9 @@ import org.opensearch.common.geo.GeoDistance; import org.opensearch.common.geo.GeoPoint; import org.opensearch.common.unit.DistanceUnit; +import org.opensearch.index.mapper.GeoPointFieldMapper; +import org.opensearch.index.mapper.GeoShapeFieldMapper; +import org.opensearch.index.mapper.MappedFieldType; import org.opensearch.test.AbstractQueryTestCase; import org.opensearch.test.geo.RandomShapeGenerator; import org.locationtech.spatial4j.shape.Point; @@ -55,7 +58,7 @@ public class GeoDistanceQueryBuilderTests extends AbstractQueryTestCase failingQueryBuilder.toQuery(shardContext)); - assertThat(e.getMessage(), containsString("failed to find geo_point field [unmapped]")); + assertThat(e.getMessage(), containsString("failed to find geo field [unmapped]")); } public void testParseFailsWithMultipleFields() throws IOException { From 59d1e6912951884df56da24bf06bd4cc33b12476 Mon Sep 17 00:00:00 2001 From: Suraj Singh <79435743+dreamer-89@users.noreply.github.com> Date: Mon, 21 Mar 2022 16:49:18 -0700 Subject: [PATCH 39/46] [Remove] Types from PutIndexTemplateRequest and builder to reduce mapping to a string (#2510) Signed-off-by: Suraj Singh --- .../cluster/SimpleClusterStateIT.java | 10 +-- .../gateway/RecoveryFromGatewayIT.java | 5 +- .../template/IndexTemplateBlocksIT.java | 5 +- .../template/SimpleIndexTemplateIT.java | 64 +++----------- .../snapshots/RestoreSnapshotIT.java | 5 +- .../SnapshotCustomPluginStateIT.java | 5 +- .../template/put/PutIndexTemplateRequest.java | 86 ++++++++++--------- .../put/PutIndexTemplateRequestBuilder.java | 21 +---- .../MetadataIndexTemplateService.java | 17 ++-- .../put/PutIndexTemplateRequestTests.java | 16 ++-- .../MetadataIndexTemplateServiceTests.java | 11 +-- 11 files changed, 85 insertions(+), 160 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleClusterStateIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleClusterStateIT.java index fcf5dcf3891ce..19f7b0b4c630c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleClusterStateIT.java @@ -166,11 +166,9 @@ public void testIndexTemplates() throws Exception { .preparePutTemplate("foo_template") .setPatterns(Collections.singletonList("te*")) .setOrder(0) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -182,7 +180,6 @@ public void testIndexTemplates() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .get(); @@ -191,11 +188,9 @@ public void testIndexTemplates() throws Exception { .preparePutTemplate("fuu_template") .setPatterns(Collections.singletonList("test*")) .setOrder(1) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field2") .field("type", "text") @@ -203,7 +198,6 @@ public void testIndexTemplates() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java index d76e21ea712f3..92d8dc6a0bb5e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java @@ -461,11 +461,9 @@ public void testLatestVersionLoaded() throws Exception { .preparePutTemplate("template_1") .setPatterns(Collections.singletonList("te*")) .setOrder(0) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -477,7 +475,6 @@ public void testLatestVersionLoaded() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .execute() .actionGet(); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/template/IndexTemplateBlocksIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/template/IndexTemplateBlocksIT.java index 721e05a867137..21e3e58d4d091 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/template/IndexTemplateBlocksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/template/IndexTemplateBlocksIT.java @@ -54,11 +54,9 @@ public void testIndexTemplatesWithBlocks() throws IOException { .preparePutTemplate("template_blocks") .setPatterns(Collections.singletonList("te*")) .setOrder(0) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -70,7 +68,6 @@ public void testIndexTemplatesWithBlocks() throws IOException { .endObject() .endObject() .endObject() - .endObject() ) .execute() .actionGet(); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java index 090cf81de60a3..0e15a0c895432 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java @@ -110,11 +110,9 @@ public void testSimpleIndexTemplateTests() throws Exception { .setPatterns(Collections.singletonList("te*")) .setSettings(indexSettings()) .setOrder(0) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -126,7 +124,6 @@ public void testSimpleIndexTemplateTests() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .get(); @@ -136,11 +133,9 @@ public void testSimpleIndexTemplateTests() throws Exception { .setPatterns(Collections.singletonList("test*")) .setSettings(indexSettings()) .setOrder(1) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field2") .field("type", "text") @@ -148,7 +143,6 @@ public void testSimpleIndexTemplateTests() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .get(); @@ -161,11 +155,9 @@ public void testSimpleIndexTemplateTests() throws Exception { .setSettings(indexSettings()) .setCreate(true) .setOrder(1) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field2") .field("type", "text") @@ -173,7 +165,6 @@ public void testSimpleIndexTemplateTests() throws Exception { .endObject() .endObject() .endObject() - .endObject() ), IllegalArgumentException.class ); @@ -223,11 +214,9 @@ public void testDeleteIndexTemplate() throws Exception { .preparePutTemplate("template_1") .setPatterns(Collections.singletonList("te*")) .setOrder(0) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -239,7 +228,6 @@ public void testDeleteIndexTemplate() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .execute() .actionGet(); @@ -249,11 +237,9 @@ public void testDeleteIndexTemplate() throws Exception { .preparePutTemplate("template_2") .setPatterns(Collections.singletonList("test*")) .setOrder(1) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field2") .field("type", "text") @@ -261,7 +247,6 @@ public void testDeleteIndexTemplate() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .execute() .actionGet(); @@ -281,11 +266,9 @@ public void testDeleteIndexTemplate() throws Exception { .preparePutTemplate("template_1") .setPatterns(Collections.singletonList("te*")) .setOrder(0) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -297,7 +280,6 @@ public void testDeleteIndexTemplate() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .execute() .actionGet(); @@ -322,11 +304,9 @@ public void testThatGetIndexTemplatesWorks() throws Exception { .setPatterns(Collections.singletonList("te*")) .setOrder(0) .setVersion(123) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -338,7 +318,6 @@ public void testThatGetIndexTemplatesWorks() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .execute() .actionGet(); @@ -367,11 +346,9 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception { .preparePutTemplate("template_1") .setPatterns(Collections.singletonList("te*")) .setOrder(0) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -383,7 +360,6 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .execute() .actionGet(); @@ -394,11 +370,9 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception { .preparePutTemplate("template_2") .setPatterns(Collections.singletonList("te*")) .setOrder(0) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -410,7 +384,6 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .execute() .actionGet(); @@ -421,11 +394,9 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception { .preparePutTemplate("template3") .setPatterns(Collections.singletonList("te*")) .setOrder(0) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -437,7 +408,6 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .execute() .actionGet(); @@ -507,7 +477,7 @@ public void testBrokenMapping() throws Exception { .indices() .preparePutTemplate("template_1") .setPatterns(Collections.singletonList("te*")) - .addMapping("type1", "{\"foo\": \"abcde\"}", XContentType.JSON) + .setMapping("{\"foo\": \"abcde\"}", XContentType.JSON) .get() ); assertThat(e.getMessage(), containsString("Failed to parse mapping ")); @@ -896,11 +866,9 @@ public void testCombineTemplates() throws Exception { .setPatterns(Collections.singletonList("test*")) .setCreate(true) .setOrder(1) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field2") .field("type", "text") @@ -908,7 +876,6 @@ public void testCombineTemplates() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .get() ); @@ -946,11 +913,9 @@ public void testMultipleTemplate() throws IOException { .preparePutTemplate("template_1") .setPatterns(Arrays.asList("a*", "b*")) .setSettings(indexSettings()) - .addMapping( - "type1", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -962,7 +927,6 @@ public void testMultipleTemplate() throws IOException { .endObject() .endObject() .endObject() - .endObject() ) .get(); @@ -1027,7 +991,7 @@ public void testPartitionedTemplate() throws Exception { .indices() .preparePutTemplate("template_2") .setPatterns(Collections.singletonList("te*")) - .addMapping("type", "{\"type\":{\"_routing\":{\"required\":false}}}", XContentType.JSON) + .setMapping("{\"_routing\":{\"required\":false}}", XContentType.JSON) .setSettings(Settings.builder().put("index.number_of_shards", "6").put("index.routing_partition_size", "3")) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java index 643a301c025c3..3a7fdd4093657 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java @@ -424,11 +424,9 @@ public void testRestoreTemplates() throws Exception { .indices() .preparePutTemplate("test-template") .setPatterns(Collections.singletonList("te*")) - .addMapping( - "_doc", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("_doc") .startObject("properties") .startObject("field1") .field("type", "text") @@ -440,7 +438,6 @@ public void testRestoreTemplates() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .get() .isAcknowledged(), diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotCustomPluginStateIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotCustomPluginStateIT.java index 90ec4940a95c5..ea1635b1d8053 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotCustomPluginStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotCustomPluginStateIT.java @@ -81,11 +81,9 @@ public void testIncludeGlobalState() throws Exception { .indices() .preparePutTemplate("test-template") .setPatterns(Collections.singletonList("te*")) - .addMapping( - "_doc", + .setMapping( XContentFactory.jsonBuilder() .startObject() - .startObject("_doc") .startObject("properties") .startObject("field1") .field("type", "text") @@ -97,7 +95,6 @@ public void testIncludeGlobalState() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) .get() .isAcknowledged(), diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index d443d14f3f463..608e3da699318 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -33,16 +33,17 @@ import org.opensearch.OpenSearchGenerationException; import org.opensearch.OpenSearchParseException; +import org.opensearch.Version; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.admin.indices.alias.Alias; import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest; import org.opensearch.action.support.IndicesOptions; import org.opensearch.action.support.master.MasterNodeRequest; +import org.opensearch.common.Nullable; import org.opensearch.common.Strings; import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.collect.MapBuilder; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.logging.DeprecationLogger; @@ -62,7 +63,6 @@ import java.io.IOException; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -94,7 +94,8 @@ public class PutIndexTemplateRequest extends MasterNodeRequest mappings = new HashMap<>(); + @Nullable + private String mappings; private final Set aliases = new HashSet<>(); @@ -108,11 +109,14 @@ public PutIndexTemplateRequest(StreamInput in) throws IOException { order = in.readInt(); create = in.readBoolean(); settings = readSettingsFromStream(in); - int size = in.readVInt(); - for (int i = 0; i < size; i++) { - final String type = in.readString(); - String mappingSource = in.readString(); - mappings.put(type, mappingSource); + if (in.getVersion().before(Version.V_2_0_0)) { + int size = in.readVInt(); + for (int i = 0; i < size; i++) { + in.readString(); // type - cannot assert on _doc because 7x allows arbitrary type names + this.mappings = in.readString(); + } + } else { + this.mappings = in.readOptionalString(); } int aliasesSize = in.readVInt(); for (int i = 0; i < aliasesSize; i++) { @@ -233,17 +237,6 @@ public Settings settings() { return this.settings; } - /** - * Adds mapping that will be added when the index gets created. - * - * @param type The mapping type - * @param source The mapping source - * @param xContentType The type of content contained within the source - */ - public PutIndexTemplateRequest mapping(String type, String source, XContentType xContentType) { - return mapping(type, new BytesArray(source), xContentType); - } - /** * The cause for this index template creation. */ @@ -259,41 +252,47 @@ public String cause() { /** * Adds mapping that will be added when the index gets created. * - * @param type The mapping type * @param source The mapping source + * @param xContentType The type of content contained within the source */ - public PutIndexTemplateRequest mapping(String type, XContentBuilder source) { - return mapping(type, BytesReference.bytes(source), source.contentType()); + public PutIndexTemplateRequest mapping(String source, XContentType xContentType) { + return mapping(new BytesArray(source), xContentType); + } + + /** + * Adds mapping that will be added when the index gets created. + * + * @param source The mapping source + */ + public PutIndexTemplateRequest mapping(XContentBuilder source) { + return mapping(BytesReference.bytes(source), source.contentType()); } /** * Adds mapping that will be added when the index gets created. * - * @param type The mapping type * @param source The mapping source * @param xContentType the source content type */ - public PutIndexTemplateRequest mapping(String type, BytesReference source, XContentType xContentType) { + public PutIndexTemplateRequest mapping(BytesReference source, XContentType xContentType) { Objects.requireNonNull(xContentType); Map mappingAsMap = XContentHelper.convertToMap(source, false, xContentType).v2(); - return mapping(type, mappingAsMap); + return mapping(mappingAsMap); } /** * Adds mapping that will be added when the index gets created. * - * @param type The mapping type * @param source The mapping source */ - public PutIndexTemplateRequest mapping(String type, Map source) { - // wrap it in a type map if its not - if (source.size() != 1 || !source.containsKey(type)) { - source = MapBuilder.newMapBuilder().put(type, source).map(); + public PutIndexTemplateRequest mapping(Map source) { + if (source.size() != 1 || source.containsKey(MapperService.SINGLE_MAPPING_NAME) == false) { + source = Map.of(MapperService.SINGLE_MAPPING_NAME, source); } try { XContentBuilder builder = XContentFactory.jsonBuilder(); builder.map(source); - mappings.put(type, Strings.toString(builder)); + mappings = Strings.toString(builder); return this; } catch (IOException e) { throw new OpenSearchGenerationException("Failed to generate [" + source + "]", e); @@ -305,11 +304,11 @@ public PutIndexTemplateRequest mapping(String type, Map source) * ("field1", "type=string,store=true"). */ public PutIndexTemplateRequest mapping(String... source) { - mapping(MapperService.SINGLE_MAPPING_NAME, PutMappingRequest.simpleMapping(source)); + mapping(PutMappingRequest.simpleMapping(source)); return this; } - public Map mappings() { + public String mappings() { return this.mappings; } @@ -372,7 +371,7 @@ public PutIndexTemplateRequest source(Map templateSource) { + "], should include an inner object describing the mapping" ); } - mapping(entry1.getKey(), (Map) entry1.getValue()); + mapping((Map) entry1.getValue()); } } else if (name.equals("aliases")) { aliases((Map) entry.getValue()); @@ -489,10 +488,14 @@ public void writeTo(StreamOutput out) throws IOException { out.writeInt(order); out.writeBoolean(create); writeSettingsToStream(settings, out); - out.writeVInt(mappings.size()); - for (Map.Entry entry : mappings.entrySet()) { - out.writeString(entry.getKey()); - out.writeString(entry.getValue()); + if (out.getVersion().before(Version.V_2_0_0)) { + out.writeVInt(mappings == null ? 0 : 1); + if (mappings != null) { + out.writeString(MapperService.SINGLE_MAPPING_NAME); + out.writeString(mappings); + } + } else { + out.writeOptionalString(mappings); } out.writeVInt(aliases.size()); for (Alias alias : aliases) { @@ -516,20 +519,19 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.endObject(); builder.startObject("mappings"); - for (Map.Entry entry : mappings.entrySet()) { - builder.field(entry.getKey()); + if (mappings != null) { + builder.field(MapperService.SINGLE_MAPPING_NAME); try ( XContentParser parser = JsonXContent.jsonXContent.createParser( NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, - entry.getValue() + mappings ) ) { builder.copyCurrentStructure(parser); } } builder.endObject(); - builder.startObject("aliases"); for (Alias alias : aliases) { alias.toXContent(builder, params); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java index df3b5f6417576..e5a02acb4a6e9 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java @@ -124,12 +124,11 @@ public PutIndexTemplateRequestBuilder setSettings(Map source) { /** * Adds mapping that will be added when the index template gets created. * - * @param type The mapping type * @param source The mapping source * @param xContentType The type/format of the source */ - public PutIndexTemplateRequestBuilder addMapping(String type, String source, XContentType xContentType) { - request.mapping(type, source, xContentType); + public PutIndexTemplateRequestBuilder setMapping(String source, XContentType xContentType) { + request.mapping(source, xContentType); return this; } @@ -196,22 +195,10 @@ public PutIndexTemplateRequestBuilder cause(String cause) { /** * Adds mapping that will be added when the index template gets created. * - * @param type The mapping type * @param source The mapping source */ - public PutIndexTemplateRequestBuilder addMapping(String type, XContentBuilder source) { - request.mapping(type, source); - return this; - } - - /** - * Adds mapping that will be added when the index gets created. - * - * @param type The mapping type - * @param source The mapping source - */ - public PutIndexTemplateRequestBuilder addMapping(String type, Map source) { - request.mapping(type, source); + public PutIndexTemplateRequestBuilder setMapping(XContentBuilder source) { + request.mapping(source); return this; } diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java index 22cd5c1dbbbe2..896679206aec5 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java @@ -915,11 +915,11 @@ static ClusterState innerPutTemplate( templateBuilder.patterns(request.indexPatterns); templateBuilder.settings(request.settings); - for (Map.Entry entry : request.mappings.entrySet()) { + if (request.mappings != null) { try { - templateBuilder.putMapping(entry.getKey(), entry.getValue()); + templateBuilder.putMapping(MapperService.SINGLE_MAPPING_NAME, request.mappings); } catch (Exception e) { - throw new MapperParsingException("Failed to parse mapping [{}]: {}", e, entry.getKey(), e.getMessage()); + throw new MapperParsingException("Failed to parse mapping: {}", e, request.mappings); } } @@ -1511,7 +1511,7 @@ public static class PutRequest { Integer version; List indexPatterns; Settings settings = Settings.Builder.EMPTY_SETTINGS; - Map mappings = new HashMap<>(); + String mappings = null; List aliases = new ArrayList<>(); TimeValue masterTimeout = MasterNodeRequest.DEFAULT_MASTER_NODE_TIMEOUT; @@ -1541,8 +1541,8 @@ public PutRequest settings(Settings settings) { return this; } - public PutRequest mappings(Map mappings) { - this.mappings.putAll(mappings); + public PutRequest mappings(String mappings) { + this.mappings = mappings; return this; } @@ -1551,11 +1551,6 @@ public PutRequest aliases(Set aliases) { return this; } - public PutRequest putMapping(String mappingType, String mappingSource) { - mappings.put(mappingType, mappingSource); - return this; - } - public PutRequest masterTimeout(TimeValue masterTimeout) { this.masterTimeout = masterTimeout; return this; diff --git a/server/src/test/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestTests.java index db174aeca9476..f4cdb778a3169 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestTests.java @@ -39,6 +39,7 @@ import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.index.mapper.MapperService; import org.opensearch.test.AbstractXContentTestCase; import java.io.IOException; @@ -90,10 +91,9 @@ public void testMappingKeyedByType() throws IOException { .endObject() .endObject() .endObject(); - request1.mapping("type1", builder); + request1.mapping(builder); builder = XContentFactory.contentBuilder(randomFrom(XContentType.values())); builder.startObject() - .startObject("type1") .startObject("properties") .startObject("field1") .field("type", "text") @@ -106,17 +106,16 @@ public void testMappingKeyedByType() throws IOException { .endObject() .endObject() .endObject() - .endObject() .endObject(); - request2.mapping("type1", builder); + request2.mapping(builder); assertEquals(request1.mappings(), request2.mappings()); } { request1 = new PutIndexTemplateRequest("foo"); request2 = new PutIndexTemplateRequest("bar"); String nakedMapping = "{\"properties\": {\"foo\": {\"type\": \"integer\"}}}"; - request1.mapping("type2", nakedMapping, XContentType.JSON); - request2.mapping("type2", "{\"type2\": " + nakedMapping + "}", XContentType.JSON); + request1.mapping(nakedMapping, XContentType.JSON); + request2.mapping(nakedMapping, XContentType.JSON); assertEquals(request1.mappings(), request2.mappings()); } { @@ -130,8 +129,8 @@ public void testMappingKeyedByType() throws IOException { .map() ) .map(); - request1.mapping("type3", nakedMapping); - request2.mapping("type3", MapBuilder.newMapBuilder().put("type3", nakedMapping).map()); + request1.mapping(nakedMapping); + request2.mapping(MapBuilder.newMapBuilder().put(MapperService.SINGLE_MAPPING_NAME, nakedMapping).map()); assertEquals(request1.mappings(), request2.mappings()); } } @@ -163,7 +162,6 @@ protected PutIndexTemplateRequest createTestInstance() { if (randomBoolean()) { try { request.mapping( - "doc", XContentFactory.jsonBuilder() .startObject() .startObject("doc") diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java index 19e73422c5362..c3a16a1e25bc8 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java @@ -185,12 +185,10 @@ public void testIndexTemplateWithAliasNameEqualToTemplatePattern() { public void testIndexTemplateWithValidateMapping() throws Exception { PutRequest request = new PutRequest("api", "validate_template"); request.patterns(singletonList("te*")); - request.putMapping( - "type1", + request.mappings( Strings.toString( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") .startObject("properties") .startObject("field2") .field("type", "text") @@ -198,7 +196,6 @@ public void testIndexTemplateWithValidateMapping() throws Exception { .endObject() .endObject() .endObject() - .endObject() ) ); @@ -211,7 +208,7 @@ public void testIndexTemplateWithValidateMapping() throws Exception { public void testBrokenMapping() throws Exception { PutRequest request = new PutRequest("api", "broken_mapping"); request.patterns(singletonList("te*")); - request.putMapping("type1", "abcde"); + request.mappings("abcde"); List errors = putTemplateDetail(request); assertThat(errors.size(), equalTo(1)); @@ -223,7 +220,7 @@ public void testAliasInvalidFilterInvalidJson() throws Exception { // invalid json: put index template fails PutRequest request = new PutRequest("api", "blank_mapping"); request.patterns(singletonList("te*")); - request.putMapping("type1", "{}"); + request.mappings("{}"); Set aliases = new HashSet<>(); aliases.add(new Alias("invalid_alias").filter("abcde")); request.aliases(aliases); @@ -2073,7 +2070,7 @@ public void testLegacyNoopUpdate() { pr.settings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 3).build()); } if (randomBoolean()) { - pr.mappings(Collections.emptyMap()); + pr.mappings("{}"); } if (randomBoolean()) { pr.aliases(Collections.singleton(new Alias("alias"))); From 5311844f3b65de949ad7a1d88c08b830bcd7c870 Mon Sep 17 00:00:00 2001 From: Sarat Vemulapalli Date: Mon, 21 Mar 2022 17:30:00 -0700 Subject: [PATCH 40/46] Updating repository commons logging version (#2541) Signed-off-by: Sarat Vemulapalli --- plugins/repository-hdfs/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/repository-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index c9c7c8e6ffced..99943971df64f 100644 --- a/plugins/repository-hdfs/build.gradle +++ b/plugins/repository-hdfs/build.gradle @@ -68,7 +68,7 @@ dependencies { api 'com.google.code.gson:gson:2.9.0' runtimeOnly 'com.google.guava:guava:30.1.1-jre' api 'com.google.protobuf:protobuf-java:3.19.3' - api 'commons-logging:commons-logging:1.1.3' + api "commons-logging:commons-logging:${versions.commonslogging}" api 'commons-cli:commons-cli:1.2' api "commons-codec:commons-codec:${versions.commonscodec}" api 'commons-collections:commons-collections:3.2.2' From 7d9cd3102fc0c4dddfa1aa969d74526bb72edc54 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 18:02:55 -0700 Subject: [PATCH 41/46] Bump google-oauth-client from 1.31.0 to 1.33.1 in /plugins/discovery-gce (#2524) * Bump google-oauth-client from 1.31.0 to 1.33.1 in /plugins/discovery-gce Bumps [google-oauth-client](https://github.com/googleapis/google-oauth-java-client) from 1.31.0 to 1.33.1. - [Release notes](https://github.com/googleapis/google-oauth-java-client/releases) - [Changelog](https://github.com/googleapis/google-oauth-java-client/blob/main/CHANGELOG.md) - [Commits](https://github.com/googleapis/google-oauth-java-client/compare/v1.31.0...v1.33.1) --- updated-dependencies: - dependency-name: com.google.oauth-client:google-oauth-client dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Updating SHAs Signed-off-by: dependabot[bot] * Fixing precommit failure Signed-off-by: Vacha Shah Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] Co-authored-by: Vacha Shah --- plugins/discovery-gce/build.gradle | 3 ++- .../discovery-gce/licenses/google-oauth-client-1.31.0.jar.sha1 | 1 - .../discovery-gce/licenses/google-oauth-client-1.33.1.jar.sha1 | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 plugins/discovery-gce/licenses/google-oauth-client-1.31.0.jar.sha1 create mode 100644 plugins/discovery-gce/licenses/google-oauth-client-1.33.1.jar.sha1 diff --git a/plugins/discovery-gce/build.gradle b/plugins/discovery-gce/build.gradle index 14827eb180e9f..2396b228d77a0 100644 --- a/plugins/discovery-gce/build.gradle +++ b/plugins/discovery-gce/build.gradle @@ -24,7 +24,7 @@ versions << [ dependencies { api "com.google.apis:google-api-services-compute:v1-rev160-${versions.google}" api "com.google.api-client:google-api-client:${versions.google}" - api "com.google.oauth-client:google-oauth-client:1.31.0" + api "com.google.oauth-client:google-oauth-client:1.33.1" api "com.google.http-client:google-http-client:${versions.google}" api "com.google.http-client:google-http-client-jackson2:${versions.google}" api 'com.google.code.findbugs:jsr305:3.0.2' @@ -68,4 +68,5 @@ thirdPartyAudit.ignoreMissingClasses( 'com.google.common.collect.Multiset', 'com.google.common.collect.SortedMultiset', 'com.google.common.collect.TreeMultiset', + 'com.google.common.io.BaseEncoding', ) diff --git a/plugins/discovery-gce/licenses/google-oauth-client-1.31.0.jar.sha1 b/plugins/discovery-gce/licenses/google-oauth-client-1.31.0.jar.sha1 deleted file mode 100644 index 942dbb5d167a4..0000000000000 --- a/plugins/discovery-gce/licenses/google-oauth-client-1.31.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -bf1cfbbaa2497d0a841ea0363df4a61170d5823b \ No newline at end of file diff --git a/plugins/discovery-gce/licenses/google-oauth-client-1.33.1.jar.sha1 b/plugins/discovery-gce/licenses/google-oauth-client-1.33.1.jar.sha1 new file mode 100644 index 0000000000000..3897a85310ec6 --- /dev/null +++ b/plugins/discovery-gce/licenses/google-oauth-client-1.33.1.jar.sha1 @@ -0,0 +1 @@ +0a431f1a677c5f89507591ab47a7ccdb0b18b6f7 \ No newline at end of file From bb748e0a1b37ce2d8077d2d901471d0e42636f7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 18:27:24 -0700 Subject: [PATCH 42/46] Bump gson from 2.8.9 to 2.9.0 in /plugins/repository-gcs (#2550) * Bump gson from 2.8.9 to 2.9.0 in /plugins/repository-gcs Bumps [gson](https://github.com/google/gson) from 2.8.9 to 2.9.0. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.8.9...gson-parent-2.9.0) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Updating SHAs Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- plugins/repository-gcs/build.gradle | 2 +- plugins/repository-gcs/licenses/gson-2.8.9.jar.sha1 | 1 - plugins/repository-gcs/licenses/gson-2.9.0.jar.sha1 | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 plugins/repository-gcs/licenses/gson-2.8.9.jar.sha1 create mode 100644 plugins/repository-gcs/licenses/gson-2.9.0.jar.sha1 diff --git a/plugins/repository-gcs/build.gradle b/plugins/repository-gcs/build.gradle index 67943c069d633..e1ecf3c65a0f9 100644 --- a/plugins/repository-gcs/build.gradle +++ b/plugins/repository-gcs/build.gradle @@ -63,7 +63,7 @@ dependencies { api 'org.threeten:threetenbp:1.4.4' api 'com.google.protobuf:protobuf-java-util:3.19.3' api 'com.google.protobuf:protobuf-java:3.19.3' - api 'com.google.code.gson:gson:2.8.9' + api 'com.google.code.gson:gson:2.9.0' api 'com.google.api.grpc:proto-google-common-protos:1.16.0' api 'com.google.api.grpc:proto-google-iam-v1:0.12.0' api 'com.google.cloud:google-cloud-core-http:1.93.3' diff --git a/plugins/repository-gcs/licenses/gson-2.8.9.jar.sha1 b/plugins/repository-gcs/licenses/gson-2.8.9.jar.sha1 deleted file mode 100644 index f7a8108d8c8e6..0000000000000 --- a/plugins/repository-gcs/licenses/gson-2.8.9.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -8a432c1d6825781e21a02db2e2c33c5fde2833b9 \ No newline at end of file diff --git a/plugins/repository-gcs/licenses/gson-2.9.0.jar.sha1 b/plugins/repository-gcs/licenses/gson-2.9.0.jar.sha1 new file mode 100644 index 0000000000000..8e9626b0c949b --- /dev/null +++ b/plugins/repository-gcs/licenses/gson-2.9.0.jar.sha1 @@ -0,0 +1 @@ +8a1167e089096758b49f9b34066ef98b2f4b37aa \ No newline at end of file From d2bdcdec33ec4ae66b705dc75716d70ce68575b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 22:44:46 -0500 Subject: [PATCH 43/46] Bump commons-lang3 from 3.7 to 3.12.0 in /plugins/repository-hdfs (#2552) Bumps commons-lang3 from 3.7 to 3.12.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-lang3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- plugins/repository-hdfs/build.gradle | 2 +- plugins/repository-hdfs/licenses/commons-lang3-3.12.0.jar.sha1 | 1 + plugins/repository-hdfs/licenses/commons-lang3-3.7.jar.sha1 | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 plugins/repository-hdfs/licenses/commons-lang3-3.12.0.jar.sha1 delete mode 100644 plugins/repository-hdfs/licenses/commons-lang3-3.7.jar.sha1 diff --git a/plugins/repository-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index 99943971df64f..dc1f55b686044 100644 --- a/plugins/repository-hdfs/build.gradle +++ b/plugins/repository-hdfs/build.gradle @@ -75,7 +75,7 @@ dependencies { api 'org.apache.commons:commons-compress:1.21' api 'org.apache.commons:commons-configuration2:2.7' api 'commons-io:commons-io:2.11.0' - api 'org.apache.commons:commons-lang3:3.7' + api 'org.apache.commons:commons-lang3:3.12.0' implementation 'com.google.re2j:re2j:1.1' api 'javax.servlet:servlet-api:2.5' api "org.slf4j:slf4j-api:${versions.slf4j}" diff --git a/plugins/repository-hdfs/licenses/commons-lang3-3.12.0.jar.sha1 b/plugins/repository-hdfs/licenses/commons-lang3-3.12.0.jar.sha1 new file mode 100644 index 0000000000000..9273d8c01aaba --- /dev/null +++ b/plugins/repository-hdfs/licenses/commons-lang3-3.12.0.jar.sha1 @@ -0,0 +1 @@ +c6842c86792ff03b9f1d1fe2aab8dc23aa6c6f0e \ No newline at end of file diff --git a/plugins/repository-hdfs/licenses/commons-lang3-3.7.jar.sha1 b/plugins/repository-hdfs/licenses/commons-lang3-3.7.jar.sha1 deleted file mode 100644 index 788fa39a7905a..0000000000000 --- a/plugins/repository-hdfs/licenses/commons-lang3-3.7.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -557edd918fd41f9260963583ebf5a61a43a6b423 \ No newline at end of file From bd2d9350b705c8a02b3eb4cadde90d094824ec7d Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Mon, 21 Mar 2022 22:51:51 -0500 Subject: [PATCH 44/46] Support for geo_bounding_box queries on geo_shape fields (#2506) Adds support for using geo_bounding_box queries on geo_shape field types by lifting the geo_point restriction in the QueryBuilder. Bounding Box query integration tests are abstracted to test both geo_point and geo_shape types. Signed-off-by: Nicholas Walter Knize --- ...ava => AbstractGeoBoundingBoxQueryIT.java} | 117 ++++-------------- .../geo/GeoBoundingBoxQueryGeoPointsIT.java | 21 ++++ .../geo/GeoBoundingBoxQueryGeoShapesIT.java | 25 ++++ .../query/GeoBoundingBoxQueryBuilder.java | 50 ++++---- .../GeoBoundingBoxQueryBuilderTests.java | 15 ++- 5 files changed, 108 insertions(+), 120 deletions(-) rename server/src/internalClusterTest/java/org/opensearch/search/geo/{GeoBoundingBoxQueryIT.java => AbstractGeoBoundingBoxQueryIT.java} (73%) create mode 100644 server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryGeoPointsIT.java create mode 100644 server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryGeoShapesIT.java diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/AbstractGeoBoundingBoxQueryIT.java similarity index 73% rename from server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryIT.java rename to server/src/internalClusterTest/java/org/opensearch/search/geo/AbstractGeoBoundingBoxQueryIT.java index 90e7163342547..3e63987af20f2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/AbstractGeoBoundingBoxQueryIT.java @@ -43,6 +43,8 @@ import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.test.VersionUtils; +import java.io.IOException; + import static org.opensearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder; import static org.opensearch.index.query.QueryBuilders.boolQuery; @@ -52,7 +54,15 @@ import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.equalTo; -public class GeoBoundingBoxQueryIT extends OpenSearchIntegTestCase { +abstract class AbstractGeoBoundingBoxQueryIT extends OpenSearchIntegTestCase { + + public abstract XContentBuilder addGeoMapping(XContentBuilder parentMapping) throws IOException; + + public XContentBuilder getMapping() throws IOException { + XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties"); + mapping = addGeoMapping(mapping); + return mapping.endObject().endObject(); + } @Override protected boolean forbidPrivateIndexSettings() { @@ -62,110 +72,55 @@ protected boolean forbidPrivateIndexSettings() { public void testSimpleBoundingBoxTest() throws Exception { Version version = VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() - .startObject() - .startObject("properties") - .startObject("location") - .field("type", "geo_point"); - xContentBuilder.endObject().endObject().endObject(); + XContentBuilder xContentBuilder = getMapping(); assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder)); ensureGreen(); client().prepareIndex("test") .setId("1") - .setSource( - jsonBuilder().startObject() - .field("name", "New York") - .startObject("location") - .field("lat", 40.7143528) - .field("lon", -74.0059731) - .endObject() - .endObject() - ) + .setSource(jsonBuilder().startObject().field("name", "New York").field("location", "POINT(-74.0059731 40.7143528)").endObject()) .get(); // to NY: 5.286 km client().prepareIndex("test") .setId("2") .setSource( - jsonBuilder().startObject() - .field("name", "Times Square") - .startObject("location") - .field("lat", 40.759011) - .field("lon", -73.9844722) - .endObject() - .endObject() + jsonBuilder().startObject().field("name", "Times Square").field("location", "POINT(-73.9844722 40.759011)").endObject() ) .get(); // to NY: 0.4621 km client().prepareIndex("test") .setId("3") - .setSource( - jsonBuilder().startObject() - .field("name", "Tribeca") - .startObject("location") - .field("lat", 40.718266) - .field("lon", -74.007819) - .endObject() - .endObject() - ) + .setSource(jsonBuilder().startObject().field("name", "Tribeca").field("location", "POINT(-74.007819 40.718266)").endObject()) .get(); // to NY: 1.055 km client().prepareIndex("test") .setId("4") .setSource( - jsonBuilder().startObject() - .field("name", "Wall Street") - .startObject("location") - .field("lat", 40.7051157) - .field("lon", -74.0088305) - .endObject() - .endObject() + jsonBuilder().startObject().field("name", "Wall Street").field("location", "POINT(-74.0088305 40.7051157)").endObject() ) .get(); // to NY: 1.258 km client().prepareIndex("test") .setId("5") - .setSource( - jsonBuilder().startObject() - .field("name", "Soho") - .startObject("location") - .field("lat", 40.7247222) - .field("lon", -74) - .endObject() - .endObject() - ) + .setSource(jsonBuilder().startObject().field("name", "Soho").field("location", "POINT(-74 40.7247222)").endObject()) .get(); // to NY: 2.029 km client().prepareIndex("test") .setId("6") .setSource( - jsonBuilder().startObject() - .field("name", "Greenwich Village") - .startObject("location") - .field("lat", 40.731033) - .field("lon", -73.9962255) - .endObject() - .endObject() + jsonBuilder().startObject().field("name", "Greenwich Village").field("location", "POINT(-73.9962255 40.731033)").endObject() ) .get(); // to NY: 8.572 km client().prepareIndex("test") .setId("7") - .setSource( - jsonBuilder().startObject() - .field("name", "Brooklyn") - .startObject("location") - .field("lat", 40.65) - .field("lon", -73.95) - .endObject() - .endObject() - ) + .setSource(jsonBuilder().startObject().field("name", "Brooklyn").field("location", "POINT(-73.95 40.65)").endObject()) .get(); client().admin().indices().prepareRefresh().get(); @@ -192,12 +147,7 @@ public void testSimpleBoundingBoxTest() throws Exception { public void testLimit2BoundingBox() throws Exception { Version version = VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() - .startObject() - .startObject("properties") - .startObject("location") - .field("type", "geo_point"); - xContentBuilder.endObject().endObject().endObject(); + XContentBuilder xContentBuilder = getMapping(); assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder)); ensureGreen(); @@ -207,10 +157,7 @@ public void testLimit2BoundingBox() throws Exception { jsonBuilder().startObject() .field("userid", 880) .field("title", "Place in Stockholm") - .startObject("location") - .field("lat", 59.328355000000002) - .field("lon", 18.036842) - .endObject() + .field("location", "POINT(59.328355000000002 18.036842)") .endObject() ) .setRefreshPolicy(IMMEDIATE) @@ -222,10 +169,7 @@ public void testLimit2BoundingBox() throws Exception { jsonBuilder().startObject() .field("userid", 534) .field("title", "Place in Montreal") - .startObject("location") - .field("lat", 45.509526999999999) - .field("lon", -73.570986000000005) - .endObject() + .field("location", "POINT(-73.570986000000005 45.509526999999999)") .endObject() ) .setRefreshPolicy(IMMEDIATE) @@ -271,12 +215,7 @@ public void testLimit2BoundingBox() throws Exception { public void testCompleteLonRange() throws Exception { Version version = VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() - .startObject() - .startObject("properties") - .startObject("location") - .field("type", "geo_point"); - xContentBuilder.endObject().endObject().endObject(); + XContentBuilder xContentBuilder = getMapping(); assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder)); ensureGreen(); @@ -286,10 +225,7 @@ public void testCompleteLonRange() throws Exception { jsonBuilder().startObject() .field("userid", 880) .field("title", "Place in Stockholm") - .startObject("location") - .field("lat", 59.328355000000002) - .field("lon", 18.036842) - .endObject() + .field("location", "POINT(18.036842 59.328355000000002)") .endObject() ) .setRefreshPolicy(IMMEDIATE) @@ -301,10 +237,7 @@ public void testCompleteLonRange() throws Exception { jsonBuilder().startObject() .field("userid", 534) .field("title", "Place in Montreal") - .startObject("location") - .field("lat", 45.509526999999999) - .field("lon", -73.570986000000005) - .endObject() + .field("location", "POINT(-73.570986000000005 45.509526999999999)") .endObject() ) .setRefreshPolicy(IMMEDIATE) diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryGeoPointsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryGeoPointsIT.java new file mode 100644 index 0000000000000..d039e1200a862 --- /dev/null +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryGeoPointsIT.java @@ -0,0 +1,21 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.search.geo; + +import org.opensearch.common.xcontent.XContentBuilder; + +import java.io.IOException; + +public class GeoBoundingBoxQueryGeoPointsIT extends AbstractGeoBoundingBoxQueryIT { + + @Override + public XContentBuilder addGeoMapping(XContentBuilder parentMapping) throws IOException { + return parentMapping.startObject("location").field("type", "geo_point").endObject(); + } +} diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryGeoShapesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryGeoShapesIT.java new file mode 100644 index 0000000000000..44f9dd6d01144 --- /dev/null +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryGeoShapesIT.java @@ -0,0 +1,25 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.search.geo; + +import org.opensearch.common.xcontent.XContentBuilder; + +import java.io.IOException; + +public class GeoBoundingBoxQueryGeoShapesIT extends AbstractGeoBoundingBoxQueryIT { + + @Override + public XContentBuilder addGeoMapping(XContentBuilder parentMapping) throws IOException { + parentMapping = parentMapping.startObject("location").field("type", "geo_shape"); + if (randomBoolean()) { + parentMapping.field("strategy", "recursive"); + } + return parentMapping.endObject(); + } +} diff --git a/server/src/main/java/org/opensearch/index/query/GeoBoundingBoxQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/GeoBoundingBoxQueryBuilder.java index 82e95c7450798..879ad07ca81fd 100644 --- a/server/src/main/java/org/opensearch/index/query/GeoBoundingBoxQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/GeoBoundingBoxQueryBuilder.java @@ -32,9 +32,6 @@ package org.opensearch.index.query; -import org.apache.lucene.document.LatLonDocValuesField; -import org.apache.lucene.document.LatLonPoint; -import org.apache.lucene.search.IndexOrDocValuesQuery; import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; import org.opensearch.OpenSearchParseException; @@ -44,13 +41,17 @@ import org.opensearch.common.geo.GeoBoundingBox; import org.opensearch.common.geo.GeoPoint; import org.opensearch.common.geo.GeoUtils; +import org.opensearch.common.geo.ShapeRelation; +import org.opensearch.common.geo.SpatialStrategy; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentParser; import org.opensearch.geometry.Rectangle; import org.opensearch.geometry.utils.Geohash; -import org.opensearch.index.mapper.GeoPointFieldMapper.GeoPointFieldType; +import org.opensearch.index.mapper.GeoPointFieldMapper; +import org.opensearch.index.mapper.GeoShapeFieldMapper; +import org.opensearch.index.mapper.GeoShapeQueryable; import org.opensearch.index.mapper.MappedFieldType; import java.io.IOException; @@ -315,11 +316,24 @@ public Query doToQuery(QueryShardContext context) { if (ignoreUnmapped) { return new MatchNoDocsQuery(); } else { - throw new QueryShardException(context, "failed to find geo_point field [" + fieldName + "]"); + throw new QueryShardException(context, "failed to find geo field [" + fieldName + "]"); } } - if (!(fieldType instanceof GeoPointFieldType)) { - throw new QueryShardException(context, "field [" + fieldName + "] is not a geo_point field"); + if (fieldType instanceof GeoShapeQueryable == false) { + throw new QueryShardException( + context, + "type [" + + fieldType + + "] for field [" + + fieldName + + "] is not supported for [" + + NAME + + "] queries. Must be one of [" + + GeoPointFieldMapper.CONTENT_TYPE + + "] or [" + + GeoShapeFieldMapper.CONTENT_TYPE + + "]" + ); } QueryValidationException exception = checkLatLon(); @@ -344,24 +358,14 @@ public Query doToQuery(QueryShardContext context) { } } - Query query = LatLonPoint.newBoxQuery( - fieldType.name(), - luceneBottomRight.getLat(), - luceneTopLeft.getLat(), + final GeoShapeQueryable geoShapeQueryable = (GeoShapeQueryable) fieldType; + final Rectangle rectangle = new Rectangle( luceneTopLeft.getLon(), - luceneBottomRight.getLon() + luceneBottomRight.getLon(), + luceneTopLeft.getLat(), + luceneBottomRight.getLat() ); - if (fieldType.hasDocValues()) { - Query dvQuery = LatLonDocValuesField.newSlowBoxQuery( - fieldType.name(), - luceneBottomRight.getLat(), - luceneTopLeft.getLat(), - luceneTopLeft.getLon(), - luceneBottomRight.getLon() - ); - query = new IndexOrDocValuesQuery(query, dvQuery); - } - return query; + return geoShapeQueryable.geoShapeQuery(rectangle, fieldType.name(), SpatialStrategy.RECURSIVE, ShapeRelation.INTERSECTS, context); } @Override diff --git a/server/src/test/java/org/opensearch/index/query/GeoBoundingBoxQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/GeoBoundingBoxQueryBuilderTests.java index 1d46323efa44c..94cdebdcdf59e 100644 --- a/server/src/test/java/org/opensearch/index/query/GeoBoundingBoxQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/GeoBoundingBoxQueryBuilderTests.java @@ -40,6 +40,8 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.common.geo.GeoPoint; import org.opensearch.common.geo.GeoUtils; +import org.opensearch.index.mapper.GeoPointFieldMapper; +import org.opensearch.index.mapper.GeoShapeFieldMapper; import org.opensearch.index.mapper.MappedFieldType; import org.opensearch.test.AbstractQueryTestCase; import org.opensearch.test.geo.RandomShapeGenerator; @@ -58,7 +60,7 @@ public class GeoBoundingBoxQueryBuilderTests extends AbstractQueryTestCase qb.toQuery(context)); - assertEquals("failed to find geo_point field [" + qb.fieldName() + "]", e.getMessage()); + assertEquals("failed to find geo field [" + qb.fieldName() + "]", e.getMessage()); } public void testBrokenCoordinateCannotBeSet() { @@ -223,10 +225,11 @@ public void testStrictnessDefault() { @Override protected void doAssertLuceneQuery(GeoBoundingBoxQueryBuilder queryBuilder, Query query, QueryShardContext context) throws IOException { - MappedFieldType fieldType = context.fieldMapper(queryBuilder.fieldName()); + final MappedFieldType fieldType = context.fieldMapper(queryBuilder.fieldName()); if (fieldType == null) { assertTrue("Found no indexed geo query.", query instanceof MatchNoDocsQuery); - } else if (query instanceof IndexOrDocValuesQuery) { // TODO: remove the if statement once we always use LatLonPoint + } else if (fieldType instanceof GeoPointFieldMapper.GeoPointFieldType) { + assertEquals(IndexOrDocValuesQuery.class, query.getClass()); Query indexQuery = ((IndexOrDocValuesQuery) query).getIndexQuery(); String expectedFieldName = expectedFieldName(queryBuilder.fieldName()); assertEquals( @@ -250,6 +253,8 @@ protected void doAssertLuceneQuery(GeoBoundingBoxQueryBuilder queryBuilder, Quer ), dvQuery ); + } else { + assertEquals(GeoShapeFieldMapper.GeoShapeFieldType.class, fieldType.getClass()); } } @@ -572,6 +577,6 @@ public void testIgnoreUnmapped() throws IOException { final GeoBoundingBoxQueryBuilder failingQueryBuilder = new GeoBoundingBoxQueryBuilder("unmapped").setCorners(1.0, 0.0, 0.0, 1.0); failingQueryBuilder.ignoreUnmapped(false); QueryShardException e = expectThrows(QueryShardException.class, () -> failingQueryBuilder.toQuery(shardContext)); - assertThat(e.getMessage(), containsString("failed to find geo_point field [unmapped]")); + assertThat(e.getMessage(), containsString("failed to find geo field [unmapped]")); } } From 82fb7abb7158788fa727543dbcc89cffc318c67a Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Tue, 22 Mar 2022 00:11:23 -0400 Subject: [PATCH 45/46] Introduce QueryPhaseSearcher extension point (SearchPlugin) (#1931) Signed-off-by: Andriy Redko --- .../main/java/org/opensearch/node/Node.java | 14 +++- .../org/opensearch/plugins/SearchPlugin.java | 36 ++++++++++ .../search/DefaultSearchContext.java | 7 +- .../org/opensearch/search/SearchModule.java | 52 ++++++++++++++ .../org/opensearch/search/SearchService.java | 11 ++- .../opensearch/search/query/QueryPhase.java | 70 ++++++++++++++++++- .../search/query/QueryPhaseSearcher.java | 41 +++++++++++ .../search/DefaultSearchContextTests.java | 18 +++-- .../snapshots/SnapshotResiliencyTests.java | 5 +- .../java/org/opensearch/node/MockNode.java | 11 ++- .../opensearch/search/MockSearchService.java | 15 +++- 11 files changed, 259 insertions(+), 21 deletions(-) create mode 100644 server/src/main/java/org/opensearch/search/query/QueryPhaseSearcher.java diff --git a/server/src/main/java/org/opensearch/node/Node.java b/server/src/main/java/org/opensearch/node/Node.java index 060f5b23fb504..6368e097f6a14 100644 --- a/server/src/main/java/org/opensearch/node/Node.java +++ b/server/src/main/java/org/opensearch/node/Node.java @@ -174,6 +174,7 @@ import org.opensearch.search.SearchService; import org.opensearch.search.aggregations.support.AggregationUsageService; import org.opensearch.search.fetch.FetchPhase; +import org.opensearch.search.query.QueryPhase; import org.opensearch.snapshots.InternalSnapshotsInfoService; import org.opensearch.snapshots.RestoreService; import org.opensearch.snapshots.SnapshotShardsService; @@ -210,6 +211,7 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.function.UnaryOperator; @@ -849,9 +851,11 @@ protected Node( threadPool, scriptService, bigArrays, + searchModule.getQueryPhase(), searchModule.getFetchPhase(), responseCollectorService, - circuitBreakerService + circuitBreakerService, + searchModule.getIndexSearcherExecutor(threadPool) ); final List> tasksExecutors = pluginsService.filterPlugins(PersistentTaskPlugin.class) @@ -1407,9 +1411,11 @@ protected SearchService newSearchService( ThreadPool threadPool, ScriptService scriptService, BigArrays bigArrays, + QueryPhase queryPhase, FetchPhase fetchPhase, ResponseCollectorService responseCollectorService, - CircuitBreakerService circuitBreakerService + CircuitBreakerService circuitBreakerService, + Executor indexSearcherExecutor ) { return new SearchService( clusterService, @@ -1417,9 +1423,11 @@ protected SearchService newSearchService( threadPool, scriptService, bigArrays, + queryPhase, fetchPhase, responseCollectorService, - circuitBreakerService + circuitBreakerService, + indexSearcherExecutor ); } diff --git a/server/src/main/java/org/opensearch/plugins/SearchPlugin.java b/server/src/main/java/org/opensearch/plugins/SearchPlugin.java index 3a5b965d07fb6..f650a1ce5512f 100644 --- a/server/src/main/java/org/opensearch/plugins/SearchPlugin.java +++ b/server/src/main/java/org/opensearch/plugins/SearchPlugin.java @@ -32,6 +32,7 @@ package org.opensearch.plugins; +import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.Sort; import org.opensearch.common.CheckedFunction; @@ -40,6 +41,7 @@ import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.Writeable; import org.opensearch.common.lucene.search.function.ScoreFunction; +import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.ContextParser; import org.opensearch.common.xcontent.XContent; import org.opensearch.common.xcontent.XContentParser; @@ -61,6 +63,7 @@ import org.opensearch.search.aggregations.support.ValuesSourceRegistry; import org.opensearch.search.fetch.FetchSubPhase; import org.opensearch.search.fetch.subphase.highlight.Highlighter; +import org.opensearch.search.query.QueryPhaseSearcher; import org.opensearch.search.rescore.Rescorer; import org.opensearch.search.rescore.RescorerBuilder; import org.opensearch.search.sort.SortBuilder; @@ -68,11 +71,14 @@ import org.opensearch.search.suggest.Suggest; import org.opensearch.search.suggest.Suggester; import org.opensearch.search.suggest.SuggestionBuilder; +import org.opensearch.threadpool.ThreadPool; import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.TreeMap; +import java.util.concurrent.ExecutorService; import java.util.function.BiFunction; import java.util.function.Consumer; @@ -178,6 +184,36 @@ default List> getRescorers() { return emptyList(); } + /** + * The new {@link QueryPhaseSearcher} added by this plugin. At the moment, only one {@link QueryPhaseSearcher} is supported per + * instance, the {@link IllegalStateException} is going to be thrown if more then one plugin tries to register + * {@link QueryPhaseSearcher} implementation. + */ + default Optional getQueryPhaseSearcher() { + return Optional.empty(); + } + + /** + * The executor service provider (registered through {@link Plugin#getExecutorBuilders(Settings)} to be used at search + * time by {@link IndexSearcher}. The {@link IllegalStateException} is going to be thrown if more then one + * plugin tries to register index searcher executor. + */ + default Optional getIndexSearcherExecutorProvider() { + return Optional.empty(); + } + + /** + * Executor service provider + */ + interface ExecutorServiceProvider { + /** + * Provides an executor service instance + * @param threadPool thread pool + * @return executor service instance + */ + ExecutorService getExecutor(ThreadPool threadPool); + } + /** * Specification of custom {@link ScoreFunction}. */ diff --git a/server/src/main/java/org/opensearch/search/DefaultSearchContext.java b/server/src/main/java/org/opensearch/search/DefaultSearchContext.java index f6c76664c8988..bfe8eed05ea9b 100644 --- a/server/src/main/java/org/opensearch/search/DefaultSearchContext.java +++ b/server/src/main/java/org/opensearch/search/DefaultSearchContext.java @@ -94,6 +94,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.Executor; import java.util.function.LongSupplier; final class DefaultSearchContext extends SearchContext { @@ -177,7 +178,8 @@ final class DefaultSearchContext extends SearchContext { FetchPhase fetchPhase, boolean lowLevelCancellation, Version minNodeVersion, - boolean validate + boolean validate, + Executor executor ) throws IOException { this.readerContext = readerContext; this.request = request; @@ -198,7 +200,8 @@ final class DefaultSearchContext extends SearchContext { engineSearcher.getSimilarity(), engineSearcher.getQueryCache(), engineSearcher.getQueryCachingPolicy(), - lowLevelCancellation + lowLevelCancellation, + executor ); this.relativeTimeSupplier = relativeTimeSupplier; this.timeout = timeout; diff --git a/server/src/main/java/org/opensearch/search/SearchModule.java b/server/src/main/java/org/opensearch/search/SearchModule.java index c052f7f89e14e..dc5309b50abb8 100644 --- a/server/src/main/java/org/opensearch/search/SearchModule.java +++ b/server/src/main/java/org/opensearch/search/SearchModule.java @@ -34,6 +34,7 @@ import org.apache.lucene.search.BooleanQuery; import org.opensearch.common.NamedRegistry; +import org.opensearch.common.Nullable; import org.opensearch.common.ParseField; import org.opensearch.common.geo.GeoShapeType; import org.opensearch.common.geo.ShapesAvailability; @@ -273,6 +274,8 @@ import org.opensearch.search.fetch.subphase.highlight.Highlighter; import org.opensearch.search.fetch.subphase.highlight.PlainHighlighter; import org.opensearch.search.fetch.subphase.highlight.UnifiedHighlighter; +import org.opensearch.search.query.QueryPhase; +import org.opensearch.search.query.QueryPhaseSearcher; import org.opensearch.search.rescore.QueryRescorerBuilder; import org.opensearch.search.rescore.RescorerBuilder; import org.opensearch.search.sort.FieldSortBuilder; @@ -293,11 +296,14 @@ import org.opensearch.search.suggest.phrase.StupidBackoff; import org.opensearch.search.suggest.term.TermSuggestion; import org.opensearch.search.suggest.term.TermSuggestionBuilder; +import org.opensearch.threadpool.ThreadPool; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Optional; +import java.util.concurrent.ExecutorService; import java.util.function.Consumer; import java.util.function.Function; @@ -329,6 +335,8 @@ public class SearchModule { private final List namedWriteables = new ArrayList<>(); private final List namedXContents = new ArrayList<>(); private final ValuesSourceRegistry valuesSourceRegistry; + private final QueryPhaseSearcher queryPhaseSearcher; + private final SearchPlugin.ExecutorServiceProvider indexSearcherExecutorProvider; /** * Constructs a new SearchModule object @@ -355,6 +363,8 @@ public SearchModule(Settings settings, List plugins) { registerSearchExts(plugins); registerShapes(); registerIntervalsSourceProviders(); + queryPhaseSearcher = registerQueryPhaseSearcher(plugins); + indexSearcherExecutorProvider = registerIndexSearcherExecutorProvider(plugins); namedWriteables.addAll(SortValue.namedWriteables()); } @@ -1282,7 +1292,49 @@ private void registerSort(SortSpec spec) { ); } + private QueryPhaseSearcher registerQueryPhaseSearcher(List plugins) { + QueryPhaseSearcher searcher = null; + + for (SearchPlugin plugin : plugins) { + final Optional searcherOpt = plugin.getQueryPhaseSearcher(); + + if (searcher == null) { + searcher = searcherOpt.orElse(null); + } else if (searcherOpt.isPresent()) { + throw new IllegalStateException("Only one QueryPhaseSearcher is allowed, but more than one are provided by the plugins"); + } + } + + return searcher; + } + + private SearchPlugin.ExecutorServiceProvider registerIndexSearcherExecutorProvider(List plugins) { + SearchPlugin.ExecutorServiceProvider provider = null; + + for (SearchPlugin plugin : plugins) { + final Optional providerOpt = plugin.getIndexSearcherExecutorProvider(); + + if (provider == null) { + provider = providerOpt.orElse(null); + } else if (providerOpt.isPresent()) { + throw new IllegalStateException( + "The index searcher executor is already assigned but more than one are provided by the plugins" + ); + } + } + + return provider; + } + public FetchPhase getFetchPhase() { return new FetchPhase(fetchSubPhases); } + + public QueryPhase getQueryPhase() { + return (queryPhaseSearcher == null) ? new QueryPhase() : new QueryPhase(queryPhaseSearcher); + } + + public @Nullable ExecutorService getIndexSearcherExecutor(ThreadPool pool) { + return (indexSearcherExecutorProvider == null) ? null : indexSearcherExecutorProvider.getExecutor(pool); + } } diff --git a/server/src/main/java/org/opensearch/search/SearchService.java b/server/src/main/java/org/opensearch/search/SearchService.java index 0ffe859879453..5a5f223d33e60 100644 --- a/server/src/main/java/org/opensearch/search/SearchService.java +++ b/server/src/main/java/org/opensearch/search/SearchService.java @@ -256,6 +256,7 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv private final AtomicInteger openScrollContexts = new AtomicInteger(); private final String sessionId = UUIDs.randomBase64UUID(); + private final Executor indexSearcherExecutor; public SearchService( ClusterService clusterService, @@ -263,9 +264,11 @@ public SearchService( ThreadPool threadPool, ScriptService scriptService, BigArrays bigArrays, + QueryPhase queryPhase, FetchPhase fetchPhase, ResponseCollectorService responseCollectorService, - CircuitBreakerService circuitBreakerService + CircuitBreakerService circuitBreakerService, + Executor indexSearcherExecutor ) { Settings settings = clusterService.getSettings(); this.threadPool = threadPool; @@ -274,13 +277,14 @@ public SearchService( this.scriptService = scriptService; this.responseCollectorService = responseCollectorService; this.bigArrays = bigArrays; - this.queryPhase = new QueryPhase(); + this.queryPhase = queryPhase; this.fetchPhase = fetchPhase; this.multiBucketConsumerService = new MultiBucketConsumerService( clusterService, settings, circuitBreakerService.getBreaker(CircuitBreaker.REQUEST) ); + this.indexSearcherExecutor = indexSearcherExecutor; TimeValue keepAliveInterval = KEEPALIVE_INTERVAL_SETTING.get(settings); setKeepAlives(DEFAULT_KEEPALIVE_SETTING.get(settings), MAX_KEEPALIVE_SETTING.get(settings)); @@ -884,7 +888,8 @@ private DefaultSearchContext createSearchContext(ReaderContext reader, ShardSear fetchPhase, lowLevelCancellation, clusterService.state().nodes().getMinNodeVersion(), - validate + validate, + indexSearcherExecutor ); // we clone the query shard context here just for rewriting otherwise we // might end up with incorrect state since we are using now() or script services diff --git a/server/src/main/java/org/opensearch/search/query/QueryPhase.java b/server/src/main/java/org/opensearch/search/query/QueryPhase.java index 7d4b8738c1800..3edbc16cd613f 100644 --- a/server/src/main/java/org/opensearch/search/query/QueryPhase.java +++ b/server/src/main/java/org/opensearch/search/query/QueryPhase.java @@ -72,6 +72,7 @@ import java.io.IOException; import java.util.LinkedList; +import java.util.Objects; import java.util.concurrent.ExecutorService; import static org.opensearch.search.query.QueryCollectorContext.createEarlyTerminationCollectorContext; @@ -88,12 +89,19 @@ public class QueryPhase { private static final Logger LOGGER = LogManager.getLogger(QueryPhase.class); // TODO: remove this property public static final boolean SYS_PROP_REWRITE_SORT = Booleans.parseBoolean(System.getProperty("opensearch.search.rewrite_sort", "true")); + public static final QueryPhaseSearcher DEFAULT_QUERY_PHASE_SEARCHER = new DefaultQueryPhaseSearcher(); + private final QueryPhaseSearcher queryPhaseSearcher; private final AggregationPhase aggregationPhase; private final SuggestPhase suggestPhase; private final RescorePhase rescorePhase; public QueryPhase() { + this(DEFAULT_QUERY_PHASE_SEARCHER); + } + + public QueryPhase(QueryPhaseSearcher queryPhaseSearcher) { + this.queryPhaseSearcher = Objects.requireNonNull(queryPhaseSearcher, "QueryPhaseSearcher is required"); this.aggregationPhase = new AggregationPhase(); this.suggestPhase = new SuggestPhase(); this.rescorePhase = new RescorePhase(); @@ -139,7 +147,7 @@ public void execute(SearchContext searchContext) throws QueryPhaseExecutionExcep // request, preProcess is called on the DFS phase phase, this is why we pre-process them // here to make sure it happens during the QUERY phase aggregationPhase.preProcess(searchContext); - boolean rescore = executeInternal(searchContext); + boolean rescore = executeInternal(searchContext, queryPhaseSearcher); if (rescore) { // only if we do a regular search rescorePhase.execute(searchContext); @@ -162,6 +170,15 @@ public void execute(SearchContext searchContext) throws QueryPhaseExecutionExcep * @return whether the rescoring phase should be executed */ static boolean executeInternal(SearchContext searchContext) throws QueryPhaseExecutionException { + return executeInternal(searchContext, QueryPhase.DEFAULT_QUERY_PHASE_SEARCHER); + } + + /** + * In a package-private method so that it can be tested without having to + * wire everything (mapperService, etc.) + * @return whether the rescoring phase should be executed + */ + static boolean executeInternal(SearchContext searchContext, QueryPhaseSearcher queryPhaseSearcher) throws QueryPhaseExecutionException { final ContextIndexSearcher searcher = searchContext.searcher(); final IndexReader reader = searcher.getIndexReader(); QuerySearchResult queryResult = searchContext.queryResult(); @@ -261,13 +278,22 @@ static boolean executeInternal(SearchContext searchContext) throws QueryPhaseExe } try { - boolean shouldRescore = searchWithCollector(searchContext, searcher, query, collectors, hasFilterCollector, timeoutSet); + boolean shouldRescore = queryPhaseSearcher.searchWith( + searchContext, + searcher, + query, + collectors, + hasFilterCollector, + timeoutSet + ); + ExecutorService executor = searchContext.indexShard().getThreadPool().executor(ThreadPool.Names.SEARCH); if (executor instanceof QueueResizingOpenSearchThreadPoolExecutor) { QueueResizingOpenSearchThreadPoolExecutor rExecutor = (QueueResizingOpenSearchThreadPoolExecutor) executor; queryResult.nodeQueueSize(rExecutor.getCurrentQueueSize()); queryResult.serviceTimeEWMA((long) rExecutor.getTaskExecutionEWMA()); } + return shouldRescore; } finally { // Search phase has finished, no longer need to check for timeout @@ -358,5 +384,43 @@ private static boolean canEarlyTerminate(IndexReader reader, SortAndFormats sort return true; } - private static class TimeExceededException extends RuntimeException {} + /** + * The exception being raised when search timeout is reached. + */ + public static class TimeExceededException extends RuntimeException { + private static final long serialVersionUID = 1L; + } + + /** + * Default {@link QueryPhaseSearcher} implementation which delegates to the {@link QueryPhase}. + */ + public static class DefaultQueryPhaseSearcher implements QueryPhaseSearcher { + /** + * Please use {@link QueryPhase#DEFAULT_QUERY_PHASE_SEARCHER} + */ + protected DefaultQueryPhaseSearcher() {} + + @Override + public boolean searchWith( + SearchContext searchContext, + ContextIndexSearcher searcher, + Query query, + LinkedList collectors, + boolean hasFilterCollector, + boolean hasTimeout + ) throws IOException { + return searchWithCollector(searchContext, searcher, query, collectors, hasFilterCollector, hasTimeout); + } + + protected boolean searchWithCollector( + SearchContext searchContext, + ContextIndexSearcher searcher, + Query query, + LinkedList collectors, + boolean hasFilterCollector, + boolean hasTimeout + ) throws IOException { + return QueryPhase.searchWithCollector(searchContext, searcher, query, collectors, hasFilterCollector, hasTimeout); + } + } } diff --git a/server/src/main/java/org/opensearch/search/query/QueryPhaseSearcher.java b/server/src/main/java/org/opensearch/search/query/QueryPhaseSearcher.java new file mode 100644 index 0000000000000..9a48f030fe147 --- /dev/null +++ b/server/src/main/java/org/opensearch/search/query/QueryPhaseSearcher.java @@ -0,0 +1,41 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.search.query; + +import org.apache.lucene.search.CollectorManager; +import org.apache.lucene.search.Query; +import org.opensearch.search.internal.ContextIndexSearcher; +import org.opensearch.search.internal.SearchContext; + +import java.io.IOException; +import java.util.LinkedList; + +/** + * The extension point which allows to plug in custom search implementation to be + * used at {@link QueryPhase}. + */ +public interface QueryPhaseSearcher { + /** + * Perform search using {@link CollectorManager} + * @param searchContext search context + * @param searcher context index searcher + * @param query query + * @param hasTimeout "true" if timeout was set, "false" otherwise + * @return is rescoring required or not + * @throws IOException IOException + */ + boolean searchWith( + SearchContext searchContext, + ContextIndexSearcher searcher, + Query query, + LinkedList collectors, + boolean hasFilterCollector, + boolean hasTimeout + ) throws IOException; +} diff --git a/server/src/test/java/org/opensearch/search/DefaultSearchContextTests.java b/server/src/test/java/org/opensearch/search/DefaultSearchContextTests.java index 3429e1635b58b..e1cf74bdd6aeb 100644 --- a/server/src/test/java/org/opensearch/search/DefaultSearchContextTests.java +++ b/server/src/test/java/org/opensearch/search/DefaultSearchContextTests.java @@ -182,7 +182,8 @@ protected Engine.Searcher acquireSearcherInternal(String source) { null, false, Version.CURRENT, - false + false, + null ); contextWithoutScroll.from(300); contextWithoutScroll.close(); @@ -223,7 +224,8 @@ protected Engine.Searcher acquireSearcherInternal(String source) { null, false, Version.CURRENT, - false + false, + null ); context1.from(300); exception = expectThrows(IllegalArgumentException.class, () -> context1.preProcess(false)); @@ -292,7 +294,8 @@ protected Engine.Searcher acquireSearcherInternal(String source) { null, false, Version.CURRENT, - false + false, + null ); SliceBuilder sliceBuilder = mock(SliceBuilder.class); @@ -330,7 +333,8 @@ protected Engine.Searcher acquireSearcherInternal(String source) { null, false, Version.CURRENT, - false + false, + null ); ParsedQuery parsedQuery = ParsedQuery.parsedMatchAllQuery(); context3.sliceBuilder(null).parsedQuery(parsedQuery).preProcess(false); @@ -360,7 +364,8 @@ protected Engine.Searcher acquireSearcherInternal(String source) { null, false, Version.CURRENT, - false + false, + null ); context4.sliceBuilder(new SliceBuilder(1, 2)).parsedQuery(parsedQuery).preProcess(false); Query query1 = context4.query(); @@ -440,7 +445,8 @@ protected Engine.Searcher acquireSearcherInternal(String source) { null, false, Version.CURRENT, - false + false, + null ); assertThat(context.searcher().hasCancellations(), is(false)); context.searcher().addQueryCancellation(() -> {}); diff --git a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java index 7855f7f2b0e59..26e19e532b6bc 100644 --- a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java +++ b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java @@ -196,6 +196,7 @@ import org.opensearch.search.SearchService; import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.search.fetch.FetchPhase; +import org.opensearch.search.query.QueryPhase; import org.opensearch.snapshots.mockstore.MockEventuallyConsistentRepository; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.disruption.DisruptableMockTransport; @@ -1977,9 +1978,11 @@ public void onFailure(final Exception e) { threadPool, scriptService, bigArrays, + new QueryPhase(), new FetchPhase(Collections.emptyList()), responseCollectorService, - new NoneCircuitBreakerService() + new NoneCircuitBreakerService(), + null ); SearchPhaseController searchPhaseController = new SearchPhaseController( writableRegistry(), diff --git a/test/framework/src/main/java/org/opensearch/node/MockNode.java b/test/framework/src/main/java/org/opensearch/node/MockNode.java index e3e77ae1da48f..1bb034588d20e 100644 --- a/test/framework/src/main/java/org/opensearch/node/MockNode.java +++ b/test/framework/src/main/java/org/opensearch/node/MockNode.java @@ -59,6 +59,7 @@ import org.opensearch.search.MockSearchService; import org.opensearch.search.SearchService; import org.opensearch.search.fetch.FetchPhase; +import org.opensearch.search.query.QueryPhase; import org.opensearch.test.MockHttpTransport; import org.opensearch.test.transport.MockTransportService; import org.opensearch.threadpool.ThreadPool; @@ -71,6 +72,7 @@ import java.util.Collections; import java.util.Map; import java.util.Set; +import java.util.concurrent.Executor; import java.util.function.Function; /** @@ -148,9 +150,11 @@ protected SearchService newSearchService( ThreadPool threadPool, ScriptService scriptService, BigArrays bigArrays, + QueryPhase queryPhase, FetchPhase fetchPhase, ResponseCollectorService responseCollectorService, - CircuitBreakerService circuitBreakerService + CircuitBreakerService circuitBreakerService, + Executor indexSearcherExecutor ) { if (getPluginsService().filterPlugins(MockSearchService.TestPlugin.class).isEmpty()) { return super.newSearchService( @@ -159,9 +163,11 @@ protected SearchService newSearchService( threadPool, scriptService, bigArrays, + queryPhase, fetchPhase, responseCollectorService, - circuitBreakerService + circuitBreakerService, + indexSearcherExecutor ); } return new MockSearchService( @@ -170,6 +176,7 @@ protected SearchService newSearchService( threadPool, scriptService, bigArrays, + queryPhase, fetchPhase, circuitBreakerService ); diff --git a/test/framework/src/main/java/org/opensearch/search/MockSearchService.java b/test/framework/src/main/java/org/opensearch/search/MockSearchService.java index a05066cef1804..fd522cd298632 100644 --- a/test/framework/src/main/java/org/opensearch/search/MockSearchService.java +++ b/test/framework/src/main/java/org/opensearch/search/MockSearchService.java @@ -41,6 +41,7 @@ import org.opensearch.script.ScriptService; import org.opensearch.search.fetch.FetchPhase; import org.opensearch.search.internal.ReaderContext; +import org.opensearch.search.query.QueryPhase; import org.opensearch.threadpool.ThreadPool; import java.util.HashMap; @@ -91,10 +92,22 @@ public MockSearchService( ThreadPool threadPool, ScriptService scriptService, BigArrays bigArrays, + QueryPhase queryPhase, FetchPhase fetchPhase, CircuitBreakerService circuitBreakerService ) { - super(clusterService, indicesService, threadPool, scriptService, bigArrays, fetchPhase, null, circuitBreakerService); + super( + clusterService, + indicesService, + threadPool, + scriptService, + bigArrays, + queryPhase, + fetchPhase, + null, + circuitBreakerService, + null + ); } @Override From fb76361812367ed5dc4ff7aea09ec9e93610d449 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 23:32:44 -0500 Subject: [PATCH 46/46] Bump antlr4 from 4.5.3 to 4.9.3 in /modules/lang-painless (#2537) Bumps [antlr4](https://github.com/antlr/antlr4) from 4.5.3 to 4.9.3. - [Release notes](https://github.com/antlr/antlr4/releases) - [Changelog](https://github.com/antlr/antlr4/blob/master/CHANGES.txt) - [Commits](https://github.com/antlr/antlr4/compare/4.5.3...4.9.3) --- updated-dependencies: - dependency-name: org.antlr:antlr4 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- modules/lang-painless/build.gradle | 2 +- modules/lang-painless/licenses/antlr4-runtime-4.5.3.jar.sha1 | 1 - modules/lang-painless/licenses/antlr4-runtime-4.9.3.jar.sha1 | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 modules/lang-painless/licenses/antlr4-runtime-4.5.3.jar.sha1 create mode 100644 modules/lang-painless/licenses/antlr4-runtime-4.9.3.jar.sha1 diff --git a/modules/lang-painless/build.gradle b/modules/lang-painless/build.gradle index a85f83f762526..7f37b5e76d904 100644 --- a/modules/lang-painless/build.gradle +++ b/modules/lang-painless/build.gradle @@ -45,7 +45,7 @@ testClusters.all { } dependencies { - api 'org.antlr:antlr4-runtime:4.5.3' + api 'org.antlr:antlr4-runtime:4.9.3' api 'org.ow2.asm:asm-util:9.2' api 'org.ow2.asm:asm-tree:7.2' api 'org.ow2.asm:asm-commons:9.2' diff --git a/modules/lang-painless/licenses/antlr4-runtime-4.5.3.jar.sha1 b/modules/lang-painless/licenses/antlr4-runtime-4.5.3.jar.sha1 deleted file mode 100644 index 535955b7d6826..0000000000000 --- a/modules/lang-painless/licenses/antlr4-runtime-4.5.3.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -2609e36f18f7e8d593cc1cddfb2ac776dc96b8e0 \ No newline at end of file diff --git a/modules/lang-painless/licenses/antlr4-runtime-4.9.3.jar.sha1 b/modules/lang-painless/licenses/antlr4-runtime-4.9.3.jar.sha1 new file mode 100644 index 0000000000000..13a2367439ede --- /dev/null +++ b/modules/lang-painless/licenses/antlr4-runtime-4.9.3.jar.sha1 @@ -0,0 +1 @@ +81befc16ebedb8b8aea3e4c0835dd5ca7e8523a8 \ No newline at end of file