UpdateByQuery can not batch execute


(赵宇飞) #1

Hello, guys!
currently i have an index, like it have three fields: id, otherIds(split by ","), score.
now i have such requirement:
i want to update the score by query at otherIds,
the udpateByQuery api can meet my needs like blow:

UpdateByQueryRequestBuilder ubqrb = UpdateByQueryAction.INSTANCE.newRequestBuilder(
                        EpScoreComputeAndUpdate.client_statistics1);
               ctx._source.grade=newGrade;
               String inlineScript="if(ctx._source.grade == null) ctx._source.grade=newGrade; else if(ctx._source.grade<newGrade) ctx._source.grade=newGrade";
                  Map<String,Object> params=Maps.newHashMap();
                            params.put("newGrade",0);
                            Script script = new Script(inlineScript, org.elasticsearch.script.ScriptService.ScriptType.INLINE, org.elasticsearch.script.ScriptService.DEFAULT_LANG, params);
    ubqrb.source("vcg_editorial")
                        .script(script)
                        .filter(QueryBuilders.termQuery("otherIds","386022522"));
                   BulkIndexByScrollResponse response= ubqrb.get();

but i can not batch execute them.

anyone know why batch execute UpdateByQueryRequest is not supported? or i miss something?


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.