Search in sources :

Example 1 with IndexResponse

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());
}
Also used : CreateIndexResponse(org.opensearch.client.opensearch.indices.CreateIndexResponse) IndexResponse(org.opensearch.client.opensearch.core.IndexResponse) GetIndexResponse(org.opensearch.client.opensearch.indices.GetIndexResponse) Test(org.junit.Test)

Example 2 with IndexResponse

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());
}
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

IndexResponse (org.opensearch.client.opensearch.core.IndexResponse)2 CreateIndexResponse (org.opensearch.client.opensearch.indices.CreateIndexResponse)2 Test (org.junit.Test)1 IndexRequest (org.opensearch.client.opensearch.core.IndexRequest)1 UpdateRequest (org.opensearch.client.opensearch.core.UpdateRequest)1 DeleteIndexResponse (org.opensearch.client.opensearch.indices.DeleteIndexResponse)1 GetIndexResponse (org.opensearch.client.opensearch.indices.GetIndexResponse)1