use of org.opensearch.client.opensearch.core.IndexRequest 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