ESUpdateNode updateNode = new ESUpdateNode(
new String[]{"characters"},
new HashMap<Reference, Symbol>(){{
put(name_ref, Literal.newLiteral("mostly harmless"));
}},
new WhereClause(whereClause),
new ArrayList<String>(0),
new ArrayList<String>(0)
);
Plan plan = new Plan();
plan.add(updateNode);
plan.expectsAffectedRows(true);
Job job = executor.newJob(plan);
assertThat(job.tasks().get(0), instanceOf(ESUpdateByQueryTask.class));
List<ListenableFuture<TaskResult>> result = executor.execute(job);
assertThat(result.get(0).get().rowCount(), is(2L));
refresh();
// verify update
Function searchWhereClause = new Function(new FunctionInfo(
new FunctionIdent(EqOperator.NAME, Arrays.<DataType>asList(DataTypes.STRING, DataTypes.STRING)),
DataTypes.BOOLEAN),
Arrays.<Symbol>asList(name_ref, Literal.newLiteral("mostly harmless")));
DocTableInfo characters = docSchemaInfo.getTableInfo("characters");
QueryThenFetchNode node = new QueryThenFetchNode(
characters.getRouting(WhereClause.MATCH_ALL),
Arrays.<Symbol>asList(id_ref, name_ref),
ImmutableList.<Symbol>of(id_ref),
new boolean[]{false},
new Boolean[] { null },
null, null, new WhereClause(searchWhereClause),
null
);
node.outputTypes(Arrays.asList(id_ref.info().type(), name_ref.info().type()));
plan = new Plan();
plan.add(node);