diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 026715279..e3f749fac 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,7 +21,7 @@ jobs: needs: Get-CI-Image-Tag strategy: matrix: - java: [11, 17] + java: [11, 17, 21] os: [ubuntu-latest] name: Gradle Check Linux @@ -55,7 +55,7 @@ jobs: Check-neural-search-windows: strategy: matrix: - java: [11, 17] + java: [11, 17, 21] os: [windows-latest] name: Gradle Check Windows @@ -83,7 +83,7 @@ jobs: needs: Get-CI-Image-Tag strategy: matrix: - java: [11, 17] + java: [11, 17, 21] os: [ubuntu-latest] name: Pre-commit Linux @@ -117,7 +117,7 @@ jobs: Precommit-neural-search-windows: strategy: matrix: - java: [11, 17] + java: [11, 17, 21] os: [windows-latest] name: Pre-commit Windows diff --git a/CHANGELOG.md b/CHANGELOG.md index 00aa761e4..a4f962510 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,5 +21,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Infrastructure ### Documentation ### Maintenance +- Added support for jdk-21 ([#500](https://github.com/opensearch-project/neural-search/pull/500))) ### Refactoring Deprecate the `max_token_score` field in `neural_sparse` query clause ([#478](https://github.com/opensearch-project/neural-search/pull/478)) diff --git a/build.gradle b/build.gradle index dd2ab1dcf..47f5cec3a 100644 --- a/build.gradle +++ b/build.gradle @@ -109,8 +109,8 @@ buildscript { dependencies { classpath "${opensearch_group}.gradle:build-tools:${opensearch_version}" - classpath "com.diffplug.spotless:spotless-plugin-gradle:5.6.1" - classpath "io.freefair.gradle:lombok-plugin:8.0.1" + classpath "com.diffplug.spotless:spotless-plugin-gradle:6.23.2" + classpath "io.freefair.gradle:lombok-plugin:8.4" } } @@ -144,7 +144,7 @@ dependencies { zipArchive group: 'org.opensearch.plugin', name:'opensearch-ml-plugin', version: "${opensearch_build}" compileOnly fileTree(dir: knnJarDirectory, include: '*.jar') api group: 'org.opensearch', name:'opensearch-ml-client', version: "${opensearch_build}" - implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.10' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0' // ml-common excluded reflection for runtime so we need to add it by ourselves. // https://github.com/opensearch-project/ml-commons/commit/464bfe34c66d7a729a00dd457f03587ea4e504d9 // TODO: Remove following three lines of dependencies if ml-common include them in their jar @@ -255,7 +255,7 @@ testClusters.integTest { // Increase heap size from default of 512mb to 1gb. When heap size is 512mb, our integ tests sporadically fail due // to ml-commons memory circuit breaker exception - jvmArgs("-Xms1g", "-Xmx1g") + jvmArgs("-Xms1g", "-Xmx4g") } // Remote Integration Tests diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a79e..7f93135c4 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 560c9869d..46671acb6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,8 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f diff --git a/src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java b/src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java index 2ccef0746..df6dfbbe5 100644 --- a/src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java +++ b/src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java @@ -16,10 +16,6 @@ import java.util.Objects; import java.util.stream.Collectors; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.extern.log4j.Log4j2; - import org.apache.logging.log4j.util.Strings; import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.util.CollectionUtils; @@ -35,6 +31,10 @@ import org.opensearch.ml.common.output.model.ModelTensors; import org.opensearch.neuralsearch.util.RetryUtil; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.extern.log4j.Log4j2; + /** * This class will act as an abstraction on the MLCommons client for accessing the ML Capabilities */ diff --git a/src/main/java/org/opensearch/neuralsearch/plugin/NeuralSearch.java b/src/main/java/org/opensearch/neuralsearch/plugin/NeuralSearch.java index 8672c6142..f244419b3 100644 --- a/src/main/java/org/opensearch/neuralsearch/plugin/NeuralSearch.java +++ b/src/main/java/org/opensearch/neuralsearch/plugin/NeuralSearch.java @@ -14,8 +14,6 @@ import java.util.Optional; import java.util.function.Supplier; -import lombok.extern.log4j.Log4j2; - import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; @@ -61,6 +59,8 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.watcher.ResourceWatcherService; +import lombok.extern.log4j.Log4j2; + /** * Neural Search plugin class */ diff --git a/src/main/java/org/opensearch/neuralsearch/processor/CompoundTopDocs.java b/src/main/java/org/opensearch/neuralsearch/processor/CompoundTopDocs.java index 7ab497825..b7aa43c64 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/CompoundTopDocs.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/CompoundTopDocs.java @@ -14,16 +14,16 @@ import java.util.Objects; import java.util.stream.Collectors; +import org.apache.lucene.search.ScoreDoc; +import org.apache.lucene.search.TopDocs; +import org.apache.lucene.search.TotalHits; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.ToString; import lombok.extern.log4j.Log4j2; -import org.apache.lucene.search.ScoreDoc; -import org.apache.lucene.search.TopDocs; -import org.apache.lucene.search.TotalHits; - /** * Class stores collection of TopDocs for each sub query from hybrid query. Collection of results is at shard level. We do store * list of TopDocs and list of ScoreDoc as well as total hits for the shard. diff --git a/src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java index 19944c11b..e66c3f7f3 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java @@ -14,8 +14,6 @@ import java.util.function.Supplier; import java.util.stream.IntStream; -import lombok.extern.log4j.Log4j2; - import org.apache.commons.lang3.StringUtils; import org.opensearch.env.Environment; import org.opensearch.index.mapper.MapperService; @@ -26,6 +24,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; +import lombok.extern.log4j.Log4j2; + /** * The abstract class for text processing use cases. Users provide a field name map and a model id. * During ingestion, the processor will use the corresponding model to inference the input texts, diff --git a/src/main/java/org/opensearch/neuralsearch/processor/NeuralQueryEnricherProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/NeuralQueryEnricherProcessor.java index 379c6a8cc..c95e0f526 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/NeuralQueryEnricherProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/NeuralQueryEnricherProcessor.java @@ -10,9 +10,6 @@ import java.util.Map; -import lombok.Getter; -import lombok.Setter; - import org.opensearch.action.search.SearchRequest; import org.opensearch.common.Nullable; import org.opensearch.index.query.QueryBuilder; @@ -22,6 +19,9 @@ import org.opensearch.search.pipeline.Processor; import org.opensearch.search.pipeline.SearchRequestProcessor; +import lombok.Getter; +import lombok.Setter; + /** * Neural Search Query Request Processor, It modifies the search request with neural query clause * and adds model Id if not present in the search query. diff --git a/src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessor.java index 997f08854..0d6742dbe 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessor.java @@ -12,9 +12,6 @@ import java.util.Optional; import java.util.stream.Collectors; -import lombok.AllArgsConstructor; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.search.QueryPhaseResultConsumer; import org.opensearch.action.search.SearchPhaseContext; import org.opensearch.action.search.SearchPhaseName; @@ -27,6 +24,9 @@ import org.opensearch.search.pipeline.SearchPhaseResultsProcessor; import org.opensearch.search.query.QuerySearchResult; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; + /** * Processor for score normalization and combination on post query search results. Updates query results with * normalized and combined scores for next phase (typically it's FETCH) diff --git a/src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessorWorkflow.java b/src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessorWorkflow.java index 9e0069b21..b8bc86de5 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessorWorkflow.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/NormalizationProcessorWorkflow.java @@ -14,9 +14,6 @@ import java.util.Optional; import java.util.stream.Collectors; -import lombok.AllArgsConstructor; -import lombok.extern.log4j.Log4j2; - import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TopDocs; import org.opensearch.common.lucene.search.TopDocsAndMaxScore; @@ -29,6 +26,9 @@ import org.opensearch.search.fetch.FetchSearchResult; import org.opensearch.search.query.QuerySearchResult; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; + /** * Class abstracts steps required for score normalization and combination, this includes pre-processing of incoming data * and post-processing of final results diff --git a/src/main/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessor.java index b5bb85aac..d1433e983 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessor.java @@ -9,14 +9,14 @@ import java.util.Map; import java.util.function.BiConsumer; -import lombok.extern.log4j.Log4j2; - import org.opensearch.core.action.ActionListener; import org.opensearch.env.Environment; import org.opensearch.ingest.IngestDocument; import org.opensearch.neuralsearch.ml.MLCommonsClientAccessor; import org.opensearch.neuralsearch.util.TokenWeightUtil; +import lombok.extern.log4j.Log4j2; + /** * This processor is used for user input data text sparse encoding processing, model_id can be used to indicate which model user use, * and field_map can be used to indicate which fields needs text embedding and the corresponding keys for the sparse encoding results. diff --git a/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java index c30d14caf..3e87188e8 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java @@ -9,13 +9,13 @@ import java.util.Map; import java.util.function.BiConsumer; -import lombok.extern.log4j.Log4j2; - import org.opensearch.core.action.ActionListener; import org.opensearch.env.Environment; import org.opensearch.ingest.IngestDocument; import org.opensearch.neuralsearch.ml.MLCommonsClientAccessor; +import lombok.extern.log4j.Log4j2; + /** * This processor is used for user input data text embedding processing, model_id can be used to indicate which model user use, * and field_map can be used to indicate which fields needs text embedding and the corresponding keys for the text embedding results. diff --git a/src/main/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessor.java index a0d9606e9..9a252bace 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessor.java @@ -15,8 +15,6 @@ import java.util.function.BiConsumer; import java.util.function.Supplier; -import lombok.extern.log4j.Log4j2; - import org.apache.commons.lang3.StringUtils; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; @@ -30,6 +28,8 @@ import com.google.common.annotations.VisibleForTesting; +import lombok.extern.log4j.Log4j2; + /** * This processor is used for user input data text and image embedding processing, model_id can be used to indicate which model user use, * and field_map can be used to indicate which fields needs embedding and the corresponding keys for the embedding results. diff --git a/src/main/java/org/opensearch/neuralsearch/processor/combination/ScoreCombinationUtil.java b/src/main/java/org/opensearch/neuralsearch/processor/combination/ScoreCombinationUtil.java index ed82a62ea..c92abba4d 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/combination/ScoreCombinationUtil.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/combination/ScoreCombinationUtil.java @@ -14,12 +14,12 @@ import java.util.Set; import java.util.stream.Collectors; -import lombok.extern.log4j.Log4j2; - import org.apache.commons.lang3.Range; import com.google.common.math.DoubleMath; +import lombok.extern.log4j.Log4j2; + /** * Collection of utility methods for score combination technique classes */ diff --git a/src/main/java/org/opensearch/neuralsearch/processor/combination/ScoreCombiner.java b/src/main/java/org/opensearch/neuralsearch/processor/combination/ScoreCombiner.java index 0293efae6..22745c50a 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/combination/ScoreCombiner.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/combination/ScoreCombiner.java @@ -13,13 +13,13 @@ import java.util.Objects; import java.util.stream.Collectors; -import lombok.extern.log4j.Log4j2; - import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.TotalHits; import org.opensearch.neuralsearch.processor.CompoundTopDocs; +import lombok.extern.log4j.Log4j2; + /** * Abstracts combination of scores in query search results. */ diff --git a/src/main/java/org/opensearch/neuralsearch/processor/factory/NormalizationProcessorFactory.java b/src/main/java/org/opensearch/neuralsearch/processor/factory/NormalizationProcessorFactory.java index 71412e736..92ab2b1df 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/factory/NormalizationProcessorFactory.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/factory/NormalizationProcessorFactory.java @@ -11,9 +11,6 @@ import java.util.Map; import java.util.Objects; -import lombok.AllArgsConstructor; -import lombok.extern.log4j.Log4j2; - import org.opensearch.neuralsearch.processor.NormalizationProcessor; import org.opensearch.neuralsearch.processor.NormalizationProcessorWorkflow; import org.opensearch.neuralsearch.processor.combination.ArithmeticMeanScoreCombinationTechnique; @@ -25,6 +22,9 @@ import org.opensearch.search.pipeline.Processor; import org.opensearch.search.pipeline.SearchPhaseResultsProcessor; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; + /** * Factory for query results normalization processor for search pipeline. Instantiates processor based on user provided input. */ diff --git a/src/main/java/org/opensearch/neuralsearch/processor/factory/SparseEncodingProcessorFactory.java b/src/main/java/org/opensearch/neuralsearch/processor/factory/SparseEncodingProcessorFactory.java index 104418ec5..609ee07be 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/factory/SparseEncodingProcessorFactory.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/factory/SparseEncodingProcessorFactory.java @@ -11,13 +11,13 @@ import java.util.Map; -import lombok.extern.log4j.Log4j2; - import org.opensearch.env.Environment; import org.opensearch.ingest.Processor; import org.opensearch.neuralsearch.ml.MLCommonsClientAccessor; import org.opensearch.neuralsearch.processor.SparseEncodingProcessor; +import lombok.extern.log4j.Log4j2; + /** * Factory for sparse encoding ingest processor for ingestion pipeline. Instantiates processor based on user provided input. */ diff --git a/src/main/java/org/opensearch/neuralsearch/processor/factory/TextImageEmbeddingProcessorFactory.java b/src/main/java/org/opensearch/neuralsearch/processor/factory/TextImageEmbeddingProcessorFactory.java index c18ec6fb3..3820d84c7 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/factory/TextImageEmbeddingProcessorFactory.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/factory/TextImageEmbeddingProcessorFactory.java @@ -15,13 +15,13 @@ import java.util.Map; -import lombok.AllArgsConstructor; - import org.opensearch.cluster.service.ClusterService; import org.opensearch.env.Environment; import org.opensearch.neuralsearch.ml.MLCommonsClientAccessor; import org.opensearch.neuralsearch.processor.TextImageEmbeddingProcessor; +import lombok.AllArgsConstructor; + /** * Factory for text_image embedding ingest processor for ingestion pipeline. Instantiates processor based on user provided input. */ diff --git a/src/main/java/org/opensearch/neuralsearch/processor/normalization/L2ScoreNormalizationTechnique.java b/src/main/java/org/opensearch/neuralsearch/processor/normalization/L2ScoreNormalizationTechnique.java index a8c0a5953..7f7d18546 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/normalization/L2ScoreNormalizationTechnique.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/normalization/L2ScoreNormalizationTechnique.java @@ -9,12 +9,12 @@ import java.util.List; import java.util.Objects; -import lombok.ToString; - import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TopDocs; import org.opensearch.neuralsearch.processor.CompoundTopDocs; +import lombok.ToString; + /** * Abstracts normalization of scores based on L2 method */ diff --git a/src/main/java/org/opensearch/neuralsearch/processor/normalization/MinMaxScoreNormalizationTechnique.java b/src/main/java/org/opensearch/neuralsearch/processor/normalization/MinMaxScoreNormalizationTechnique.java index 6452e6dcd..bd1112840 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/normalization/MinMaxScoreNormalizationTechnique.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/normalization/MinMaxScoreNormalizationTechnique.java @@ -9,14 +9,14 @@ import java.util.List; import java.util.Objects; -import lombok.ToString; - import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TopDocs; import org.opensearch.neuralsearch.processor.CompoundTopDocs; import com.google.common.primitives.Floats; +import lombok.ToString; + /** * Abstracts normalization of scores based on min-max method */ diff --git a/src/main/java/org/opensearch/neuralsearch/query/HybridQueryBuilder.java b/src/main/java/org/opensearch/neuralsearch/query/HybridQueryBuilder.java index 19540550d..a0019c826 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/HybridQueryBuilder.java +++ b/src/main/java/org/opensearch/neuralsearch/query/HybridQueryBuilder.java @@ -13,12 +13,6 @@ import java.util.Objects; import java.util.stream.Collectors; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.Accessors; -import lombok.extern.log4j.Log4j2; - import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.lucene.search.Query; import org.opensearch.common.lucene.search.Queries; @@ -35,6 +29,12 @@ import org.opensearch.index.query.QueryShardException; import org.opensearch.index.query.Rewriteable; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.Accessors; +import lombok.extern.log4j.Log4j2; + /** * Class abstract creation of a Query type "hybrid". Hybrid query will allow execution of multiple sub-queries and * collects score for each of those sub-query. diff --git a/src/main/java/org/opensearch/neuralsearch/query/HybridQueryScorer.java b/src/main/java/org/opensearch/neuralsearch/query/HybridQueryScorer.java index 9ee3e9dbb..109a50d05 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/HybridQueryScorer.java +++ b/src/main/java/org/opensearch/neuralsearch/query/HybridQueryScorer.java @@ -12,8 +12,6 @@ import java.util.Map; import java.util.Objects; -import lombok.Getter; - import org.apache.lucene.search.DisiPriorityQueue; import org.apache.lucene.search.DisiWrapper; import org.apache.lucene.search.DisjunctionDISIApproximation; @@ -22,6 +20,8 @@ import org.apache.lucene.search.Scorer; import org.apache.lucene.search.Weight; +import lombok.Getter; + /** * Class abstracts functionality of Scorer for hybrid query. When iterating over documents in increasing * order of doc id, this class fills up array of scores per sub-query for each doc id. Order in array of scores diff --git a/src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java b/src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java index edb9aace0..2e0e06adc 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java +++ b/src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java @@ -15,14 +15,6 @@ import java.util.Map; import java.util.function.Supplier; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.Accessors; -import lombok.extern.log4j.Log4j2; - import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; @@ -47,6 +39,14 @@ import com.google.common.annotations.VisibleForTesting; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.Accessors; +import lombok.extern.log4j.Log4j2; + /** * NeuralQueryBuilder is responsible for producing "neural" query types. A "neural" query type is a wrapper around a * k-NN vector query. It uses a ML language model to produce a dense vector from a query string that is then used as diff --git a/src/main/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilder.java b/src/main/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilder.java index 20eeb2e11..4d6433015 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilder.java +++ b/src/main/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilder.java @@ -11,13 +11,6 @@ import java.util.Map; import java.util.function.Supplier; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.Accessors; -import lombok.extern.log4j.Log4j2; - import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; @@ -43,6 +36,13 @@ import com.google.common.annotations.VisibleForTesting; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.Accessors; +import lombok.extern.log4j.Log4j2; + /** * SparseEncodingQueryBuilder is responsible for handling "neural_sparse" query types. It uses an ML NEURAL_SPARSE model * or SPARSE_TOKENIZE model to produce a Map with String keys and Float values for input text. Then it will be transformed diff --git a/src/main/java/org/opensearch/neuralsearch/query/visitor/NeuralSearchQueryVisitor.java b/src/main/java/org/opensearch/neuralsearch/query/visitor/NeuralSearchQueryVisitor.java index febb35294..54b478bdc 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/visitor/NeuralSearchQueryVisitor.java +++ b/src/main/java/org/opensearch/neuralsearch/query/visitor/NeuralSearchQueryVisitor.java @@ -7,13 +7,13 @@ import java.util.Map; -import lombok.AllArgsConstructor; - import org.apache.lucene.search.BooleanClause; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryBuilderVisitor; import org.opensearch.neuralsearch.query.NeuralQueryBuilder; +import lombok.AllArgsConstructor; + /** * Neural Search Query Visitor. It visits each and every component of query buikder tree. */ diff --git a/src/main/java/org/opensearch/neuralsearch/search/HitsThresholdChecker.java b/src/main/java/org/opensearch/neuralsearch/search/HitsThresholdChecker.java index 4e5c77a5b..c8c52320f 100644 --- a/src/main/java/org/opensearch/neuralsearch/search/HitsThresholdChecker.java +++ b/src/main/java/org/opensearch/neuralsearch/search/HitsThresholdChecker.java @@ -7,10 +7,10 @@ import java.util.Locale; -import lombok.Getter; - import org.apache.lucene.search.ScoreMode; +import lombok.Getter; + /** * Abstracts algorithm that allows early termination for the search flow if number of hits reached * certain treshold diff --git a/src/main/java/org/opensearch/neuralsearch/search/HybridTopScoreDocCollector.java b/src/main/java/org/opensearch/neuralsearch/search/HybridTopScoreDocCollector.java index 3fa413826..556f09bfd 100644 --- a/src/main/java/org/opensearch/neuralsearch/search/HybridTopScoreDocCollector.java +++ b/src/main/java/org/opensearch/neuralsearch/search/HybridTopScoreDocCollector.java @@ -12,9 +12,6 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import lombok.Getter; -import lombok.extern.log4j.Log4j2; - import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Collector; import org.apache.lucene.search.HitQueue; @@ -28,6 +25,9 @@ import org.apache.lucene.util.PriorityQueue; import org.opensearch.neuralsearch.query.HybridQueryScorer; +import lombok.Getter; +import lombok.extern.log4j.Log4j2; + /** * Collects the TopDocs after executing hybrid query. Uses HybridQueryTopDocs as DTO to handle each sub query results */ diff --git a/src/main/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcher.java b/src/main/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcher.java index 26f580364..539e0e22e 100644 --- a/src/main/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcher.java +++ b/src/main/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcher.java @@ -16,8 +16,6 @@ import java.util.List; import java.util.Objects; -import lombok.extern.log4j.Log4j2; - import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; @@ -48,6 +46,8 @@ import com.google.common.annotations.VisibleForTesting; +import lombok.extern.log4j.Log4j2; + /** * Custom search implementation to be used at {@link QueryPhase} for Hybrid Query search. For queries other than Hybrid the * upstream standard implementation of searcher is called. diff --git a/src/main/java/org/opensearch/neuralsearch/settings/NeuralSearchSettings.java b/src/main/java/org/opensearch/neuralsearch/settings/NeuralSearchSettings.java index 54edf8745..4ac88f75f 100644 --- a/src/main/java/org/opensearch/neuralsearch/settings/NeuralSearchSettings.java +++ b/src/main/java/org/opensearch/neuralsearch/settings/NeuralSearchSettings.java @@ -5,11 +5,11 @@ package org.opensearch.neuralsearch.settings; +import org.opensearch.common.settings.Setting; + import lombok.AccessLevel; import lombok.NoArgsConstructor; -import org.opensearch.common.settings.Setting; - /** * Class defines settings specific to neural-search plugin */ diff --git a/src/main/java/org/opensearch/neuralsearch/util/NeuralSearchClusterUtil.java b/src/main/java/org/opensearch/neuralsearch/util/NeuralSearchClusterUtil.java index 5a97120e0..1f7dd9d4a 100644 --- a/src/main/java/org/opensearch/neuralsearch/util/NeuralSearchClusterUtil.java +++ b/src/main/java/org/opensearch/neuralsearch/util/NeuralSearchClusterUtil.java @@ -5,13 +5,13 @@ package org.opensearch.neuralsearch.util; +import org.opensearch.Version; +import org.opensearch.cluster.service.ClusterService; + import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.extern.log4j.Log4j2; -import org.opensearch.Version; -import org.opensearch.cluster.service.ClusterService; - /** * Class abstracts information related to underlying OpenSearch cluster */ diff --git a/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java b/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java index 73e6c62a1..ecbf67ef0 100644 --- a/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java +++ b/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java @@ -24,10 +24,6 @@ import java.util.function.Predicate; import java.util.stream.Collectors; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.SneakyThrows; - import org.apache.commons.lang3.StringUtils; import org.apache.http.Header; import org.apache.http.HttpEntity; @@ -60,6 +56,10 @@ import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import com.google.common.collect.ImmutableList; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.SneakyThrows; + @ThreadLeakScope(ThreadLeakScope.Scope.NONE) public abstract class BaseNeuralSearchIT extends OpenSearchSecureRestTestCase { diff --git a/src/test/java/org/opensearch/neuralsearch/common/BaseSparseEncodingIT.java b/src/test/java/org/opensearch/neuralsearch/common/BaseSparseEncodingIT.java index 4395bbfcd..e25b4810e 100644 --- a/src/test/java/org/opensearch/neuralsearch/common/BaseSparseEncodingIT.java +++ b/src/test/java/org/opensearch/neuralsearch/common/BaseSparseEncodingIT.java @@ -11,8 +11,6 @@ import java.util.List; import java.util.Map; -import lombok.SneakyThrows; - import org.apache.http.HttpHeaders; import org.apache.http.message.BasicHeader; import org.apache.http.util.EntityUtils; @@ -27,6 +25,8 @@ import com.google.common.collect.ImmutableList; +import lombok.SneakyThrows; + public abstract class BaseSparseEncodingIT extends BaseNeuralSearchIT { @SneakyThrows diff --git a/src/test/java/org/opensearch/neuralsearch/processor/NeuralQueryEnricherProcessorIT.java b/src/test/java/org/opensearch/neuralsearch/processor/NeuralQueryEnricherProcessorIT.java index 7e7660457..f3db15754 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/NeuralQueryEnricherProcessorIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/NeuralQueryEnricherProcessorIT.java @@ -10,8 +10,6 @@ import java.util.Collections; import java.util.Map; -import lombok.SneakyThrows; - import org.junit.After; import org.junit.Before; import org.opensearch.common.settings.Settings; @@ -21,6 +19,8 @@ import com.google.common.primitives.Floats; +import lombok.SneakyThrows; + public class NeuralQueryEnricherProcessorIT extends BaseNeuralSearchIT { private static final String index = "my-nlp-index"; diff --git a/src/test/java/org/opensearch/neuralsearch/processor/NormalizationProcessorIT.java b/src/test/java/org/opensearch/neuralsearch/processor/NormalizationProcessorIT.java index 86e75f736..a1cc58447 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/NormalizationProcessorIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/NormalizationProcessorIT.java @@ -16,8 +16,6 @@ import java.util.Set; import java.util.stream.IntStream; -import lombok.SneakyThrows; - import org.apache.commons.lang3.Range; import org.junit.After; import org.junit.Before; @@ -30,6 +28,8 @@ import com.google.common.primitives.Floats; +import lombok.SneakyThrows; + public class NormalizationProcessorIT extends BaseNeuralSearchIT { private static final String TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME = "test-neural-multi-doc-one-shard-index"; private static final String TEST_MULTI_DOC_INDEX_THREE_SHARDS_NAME = "test-neural-multi-doc-three-shards-index"; diff --git a/src/test/java/org/opensearch/neuralsearch/processor/ScoreCombinationIT.java b/src/test/java/org/opensearch/neuralsearch/processor/ScoreCombinationIT.java index 4993df7fb..ae146311b 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/ScoreCombinationIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/ScoreCombinationIT.java @@ -16,8 +16,6 @@ import java.util.Collections; import java.util.Map; -import lombok.SneakyThrows; - import org.junit.After; import org.junit.Before; import org.opensearch.client.ResponseException; @@ -29,6 +27,8 @@ import com.google.common.primitives.Floats; +import lombok.SneakyThrows; + public class ScoreCombinationIT extends BaseNeuralSearchIT { private static final String TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME = "test-neural-multi-doc-one-shard-index"; private static final String TEST_MULTI_DOC_INDEX_THREE_SHARDS_NAME = "test-neural-multi-doc-three-shards-index"; diff --git a/src/test/java/org/opensearch/neuralsearch/processor/ScoreNormalizationIT.java b/src/test/java/org/opensearch/neuralsearch/processor/ScoreNormalizationIT.java index aa133c44d..60f5518f2 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/ScoreNormalizationIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/ScoreNormalizationIT.java @@ -13,8 +13,6 @@ import java.util.Collections; import java.util.Map; -import lombok.SneakyThrows; - import org.junit.After; import org.junit.Before; import org.opensearch.index.query.QueryBuilders; @@ -25,6 +23,8 @@ import com.google.common.primitives.Floats; +import lombok.SneakyThrows; + public class ScoreNormalizationIT extends BaseNeuralSearchIT { private static final String TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME = "test-neural-multi-doc-one-shard-index"; private static final String TEST_QUERY_TEXT3 = "hello"; diff --git a/src/test/java/org/opensearch/neuralsearch/processor/ScoreNormalizationTechniqueTests.java b/src/test/java/org/opensearch/neuralsearch/processor/ScoreNormalizationTechniqueTests.java index 8e31d619c..123e57e74 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/ScoreNormalizationTechniqueTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/ScoreNormalizationTechniqueTests.java @@ -7,8 +7,6 @@ import java.util.List; -import lombok.SneakyThrows; - import org.apache.commons.lang3.Range; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TopDocs; @@ -17,6 +15,8 @@ import org.opensearch.neuralsearch.processor.normalization.ScoreNormalizer; import org.opensearch.test.OpenSearchTestCase; +import lombok.SneakyThrows; + public class ScoreNormalizationTechniqueTests extends OpenSearchTestCase { public void testEmptyResults_whenEmptyResultsAndDefaultMethod_thenNoProcessing() { diff --git a/src/test/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessIT.java b/src/test/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessIT.java index da2373a3a..87c58e99f 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessIT.java @@ -9,8 +9,6 @@ import java.nio.file.Path; import java.util.Map; -import lombok.SneakyThrows; - import org.apache.http.HttpHeaders; import org.apache.http.message.BasicHeader; import org.apache.http.util.EntityUtils; @@ -22,6 +20,8 @@ import com.google.common.collect.ImmutableList; +import lombok.SneakyThrows; + public class SparseEncodingProcessIT extends BaseSparseEncodingIT { private static final String INDEX_NAME = "sparse_encoding_index"; diff --git a/src/test/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessorTests.java b/src/test/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessorTests.java index 209db58a8..7ddbfcc21 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessorTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessorTests.java @@ -13,8 +13,6 @@ import java.util.function.BiConsumer; import java.util.stream.IntStream; -import lombok.SneakyThrows; - import org.junit.Before; import org.mockito.InjectMocks; import org.mockito.Mock; @@ -31,6 +29,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import lombok.SneakyThrows; + public class SparseEncodingProcessorTests extends OpenSearchTestCase { @Mock private MLCommonsClientAccessor mlCommonsClientAccessor; diff --git a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorIT.java b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorIT.java index b306a7c90..bac6eeff2 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorIT.java @@ -9,8 +9,6 @@ import java.nio.file.Path; import java.util.Map; -import lombok.SneakyThrows; - import org.apache.http.HttpHeaders; import org.apache.http.message.BasicHeader; import org.apache.http.util.EntityUtils; @@ -22,6 +20,8 @@ import com.google.common.collect.ImmutableList; +import lombok.SneakyThrows; + public class TextEmbeddingProcessorIT extends BaseNeuralSearchIT { private static final String INDEX_NAME = "text_embedding_index"; diff --git a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java index 539ed8fca..5093ee72e 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java @@ -24,8 +24,6 @@ import java.util.function.BiConsumer; import java.util.function.Supplier; -import lombok.SneakyThrows; - import org.junit.Before; import org.mockito.InjectMocks; import org.mockito.Mock; @@ -43,6 +41,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import lombok.SneakyThrows; + public class TextEmbeddingProcessorTests extends OpenSearchTestCase { @Mock diff --git a/src/test/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessorIT.java b/src/test/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessorIT.java index 59d964b9c..7fbc5465a 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessorIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessorIT.java @@ -9,8 +9,6 @@ import java.nio.file.Path; import java.util.Map; -import lombok.SneakyThrows; - import org.apache.http.HttpHeaders; import org.apache.http.message.BasicHeader; import org.apache.http.util.EntityUtils; @@ -22,6 +20,8 @@ import com.google.common.collect.ImmutableList; +import lombok.SneakyThrows; + /** * Testing text_and_image_embedding ingest processor. We can only test text in integ tests, none of pre-built models * supports both text and image. diff --git a/src/test/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessorTests.java b/src/test/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessorTests.java index bae336d4a..604e4d075 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessorTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessorTests.java @@ -25,8 +25,6 @@ import java.util.function.BiConsumer; import java.util.function.Supplier; -import lombok.SneakyThrows; - import org.junit.Before; import org.mockito.InjectMocks; import org.mockito.Mock; @@ -49,6 +47,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import lombok.SneakyThrows; + public class TextImageEmbeddingProcessorTests extends OpenSearchTestCase { @Mock diff --git a/src/test/java/org/opensearch/neuralsearch/processor/combination/BaseScoreCombinationTechniqueTests.java b/src/test/java/org/opensearch/neuralsearch/processor/combination/BaseScoreCombinationTechniqueTests.java index e8ad3532d..6697ccd3e 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/combination/BaseScoreCombinationTechniqueTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/combination/BaseScoreCombinationTechniqueTests.java @@ -9,13 +9,13 @@ import java.util.List; import java.util.function.BiFunction; -import lombok.NoArgsConstructor; - import org.apache.commons.lang.ArrayUtils; import org.opensearch.test.OpenSearchTestCase; import com.carrotsearch.randomizedtesting.RandomizedTest; +import lombok.NoArgsConstructor; + @NoArgsConstructor public class BaseScoreCombinationTechniqueTests extends OpenSearchTestCase { diff --git a/src/test/java/org/opensearch/neuralsearch/processor/factory/NormalizationProcessorFactoryTests.java b/src/test/java/org/opensearch/neuralsearch/processor/factory/NormalizationProcessorFactoryTests.java index a1ddefe16..efd1cce4f 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/factory/NormalizationProcessorFactoryTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/factory/NormalizationProcessorFactoryTests.java @@ -16,8 +16,6 @@ import java.util.HashMap; import java.util.Map; -import lombok.SneakyThrows; - import org.opensearch.neuralsearch.processor.NormalizationProcessor; import org.opensearch.neuralsearch.processor.NormalizationProcessorWorkflow; import org.opensearch.neuralsearch.processor.combination.ArithmeticMeanScoreCombinationTechnique; @@ -31,6 +29,8 @@ import com.carrotsearch.randomizedtesting.RandomizedTest; +import lombok.SneakyThrows; + public class NormalizationProcessorFactoryTests extends OpenSearchTestCase { private static final String NORMALIZATION_METHOD = "min_max"; diff --git a/src/test/java/org/opensearch/neuralsearch/processor/factory/TextImageEmbeddingProcessorFactoryTests.java b/src/test/java/org/opensearch/neuralsearch/processor/factory/TextImageEmbeddingProcessorFactoryTests.java index cbf53b8fc..564373315 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/factory/TextImageEmbeddingProcessorFactoryTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/factory/TextImageEmbeddingProcessorFactoryTests.java @@ -17,14 +17,14 @@ import java.util.HashMap; import java.util.Map; -import lombok.SneakyThrows; - import org.opensearch.cluster.service.ClusterService; import org.opensearch.env.Environment; import org.opensearch.neuralsearch.ml.MLCommonsClientAccessor; import org.opensearch.neuralsearch.processor.TextImageEmbeddingProcessor; import org.opensearch.test.OpenSearchTestCase; +import lombok.SneakyThrows; + public class TextImageEmbeddingProcessorFactoryTests extends OpenSearchTestCase { @SneakyThrows diff --git a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryBuilderTests.java b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryBuilderTests.java index 0544feff8..5e53dd69d 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryBuilderTests.java +++ b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryBuilderTests.java @@ -23,8 +23,6 @@ import java.util.Map; import java.util.function.Supplier; -import lombok.SneakyThrows; - import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; @@ -58,6 +56,8 @@ import com.carrotsearch.randomizedtesting.RandomizedTest; +import lombok.SneakyThrows; + public class HybridQueryBuilderTests extends OpenSearchQueryTestCase { static final String VECTOR_FIELD_NAME = "vectorField"; static final String TEXT_FIELD_NAME = "field"; diff --git a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryIT.java b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryIT.java index 4a8f0d065..312cb8b3a 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryIT.java +++ b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryIT.java @@ -20,8 +20,6 @@ import java.util.Set; import java.util.stream.IntStream; -import lombok.SneakyThrows; - import org.apache.lucene.search.join.ScoreMode; import org.junit.After; import org.junit.Before; @@ -36,6 +34,8 @@ import com.google.common.primitives.Floats; +import lombok.SneakyThrows; + public class HybridQueryIT extends BaseNeuralSearchIT { private static final String TEST_BASIC_INDEX_NAME = "test-neural-basic-index"; private static final String TEST_BASIC_VECTOR_DOC_FIELD_INDEX_NAME = "test-neural-vector-doc-field-index"; diff --git a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryScorerTests.java b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryScorerTests.java index 77ca3e64e..3777c2d14 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryScorerTests.java +++ b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryScorerTests.java @@ -16,8 +16,6 @@ import java.util.Set; import java.util.stream.Collectors; -import lombok.SneakyThrows; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import org.apache.lucene.search.DocIdSetIterator; @@ -29,6 +27,8 @@ import com.carrotsearch.randomizedtesting.RandomizedTest; +import lombok.SneakyThrows; + public class HybridQueryScorerTests extends OpenSearchQueryTestCase { @SneakyThrows diff --git a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryTests.java b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryTests.java index 4d24c2049..a1d632755 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryTests.java +++ b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryTests.java @@ -18,8 +18,6 @@ import java.util.List; import java.util.stream.Collectors; -import lombok.SneakyThrows; - import org.apache.lucene.document.FieldType; import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; @@ -44,6 +42,8 @@ import com.carrotsearch.randomizedtesting.RandomizedTest; +import lombok.SneakyThrows; + public class HybridQueryTests extends OpenSearchQueryTestCase { static final String VECTOR_FIELD_NAME = "vectorField"; diff --git a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryWeightTests.java b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryWeightTests.java index 8656d7f04..50198af46 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryWeightTests.java +++ b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryWeightTests.java @@ -12,8 +12,6 @@ import java.util.List; -import lombok.SneakyThrows; - import org.apache.lucene.document.FieldType; import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; @@ -36,6 +34,8 @@ import com.carrotsearch.randomizedtesting.RandomizedTest; +import lombok.SneakyThrows; + public class HybridQueryWeightTests extends OpenSearchQueryTestCase { static final String TERM_QUERY_TEXT = "keyword"; diff --git a/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryBuilderTests.java b/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryBuilderTests.java index 94665d879..068be51ef 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryBuilderTests.java +++ b/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryBuilderTests.java @@ -29,8 +29,6 @@ import java.util.function.BiConsumer; import java.util.function.Supplier; -import lombok.SneakyThrows; - import org.opensearch.Version; import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; @@ -59,6 +57,8 @@ import org.opensearch.neuralsearch.util.NeuralSearchClusterUtil; import org.opensearch.test.OpenSearchTestCase; +import lombok.SneakyThrows; + public class NeuralQueryBuilderTests extends OpenSearchTestCase { private static final String FIELD_NAME = "testField"; diff --git a/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java b/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java index 6a8e48465..5e9f5834a 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java +++ b/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java @@ -5,16 +5,14 @@ package org.opensearch.neuralsearch.query; +import static org.opensearch.neuralsearch.TestUtils.DELTA_FOR_SCORE_ASSERTION; import static org.opensearch.neuralsearch.TestUtils.createRandomVector; import static org.opensearch.neuralsearch.TestUtils.objectToFloat; -import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Map; -import lombok.SneakyThrows; - import org.junit.After; import org.junit.Before; import org.opensearch.index.query.BoolQueryBuilder; @@ -25,6 +23,8 @@ import com.google.common.primitives.Floats; +import lombok.SneakyThrows; + public class NeuralQueryIT extends BaseNeuralSearchIT { private static final String TEST_BASIC_INDEX_NAME = "test-neural-basic-index"; private static final String TEST_MULTI_VECTOR_FIELD_INDEX_NAME = "test-neural-multi-vector-field-index"; @@ -92,7 +92,7 @@ public void testBasicQuery() { assertEquals("1", firstInnerHit.get("_id")); float expectedScore = computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT); - assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0); + assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION); } /** @@ -131,7 +131,7 @@ public void testBoostQuery() { assertEquals("1", firstInnerHit.get("_id")); float expectedScore = 2 * computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT); - assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0); + assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION); } /** @@ -174,7 +174,7 @@ public void testRescoreQuery() { assertEquals("1", firstInnerHit.get("_id")); float expectedScore = computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT); - assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0); + assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION); } /** @@ -234,7 +234,7 @@ public void testBooleanQuery_withMultipleNeuralQueries() { assertEquals("1", firstInnerHit.get("_id")); float expectedScore = 2 * computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT); - assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0); + assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION); } /** @@ -326,7 +326,7 @@ public void testNestedQuery() { assertEquals("1", firstInnerHit.get("_id")); float expectedScore = computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT); - assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0); + assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION); } /** @@ -368,7 +368,7 @@ public void testFilterQuery() { Map firstInnerHit = getFirstInnerHit(searchResponseAsMap); assertEquals("3", firstInnerHit.get("_id")); float expectedScore = computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT); - assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0); + assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION); } /** @@ -404,10 +404,11 @@ public void testMultimodalQuery() { assertEquals("1", firstInnerHit.get("_id")); float expectedScore = computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT); - assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0); + assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION); } - private void initializeIndexIfNotExist(String indexName) throws IOException { + @SneakyThrows + private void initializeIndexIfNotExist(String indexName) { if (TEST_BASIC_INDEX_NAME.equals(indexName) && !indexExists(TEST_BASIC_INDEX_NAME)) { prepareKnnIndex( TEST_BASIC_INDEX_NAME, diff --git a/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilderTests.java b/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilderTests.java index 9d1a1627b..92d04faa0 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilderTests.java +++ b/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilderTests.java @@ -24,8 +24,6 @@ import java.util.function.BiConsumer; import java.util.function.Supplier; -import lombok.SneakyThrows; - import org.apache.lucene.document.FeatureField; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; @@ -49,6 +47,8 @@ import org.opensearch.neuralsearch.ml.MLCommonsClientAccessor; import org.opensearch.test.OpenSearchTestCase; +import lombok.SneakyThrows; + public class NeuralSparseQueryBuilderTests extends OpenSearchTestCase { private static final String FIELD_NAME = "testField"; diff --git a/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryIT.java b/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryIT.java index 12bd1c1cb..a521dd4cd 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryIT.java +++ b/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryIT.java @@ -10,8 +10,6 @@ import java.util.List; import java.util.Map; -import lombok.SneakyThrows; - import org.junit.After; import org.junit.Before; import org.opensearch.client.ResponseException; @@ -21,6 +19,8 @@ import org.opensearch.neuralsearch.TestUtils; import org.opensearch.neuralsearch.common.BaseSparseEncodingIT; +import lombok.SneakyThrows; + public class NeuralSparseQueryIT extends BaseSparseEncodingIT { private static final String TEST_BASIC_INDEX_NAME = "test-sparse-basic-index"; private static final String TEST_MULTI_NEURAL_SPARSE_FIELD_INDEX_NAME = "test-sparse-multi-field-index"; diff --git a/src/test/java/org/opensearch/neuralsearch/query/OpenSearchQueryTestCase.java b/src/test/java/org/opensearch/neuralsearch/query/OpenSearchQueryTestCase.java index 26c183832..5b73e12ec 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/OpenSearchQueryTestCase.java +++ b/src/test/java/org/opensearch/neuralsearch/query/OpenSearchQueryTestCase.java @@ -73,7 +73,9 @@ protected final MapperService createMapperService(Version version, XContentBuild xContentRegistry(), similarityService, mapperRegistry, - () -> { throw new UnsupportedOperationException(); }, + () -> { + throw new UnsupportedOperationException(); + }, () -> true, scriptService ); diff --git a/src/test/java/org/opensearch/neuralsearch/search/HybridTopScoreDocCollectorTests.java b/src/test/java/org/opensearch/neuralsearch/search/HybridTopScoreDocCollectorTests.java index 747b05992..06bbfc416 100644 --- a/src/test/java/org/opensearch/neuralsearch/search/HybridTopScoreDocCollectorTests.java +++ b/src/test/java/org/opensearch/neuralsearch/search/HybridTopScoreDocCollectorTests.java @@ -17,8 +17,6 @@ import java.util.stream.IntStream; import java.util.stream.Stream; -import lombok.SneakyThrows; - import org.apache.commons.lang3.RandomUtils; import org.apache.lucene.document.FieldType; import org.apache.lucene.document.TextField; @@ -42,6 +40,8 @@ import org.opensearch.neuralsearch.query.HybridQueryScorer; import org.opensearch.neuralsearch.query.OpenSearchQueryTestCase; +import lombok.SneakyThrows; + public class HybridTopScoreDocCollectorTests extends OpenSearchQueryTestCase { static final String TEXT_FIELD_NAME = "field"; diff --git a/src/test/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcherTests.java b/src/test/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcherTests.java index c4f3f4a3e..55a16c4bb 100644 --- a/src/test/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcherTests.java +++ b/src/test/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcherTests.java @@ -26,8 +26,6 @@ import java.util.Set; import java.util.UUID; -import lombok.SneakyThrows; - import org.apache.lucene.document.FieldType; import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; @@ -71,6 +69,8 @@ import com.carrotsearch.randomizedtesting.RandomizedTest; +import lombok.SneakyThrows; + public class HybridQueryPhaseSearcherTests extends OpenSearchQueryTestCase { private static final String VECTOR_FIELD_NAME = "vectorField"; private static final String TEXT_FIELD_NAME = "field";