diff --git a/src/main/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessor.java index 8ae0f9a90..8acf95bf7 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessor.java @@ -45,7 +45,7 @@ public void doExecute( BiConsumer handler ) { mlCommonsClientAccessor.inferenceSentencesWithMapResult(this.modelId, inferenceList, ActionListener.wrap(resultMaps -> { - setTargetFieldsToDocument(ingestDocument, ProcessMap, TokenWeightUtil.fetchListOfTokenWeightMap(resultMaps)); + setVectorFieldsToDocument(ingestDocument, ProcessMap, TokenWeightUtil.fetchListOfTokenWeightMap(resultMaps)); handler.accept(ingestDocument, null); }, e -> { handler.accept(null, e); })); } diff --git a/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java index 04af25fc5..c1b8f92a6 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java @@ -44,7 +44,7 @@ public void doExecute( BiConsumer handler ) { mlCommonsClientAccessor.inferenceSentences(this.modelId, inferenceList, ActionListener.wrap(vectors -> { - setTargetFieldsToDocument(ingestDocument, ProcessMap, vectors); + setVectorFieldsToDocument(ingestDocument, ProcessMap, vectors); handler.accept(ingestDocument, null); }, e -> { handler.accept(null, e); })); } diff --git a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java index 25d41c345..60408d820 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java @@ -357,7 +357,7 @@ public void testProcessResponse_successful() throws Exception { Map knnMap = processor.buildMapWithProcessorKeyAndOriginalValue(ingestDocument); List> modelTensorList = createMockVectorResult(); - processor.setTargetFieldsToDocument(ingestDocument, knnMap, modelTensorList); + processor.setVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList); assertEquals(12, ingestDocument.getSourceAndMetadata().size()); } @@ -378,7 +378,7 @@ public void testBuildVectorOutput_withPlainStringValue_successful() { assertEquals(knnKeyList.get(lastIndex), configValueList.get(lastIndex).toString()); List> modelTensorList = createMockVectorResult(); - Map result = processor.buildResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata()); + Map result = processor.buildNLPResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata()); assertTrue(result.containsKey("oriKey1_knn")); assertTrue(result.containsKey("oriKey2_knn")); assertTrue(result.containsKey("oriKey3_knn")); @@ -395,7 +395,7 @@ public void testBuildVectorOutput_withNestedMap_successful() { TextEmbeddingProcessor processor = createInstanceWithNestedMapConfiguration(config); Map knnMap = processor.buildMapWithProcessorKeyAndOriginalValue(ingestDocument); List> modelTensorList = createMockVectorResult(); - processor.buildResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata()); + processor.buildNLPResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata()); Map favoritesMap = (Map) ingestDocument.getSourceAndMetadata().get("favorites"); assertNotNull(favoritesMap); Map favoriteGames = (Map) favoritesMap.get("favorite.games"); @@ -411,7 +411,7 @@ public void testBuildVectorOutput_withNestedList_successful() { TextEmbeddingProcessor textEmbeddingProcessor = createInstanceWithNestedMapConfiguration(config); Map knnMap = textEmbeddingProcessor.buildMapWithProcessorKeyAndOriginalValue(ingestDocument); List> modelTensorList = createMockVectorResult(); - textEmbeddingProcessor.buildResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata()); + textEmbeddingProcessor.buildNLPResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata()); List> nestedObj = (List>) ingestDocument.getSourceAndMetadata().get("nestedField"); assertTrue(nestedObj.get(0).containsKey("vectorField")); assertTrue(nestedObj.get(1).containsKey("vectorField")); @@ -425,7 +425,7 @@ public void testBuildVectorOutput_withNestedList_Level2_successful() { TextEmbeddingProcessor textEmbeddingProcessor = createInstanceWithNestedMapConfiguration(config); Map knnMap = textEmbeddingProcessor.buildMapWithProcessorKeyAndOriginalValue(ingestDocument); List> modelTensorList = createMockVectorResult(); - textEmbeddingProcessor.buildResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata()); + textEmbeddingProcessor.buildNLPResult(knnMap, modelTensorList, ingestDocument.getSourceAndMetadata()); Map nestedLevel1 = (Map) ingestDocument.getSourceAndMetadata().get("nestedField"); List> nestedObj = (List>) nestedLevel1.get("nestedField"); assertTrue(nestedObj.get(0).containsKey("vectorField")); @@ -440,10 +440,10 @@ public void test_updateDocument_appendVectorFieldsToDocument_successful() { TextEmbeddingProcessor processor = createInstanceWithNestedMapConfiguration(config); Map knnMap = processor.buildMapWithProcessorKeyAndOriginalValue(ingestDocument); List> modelTensorList = createMockVectorResult(); - processor.setTargetFieldsToDocument(ingestDocument, knnMap, modelTensorList); + processor.setVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList); List> modelTensorList1 = createMockVectorResult(); - processor.setTargetFieldsToDocument(ingestDocument, knnMap, modelTensorList1); + processor.setVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList1); assertEquals(12, ingestDocument.getSourceAndMetadata().size()); assertEquals(2, ((List) ingestDocument.getSourceAndMetadata().get("oriKey6_knn")).size()); }