Search in sources :

Example 1 with IndexRequest

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());
}
Also used : CreateIndexResponse(org.opensearch.client.opensearch.indices.CreateIndexResponse) DeleteIndexResponse(org.opensearch.client.opensearch.indices.DeleteIndexResponse) IndexResponse(org.opensearch.client.opensearch.core.IndexResponse) UpdateRequest(org.opensearch.client.opensearch.core.UpdateRequest) IndexRequest(org.opensearch.client.opensearch.core.IndexRequest)

Aggregations

IndexRequest (org.opensearch.client.opensearch.core.IndexRequest)1 IndexResponse (org.opensearch.client.opensearch.core.IndexResponse)1 UpdateRequest (org.opensearch.client.opensearch.core.UpdateRequest)1 CreateIndexResponse (org.opensearch.client.opensearch.indices.CreateIndexResponse)1 DeleteIndexResponse (org.opensearch.client.opensearch.indices.DeleteIndexResponse)1