use of org.opensearch.client.opensearch.core.bulk.OperationType in project opensearch-java by opensearch-project.
the class RequestTest method testBulkRequest.
@Test
public void testBulkRequest() throws IOException {
AppData appData = new AppData();
appData.setIntValue(42);
appData.setMsg("Some message");
BulkResponse bulk = highLevelClient().bulk(_0 -> _0.operations(_1 -> _1.create(_2 -> _2.index("foo").id("abc").document(appData))).operations(_1 -> _1.create(_2 -> _2.index("foo").id("def").document(appData))));
assertFalse(bulk.errors());
assertEquals(2, bulk.items().size());
assertEquals(OperationType.Create, bulk.items().get(0).operationType());
assertEquals("foo", bulk.items().get(0).index());
assertEquals(1L, bulk.items().get(0).version().longValue());
assertEquals("foo", bulk.items().get(1).index());
assertEquals(1L, bulk.items().get(1).version().longValue());
assertEquals(42, highLevelClient().get(b -> b.index("foo").id("abc"), AppData.class).source().getIntValue());
}
Aggregations