From 11b5be14723a9e442f32548e4089526736abec50 Mon Sep 17 00:00:00 2001 From: HenryL27 Date: Mon, 18 Dec 2023 12:11:02 -0800 Subject: [PATCH] rename TextSimilarity files to MLOpenSearch files Signed-off-by: HenryL27 --- .../factory/RerankProcessorFactory.java | 6 ++--- ....java => MLOpenSearchRerankProcessor.java} | 4 ++-- .../factory/RerankProcessorFactoryTests.java | 22 +++++++++---------- ...ava => MLOpenSearchRerankProcessorIT.java} | 6 ++--- ... => MLOpenSearchRerankProcessorTests.java} | 8 +++---- ...ankMLOpenSearchPipelineConfiguration.json} | 0 6 files changed, 23 insertions(+), 23 deletions(-) rename src/main/java/org/opensearch/neuralsearch/processor/rerank/{TextSimilarityRerankProcessor.java => MLOpenSearchRerankProcessor.java} (96%) rename src/test/java/org/opensearch/neuralsearch/processor/rerank/{TextSimilarityRerankProcessorIT.java => MLOpenSearchRerankProcessorIT.java} (96%) rename src/test/java/org/opensearch/neuralsearch/processor/rerank/{TextSimilarityRerankProcessorTests.java => MLOpenSearchRerankProcessorTests.java} (98%) rename src/test/resources/processor/{TextSimilarityRerankPipelineConfiguration.json => RerankMLOpenSearchPipelineConfiguration.json} (100%) diff --git a/src/main/java/org/opensearch/neuralsearch/processor/factory/RerankProcessorFactory.java b/src/main/java/org/opensearch/neuralsearch/processor/factory/RerankProcessorFactory.java index d1c7042b6..eb41789be 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/factory/RerankProcessorFactory.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/factory/RerankProcessorFactory.java @@ -30,9 +30,9 @@ import org.opensearch.neuralsearch.ml.MLCommonsClientAccessor; import org.opensearch.neuralsearch.processor.rerank.ContextSourceFetcher; import org.opensearch.neuralsearch.processor.rerank.DocumentContextSourceFetcher; +import org.opensearch.neuralsearch.processor.rerank.MLOpenSearchRerankProcessor; import org.opensearch.neuralsearch.processor.rerank.QueryContextSourceFetcher; import org.opensearch.neuralsearch.processor.rerank.RerankType; -import org.opensearch.neuralsearch.processor.rerank.TextSimilarityRerankProcessor; import org.opensearch.search.pipeline.Processor; import org.opensearch.search.pipeline.SearchResponseProcessor; @@ -70,9 +70,9 @@ public SearchResponseProcessor create( RERANK_PROCESSOR_TYPE, tag, rerankerConfig, - TextSimilarityRerankProcessor.MODEL_ID_FIELD + MLOpenSearchRerankProcessor.MODEL_ID_FIELD ); - return new TextSimilarityRerankProcessor(description, tag, ignoreFailure, modelId, contextFetchers, clientAccessor); + return new MLOpenSearchRerankProcessor(description, tag, ignoreFailure, modelId, contextFetchers, clientAccessor); default: throw new IllegalArgumentException(String.format(Locale.ROOT, "Cannot build reranker type %s", type.getLabel())); } diff --git a/src/main/java/org/opensearch/neuralsearch/processor/rerank/TextSimilarityRerankProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/rerank/MLOpenSearchRerankProcessor.java similarity index 96% rename from src/main/java/org/opensearch/neuralsearch/processor/rerank/TextSimilarityRerankProcessor.java rename to src/main/java/org/opensearch/neuralsearch/processor/rerank/MLOpenSearchRerankProcessor.java index 2c8f5f186..70ba9a050 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/rerank/TextSimilarityRerankProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/rerank/MLOpenSearchRerankProcessor.java @@ -30,7 +30,7 @@ /** * Rescoring Rerank Processor that uses a TextSimilarity model in ml-commons to rescore */ -public class TextSimilarityRerankProcessor extends RescoringRerankProcessor { +public class MLOpenSearchRerankProcessor extends RescoringRerankProcessor { public static final String MODEL_ID_FIELD = "model_id"; @@ -47,7 +47,7 @@ public class TextSimilarityRerankProcessor extends RescoringRerankProcessor { * @param contextSourceFetchers * @param mlCommonsClientAccessor */ - public TextSimilarityRerankProcessor( + public MLOpenSearchRerankProcessor( String description, String tag, boolean ignoreFailure, diff --git a/src/test/java/org/opensearch/neuralsearch/processor/factory/RerankProcessorFactoryTests.java b/src/test/java/org/opensearch/neuralsearch/processor/factory/RerankProcessorFactoryTests.java index d768b6f35..d8d372cbc 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/factory/RerankProcessorFactoryTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/factory/RerankProcessorFactoryTests.java @@ -30,9 +30,9 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.neuralsearch.ml.MLCommonsClientAccessor; import org.opensearch.neuralsearch.processor.rerank.DocumentContextSourceFetcher; +import org.opensearch.neuralsearch.processor.rerank.MLOpenSearchRerankProcessor; import org.opensearch.neuralsearch.processor.rerank.RerankProcessor; import org.opensearch.neuralsearch.processor.rerank.RerankType; -import org.opensearch.neuralsearch.processor.rerank.TextSimilarityRerankProcessor; import org.opensearch.search.pipeline.Processor.PipelineContext; import org.opensearch.search.pipeline.SearchResponseProcessor; import org.opensearch.test.OpenSearchTestCase; @@ -68,7 +68,7 @@ public void testRerankProcessorFactory_EmptyConfig_ThenFail() { public void testRerankProcessorFactory_NonExistentType_ThenFail() { Map config = new HashMap<>( - Map.of("jpeo rvgh we iorgn", Map.of(TextSimilarityRerankProcessor.MODEL_ID_FIELD, "model-id")) + Map.of("jpeo rvgh we iorgn", Map.of(MLOpenSearchRerankProcessor.MODEL_ID_FIELD, "model-id")) ); assertThrows( "no rerank type found", @@ -81,14 +81,14 @@ public void testRerankProcessorFactory_CrossEncoder_HappyPath() { Map config = new HashMap<>( Map.of( RerankType.ML_OPENSEARCH.getLabel(), - new HashMap<>(Map.of(TextSimilarityRerankProcessor.MODEL_ID_FIELD, "model-id")), + new HashMap<>(Map.of(MLOpenSearchRerankProcessor.MODEL_ID_FIELD, "model-id")), RerankProcessorFactory.CONTEXT_CONFIG_FIELD, new HashMap<>(Map.of(DocumentContextSourceFetcher.NAME, new ArrayList<>(List.of("text_representation")))) ) ); SearchResponseProcessor processor = factory.create(Map.of(), TAG, DESC, false, config, pipelineContext); assert (processor instanceof RerankProcessor); - assert (processor instanceof TextSimilarityRerankProcessor); + assert (processor instanceof MLOpenSearchRerankProcessor); assert (processor.getType().equals(RerankProcessor.TYPE)); } @@ -98,14 +98,14 @@ public void testRerankProcessorFactory_CrossEncoder_MessyConfig_ThenHappy() { "poafn aorr;anv", Map.of(";oawhls", "aowirhg "), RerankType.ML_OPENSEARCH.getLabel(), - new HashMap<>(Map.of(TextSimilarityRerankProcessor.MODEL_ID_FIELD, "model-id", "pqiohg rpowierhg", "pw;oith4pt3ih go")), + new HashMap<>(Map.of(MLOpenSearchRerankProcessor.MODEL_ID_FIELD, "model-id", "pqiohg rpowierhg", "pw;oith4pt3ih go")), RerankProcessorFactory.CONTEXT_CONFIG_FIELD, new HashMap<>(Map.of(DocumentContextSourceFetcher.NAME, new ArrayList<>(List.of("text_representation")))) ) ); SearchResponseProcessor processor = factory.create(Map.of(), TAG, DESC, false, config, pipelineContext); assert (processor instanceof RerankProcessor); - assert (processor instanceof TextSimilarityRerankProcessor); + assert (processor instanceof MLOpenSearchRerankProcessor); assert (processor.getType().equals(RerankProcessor.TYPE)); } @@ -113,7 +113,7 @@ public void testRerankProcessorFactory_CrossEncoder_MessyContext_ThenFail() { Map config = new HashMap<>( Map.of( RerankType.ML_OPENSEARCH.getLabel(), - new HashMap<>(Map.of(TextSimilarityRerankProcessor.MODEL_ID_FIELD, "model-id")), + new HashMap<>(Map.of(MLOpenSearchRerankProcessor.MODEL_ID_FIELD, "model-id")), RerankProcessorFactory.CONTEXT_CONFIG_FIELD, new HashMap<>( Map.of( @@ -143,7 +143,7 @@ public void testRerankProcessorFactory_CrossEncoder_EmptySubConfig_ThenFail() { public void testRerankProcessorFactory_CrossEncoder_NoContextField_ThenFail() { Map config = new HashMap<>( - Map.of(RerankType.ML_OPENSEARCH.getLabel(), new HashMap<>(Map.of(TextSimilarityRerankProcessor.MODEL_ID_FIELD, "model-id"))) + Map.of(RerankType.ML_OPENSEARCH.getLabel(), new HashMap<>(Map.of(MLOpenSearchRerankProcessor.MODEL_ID_FIELD, "model-id"))) ); assertThrows( String.format(Locale.ROOT, "[%s] required property is missing", RerankProcessorFactory.CONTEXT_CONFIG_FIELD), @@ -162,7 +162,7 @@ public void testRerankProcessorFactory_CrossEncoder_NoModelId_ThenFail() { ) ); assertThrows( - String.format(Locale.ROOT, "[%s] required property is missing", TextSimilarityRerankProcessor.MODEL_ID_FIELD), + String.format(Locale.ROOT, "[%s] required property is missing", MLOpenSearchRerankProcessor.MODEL_ID_FIELD), OpenSearchParseException.class, () -> factory.create(Map.of(), TAG, DESC, false, config, pipelineContext) ); @@ -172,7 +172,7 @@ public void testRerankProcessorFactory_CrossEncoder_BadContextDocField_ThenFail( Map config = new HashMap<>( Map.of( RerankType.ML_OPENSEARCH.getLabel(), - new HashMap<>(Map.of(TextSimilarityRerankProcessor.MODEL_ID_FIELD, "model-id")), + new HashMap<>(Map.of(MLOpenSearchRerankProcessor.MODEL_ID_FIELD, "model-id")), RerankProcessorFactory.CONTEXT_CONFIG_FIELD, new HashMap<>(Map.of(DocumentContextSourceFetcher.NAME, "text_representation")) ) @@ -188,7 +188,7 @@ public void testRerankProcessorFactory_CrossEncoder_EmptyContextDocField_ThenFai Map config = new HashMap<>( Map.of( RerankType.ML_OPENSEARCH.getLabel(), - new HashMap<>(Map.of(TextSimilarityRerankProcessor.MODEL_ID_FIELD, "model-id")), + new HashMap<>(Map.of(MLOpenSearchRerankProcessor.MODEL_ID_FIELD, "model-id")), RerankProcessorFactory.CONTEXT_CONFIG_FIELD, new HashMap<>(Map.of(DocumentContextSourceFetcher.NAME, new ArrayList<>())) ) diff --git a/src/test/java/org/opensearch/neuralsearch/processor/rerank/TextSimilarityRerankProcessorIT.java b/src/test/java/org/opensearch/neuralsearch/processor/rerank/MLOpenSearchRerankProcessorIT.java similarity index 96% rename from src/test/java/org/opensearch/neuralsearch/processor/rerank/TextSimilarityRerankProcessorIT.java rename to src/test/java/org/opensearch/neuralsearch/processor/rerank/MLOpenSearchRerankProcessorIT.java index ea16c614e..3c2a37057 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/rerank/TextSimilarityRerankProcessorIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/rerank/MLOpenSearchRerankProcessorIT.java @@ -39,9 +39,9 @@ import com.google.common.collect.ImmutableList; @Log4j2 -public class TextSimilarityRerankProcessorIT extends BaseNeuralSearchIT { +public class MLOpenSearchRerankProcessorIT extends BaseNeuralSearchIT { - final static String PIPELINE_NAME = "rerank-ts-pipeline"; + final static String PIPELINE_NAME = "rerank-mlos-pipeline"; final static String INDEX_NAME = "rerank-test"; final static String TEXT_REP_1 = "Jacques loves fish. Fish make Jacques happy"; final static String TEXT_REP_2 = "Fish like to eat plankton"; @@ -63,7 +63,7 @@ public void tearDown() { public void testCrossEncoderRerankProcessor() throws Exception { String modelId = uploadTextSimilarityModel(); loadModel(modelId); - createSearchPipelineViaConfig(modelId, PIPELINE_NAME, "processor/TextSimilarityRerankPipelineConfiguration.json"); + createSearchPipelineViaConfig(modelId, PIPELINE_NAME, "processor/RerankMLOpenSearchPipelineConfiguration.json"); setupIndex(); runQueries(); } diff --git a/src/test/java/org/opensearch/neuralsearch/processor/rerank/TextSimilarityRerankProcessorTests.java b/src/test/java/org/opensearch/neuralsearch/processor/rerank/MLOpenSearchRerankProcessorTests.java similarity index 98% rename from src/test/java/org/opensearch/neuralsearch/processor/rerank/TextSimilarityRerankProcessorTests.java rename to src/test/java/org/opensearch/neuralsearch/processor/rerank/MLOpenSearchRerankProcessorTests.java index b06abfc84..bb589a600 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/rerank/TextSimilarityRerankProcessorTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/rerank/MLOpenSearchRerankProcessorTests.java @@ -62,7 +62,7 @@ import org.opensearch.test.OpenSearchTestCase; @Log4j2 -public class TextSimilarityRerankProcessorTests extends OpenSearchTestCase { +public class MLOpenSearchRerankProcessorTests extends OpenSearchTestCase { @Mock SearchRequest request; @@ -80,7 +80,7 @@ public class TextSimilarityRerankProcessorTests extends OpenSearchTestCase { RerankProcessorFactory factory; - TextSimilarityRerankProcessor processor; + MLOpenSearchRerankProcessor processor; @Before public void setup() { @@ -89,12 +89,12 @@ public void setup() { Map config = new HashMap<>( Map.of( RerankType.ML_OPENSEARCH.getLabel(), - new HashMap<>(Map.of(TextSimilarityRerankProcessor.MODEL_ID_FIELD, "model-id")), + new HashMap<>(Map.of(MLOpenSearchRerankProcessor.MODEL_ID_FIELD, "model-id")), RerankProcessorFactory.CONTEXT_CONFIG_FIELD, new HashMap<>(Map.of(DocumentContextSourceFetcher.NAME, new ArrayList<>(List.of("text_representation")))) ) ); - processor = (TextSimilarityRerankProcessor) factory.create( + processor = (MLOpenSearchRerankProcessor) factory.create( Map.of(), "rerank processor", "processor for reranking with a cross encoder", diff --git a/src/test/resources/processor/TextSimilarityRerankPipelineConfiguration.json b/src/test/resources/processor/RerankMLOpenSearchPipelineConfiguration.json similarity index 100% rename from src/test/resources/processor/TextSimilarityRerankPipelineConfiguration.json rename to src/test/resources/processor/RerankMLOpenSearchPipelineConfiguration.json