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); }