use of org.opensearch.client.opensearch.core.IndexResponse in project opensearch-java by opensearch-project.
the class RequestTest method testRefresh.
@Test
public void testRefresh() throws IOException {
AppData appData = new AppData();
appData.setIntValue(42);
appData.setMsg("Some message");
IndexResponse ir = highLevelClient().index(_0 -> _0.index("test").id("1").document(appData).refresh(Refresh.WaitFor));
assertEquals("1", ir.id());
}
use of org.opensearch.client.opensearch.core.IndexResponse in project opensearch-java by opensearch-project.
the class CrudIT method testUpdateWithTypes.
public void testUpdateWithTypes() throws IOException {
AppData appData = new AppData();
appData.setIntValue(1337);
appData.setMsg("foo");
AppData updatedAppData = new AppData();
appData.setIntValue(3333);
appData.setMsg("bar");
IndexRequest<AppData> indexRequest = new IndexRequest.Builder<AppData>().index("index").id("id").type("type").document(appData).build();
IndexResponse indexResponse = highLevelClient().index(indexRequest);
UpdateRequest<AppData, AppData> updateRequest = new UpdateRequest.Builder<AppData, AppData>().index("index").id("id").type("type").doc(updatedAppData).build();
UpdateResponse<AppData> updateResponse = highLevelClient().update(updateRequest, AppData.class);
assertEquals(Result.Updated, updateResponse.result());
assertEquals(indexResponse.version() + 1, updateResponse.version());
}
Aggregations