Map<String, Object> sourceMap = new MapBuilder<String, Object>()
.put("id", 0L)
.put("name", "Trillian")
.map();
BytesReference source = XContentFactory.jsonBuilder().map(sourceMap).bytes();
PartitionName partitionName = new PartitionName("parted", Arrays.asList(new BytesRef("13959981214861")));
ESIndexNode indexNode = new ESIndexNode(
new String[]{partitionName.stringValue()},
Arrays.asList(source),
ImmutableList.of("123"),
ImmutableList.of("123"),
true,
false
);
Plan plan = new Plan();
plan.add(indexNode);
plan.expectsAffectedRows(true);
Job job = executor.newJob(plan);
assertThat(job.tasks().get(0), instanceOf(ESIndexTask.class));
List<ListenableFuture<TaskResult>> result = executor.execute(job);
TaskResult taskResult = result.get(0).get();
Object[][] indexResult = taskResult.rows();
assertThat(indexResult.length, is(0));
assertThat(taskResult.rowCount(), is(1L));
refresh();
assertTrue(
client().admin().indices().prepareExists(partitionName.stringValue())
.execute().actionGet().isExists()
);
assertTrue(
client().admin().indices().prepareAliasesExist("parted")
.execute().actionGet().exists()
);
SearchHits hits = client().prepareSearch(partitionName.stringValue())
.setTypes(Constants.DEFAULT_MAPPING_TYPE)
.addFields("id", "name")
.setQuery(new MapBuilder<String, Object>()
.put("match_all", new HashMap<String, Object>())
.map()