From 04d26cc8d0e0bb661b5560979fe0ddab7a65f01a Mon Sep 17 00:00:00 2001 From: Martin Gaievski Date: Wed, 29 Nov 2023 16:59:17 -0800 Subject: [PATCH] Upgrade spotless, run spotlessApply for whole project Signed-off-by: Martin Gaievski --- build.gradle | 2 +- .../neuralsearch/ml/MLCommonsClientAccessor.java | 8 ++++---- .../neuralsearch/plugin/NeuralSearch.java | 4 ++-- .../neuralsearch/processor/CompoundTopDocs.java | 8 ++++---- .../processor/InferenceProcessor.java | 4 ++-- .../processor/NeuralQueryEnricherProcessor.java | 6 +++--- .../processor/NormalizationProcessor.java | 6 +++--- .../NormalizationProcessorWorkflow.java | 6 +++--- .../processor/SparseEncodingProcessor.java | 4 ++-- .../processor/TextEmbeddingProcessor.java | 4 ++-- .../processor/TextImageEmbeddingProcessor.java | 4 ++-- .../combination/ScoreCombinationUtil.java | 4 ++-- .../processor/combination/ScoreCombiner.java | 4 ++-- .../factory/NormalizationProcessorFactory.java | 6 +++--- .../factory/SparseEncodingProcessorFactory.java | 4 ++-- .../TextImageEmbeddingProcessorFactory.java | 4 ++-- .../L2ScoreNormalizationTechnique.java | 4 ++-- .../MinMaxScoreNormalizationTechnique.java | 4 ++-- .../neuralsearch/query/HybridQueryBuilder.java | 12 ++++++------ .../neuralsearch/query/HybridQueryScorer.java | 4 ++-- .../neuralsearch/query/NeuralQueryBuilder.java | 16 ++++++++-------- .../query/NeuralSparseQueryBuilder.java | 14 +++++++------- .../query/visitor/NeuralSearchQueryVisitor.java | 4 ++-- .../search/HitsThresholdChecker.java | 4 ++-- .../search/HybridTopScoreDocCollector.java | 6 +++--- .../search/query/HybridQueryPhaseSearcher.java | 4 ++-- .../settings/NeuralSearchSettings.java | 4 ++-- .../util/NeuralSearchClusterUtil.java | 6 +++--- .../neuralsearch/common/BaseNeuralSearchIT.java | 8 ++++---- .../common/BaseSparseEncodingIT.java | 4 ++-- .../NeuralQueryEnricherProcessorIT.java | 4 ++-- .../processor/NormalizationProcessorIT.java | 4 ++-- .../processor/ScoreCombinationIT.java | 4 ++-- .../processor/ScoreNormalizationIT.java | 4 ++-- .../ScoreNormalizationTechniqueTests.java | 4 ++-- .../processor/SparseEncodingProcessIT.java | 4 ++-- .../processor/SparseEncodingProcessorTests.java | 4 ++-- .../processor/TextEmbeddingProcessorIT.java | 4 ++-- .../processor/TextEmbeddingProcessorTests.java | 4 ++-- .../processor/TextImageEmbeddingProcessorIT.java | 4 ++-- .../TextImageEmbeddingProcessorTests.java | 4 ++-- .../BaseScoreCombinationTechniqueTests.java | 4 ++-- .../NormalizationProcessorFactoryTests.java | 4 ++-- .../TextImageEmbeddingProcessorFactoryTests.java | 4 ++-- .../query/HybridQueryBuilderTests.java | 4 ++-- .../neuralsearch/query/HybridQueryIT.java | 4 ++-- .../query/HybridQueryScorerTests.java | 4 ++-- .../neuralsearch/query/HybridQueryTests.java | 4 ++-- .../query/HybridQueryWeightTests.java | 4 ++-- .../query/NeuralQueryBuilderTests.java | 4 ++-- .../neuralsearch/query/NeuralQueryIT.java | 16 ++++++++-------- .../query/NeuralSparseQueryBuilderTests.java | 4 ++-- .../neuralsearch/query/NeuralSparseQueryIT.java | 4 ++-- .../query/OpenSearchQueryTestCase.java | 4 +++- .../search/HybridTopScoreDocCollectorTests.java | 4 ++-- .../query/HybridQueryPhaseSearcherTests.java | 4 ++-- 56 files changed, 145 insertions(+), 143 deletions(-) diff --git a/build.gradle b/build.gradle index 581a99a9e..651483786 100644 --- a/build.gradle +++ b/build.gradle @@ -109,7 +109,7 @@ buildscript { dependencies { classpath "${opensearch_group}.gradle:build-tools:${opensearch_version}" - classpath "com.diffplug.spotless:spotless-plugin-gradle:5.6.1" + classpath "com.diffplug.spotless:spotless-plugin-gradle:6.22.0" classpath "io.freefair.gradle:lombok-plugin:8.4" } } diff --git a/src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java b/src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java index 1c09f5996..b9a95dea8 100644 --- a/src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java +++ b/src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java @@ -14,10 +14,6 @@ import java.util.Map; import java.util.stream.Collectors; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.extern.log4j.Log4j2; - import org.opensearch.core.action.ActionListener; import org.opensearch.core.common.util.CollectionUtils; import org.opensearch.ml.client.MachineLearningNodeClient; @@ -32,6 +28,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 86859a054..039d6a319 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilder.java +++ b/src/main/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilder.java @@ -12,13 +12,6 @@ import java.util.Objects; 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; @@ -44,6 +37,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 SPARSE_ENCODING 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 f65e30222..2205b14e2 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.Query; import org.apache.lucene.search.ScoreDoc; @@ -41,6 +39,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 33cdff9a0..7cbd7493d 100644 --- a/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java +++ b/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java @@ -21,10 +21,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.hc.core5.http.ContentType; import org.apache.hc.core5.http.Header; @@ -59,6 +55,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 d0231cfe6..46fb807ce 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.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.message.BasicHeader; @@ -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 893b47ede..78207c6e4 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.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.message.BasicHeader; @@ -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 de7a70add..7aad49b03 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.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.message.BasicHeader; @@ -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 399cd1eb8..f1936d812 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java @@ -17,8 +17,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; @@ -36,6 +34,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 055344352..77b0abbc6 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.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.message.BasicHeader; @@ -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 171d2f4a4..06ea7a13e 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryIT.java +++ b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryIT.java @@ -17,8 +17,6 @@ import java.util.Set; import java.util.stream.IntStream; -import lombok.SneakyThrows; - import org.junit.After; import org.junit.Before; import org.opensearch.index.query.BoolQueryBuilder; @@ -30,6 +28,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 d7d5407b6..5e9f5834a 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java +++ b/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java @@ -13,8 +13,6 @@ 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"; @@ -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,7 +404,7 @@ 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); } @SneakyThrows diff --git a/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilderTests.java b/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilderTests.java index f3fa3264d..e95794b1c 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilderTests.java +++ b/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilderTests.java @@ -23,8 +23,6 @@ import java.util.function.BiConsumer; import java.util.function.Supplier; -import lombok.SneakyThrows; - import org.opensearch.client.Client; import org.opensearch.common.SetOnce; import org.opensearch.common.io.stream.BytesStreamOutput; @@ -43,6 +41,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 0a2463ecd..3f95d5638 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 e9c55cc54..98166c2fb 100644 --- a/src/test/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcherTests.java +++ b/src/test/java/org/opensearch/neuralsearch/search/query/HybridQueryPhaseSearcherTests.java @@ -22,8 +22,6 @@ import java.util.LinkedList; 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; @@ -59,6 +57,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";