From 0397c981c90e9d764cf695cac0e81508b2363990 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Fri, 6 Oct 2023 13:48:30 -0700 Subject: [PATCH] support bwc for process function (#1427) (#1439) * support bwc for process function Signed-off-by: Yaliang Wu * add comment Signed-off-by: Yaliang Wu --------- Signed-off-by: Yaliang Wu (cherry picked from commit efe5566fbb65a2bbebd702fe773f7a00fc3b37df) Co-authored-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); }