From 285f71b37388b2e19a4ac1fa6a68cb41050c24d2 Mon Sep 17 00:00:00 2001 From: Yaliang Wu Date: Wed, 4 Oct 2023 12:30:34 -0700 Subject: [PATCH] support bwc for process function (#1427) * support bwc for process function Signed-off-by: Yaliang Wu * add comment Signed-off-by: Yaliang Wu --------- Signed-off-by: Yaliang Wu --- .../ml/engine/algorithms/remote/ConnectorUtils.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java index c481725057..ab4ed7fd6c 100644 --- a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java +++ b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java @@ -94,7 +94,10 @@ private static RemoteInferenceInputDataSet processTextDocsInput(TextDocsInputDat List docs = new ArrayList<>(); for (String doc : inputDataSet.getDocs()) { if (doc != null) { - docs.add(gson.toJson(doc)); + String gsonString = gson.toJson(doc); + // in 2.9, user will add " before and after string + // gson.toString(string) will add extra " before after string, so need to remove + docs.add(gsonString.substring(1, gsonString.length() - 1)); } else { docs.add(null); }