From 77d106015fdc28ba29bb758ba76e0cf790f61da3 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Wed, 16 Mar 2022 11:17:33 -0400 Subject: [PATCH 1/6] Fixing PluginsServiceTests (post Lucene 9 update) (#2484) Signed-off-by: Andriy Redko --- .../test/java/org/opensearch/plugins/PluginsServiceTests.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/server/src/test/java/org/opensearch/plugins/PluginsServiceTests.java b/server/src/test/java/org/opensearch/plugins/PluginsServiceTests.java index 572d2c322153f..bddc61211592e 100644 --- a/server/src/test/java/org/opensearch/plugins/PluginsServiceTests.java +++ b/server/src/test/java/org/opensearch/plugins/PluginsServiceTests.java @@ -648,7 +648,6 @@ public void testJarHellTransitiveMap() throws Exception { assertThat(deps, containsInAnyOrder(pluginJar.toUri().toURL(), dep1Jar.toUri().toURL(), dep2Jar.toUri().toURL())); } - @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/2063") public void testNonExtensibleDep() throws Exception { // This test opens a child classloader, reading a jar under the test temp // dir (a dummy plugin). Classloaders are closed by GC, so when test teardown @@ -791,7 +790,6 @@ public FakePlugin() { } - @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/2063") public void testExistingMandatoryInstalledPlugin() throws IOException { // This test opens a child classloader, reading a jar under the test temp // dir (a dummy plugin). Classloaders are closed by GC, so when test teardown @@ -825,7 +823,6 @@ public void testExistingMandatoryInstalledPlugin() throws IOException { newPluginsService(settings); } - @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/2063") public void testPluginFromParentClassLoader() throws IOException { final Path pathHome = createTempDir(); final Path plugins = pathHome.resolve("plugins"); @@ -863,7 +860,6 @@ public void testPluginFromParentClassLoader() throws IOException { ); } - @AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/2063") public void testPluginLoadFailure() throws IOException { final Path pathHome = createTempDir(); final Path plugins = pathHome.resolve("plugins"); 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 2/6] 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 3/6] 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 4/6] [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 5/6] [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 6/6] [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); }