This is the code i am forming , to update certain fields on an elastic document i only inted to update certain fields on elastic document, i am using elastic 8.10.4 , for some reason , it is not able to take the script field and says Cannot resolve method ‘script(Script) , can someine help me out
public void upsertNvalueDataToESByQuery(List searchNvalues, String index, boolean isPreview, String attributeId_s, String formattedName_s, String displayName) {
List queryList = new ArrayList<>();
queryList.add(MatchQuery.of(matchQueryBuilder -> matchQueryBuilder.field(attributeId_s).query(“”))._toQuery());
StringBuilder scriptBuilder = new StringBuilder();
scriptBuilder.append("ctx._source.NAME = params.name; ");
scriptBuilder.append("ctx._source.DISP_NAME = params.displayName; ");
Script script = new Script(
ScriptType.INLINE,
"painless",
scriptBuilder.toString(),
ImmutableMap.of(
"name", formattedName_s,
"displayName", displayName
));
UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest.Builder()
.query(builder -> builder.bool(builder1 -> builder1.must(queryList)))
.script(script)
.build();
try {
UpdateByQueryResponse updateByQueryResponse = elasticClientBuilder.getESClient(isPreview)
.updateByQuery(updateByQueryRequest);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
I have tried too many solutions available none of them seems to be working
Yash Narkhede is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.