Search in sources :

Example 1 with ReactiveElasticsearchClient

use of org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient in project spring-boot by spring-projects.

the class ReactiveElasticsearchRestClientAutoConfigurationIntegrationTests method restClientCanQueryElasticsearchNode.

@Test
void restClientCanQueryElasticsearchNode() {
    this.contextRunner.withPropertyValues("spring.elasticsearch.uris=" + elasticsearch.getHttpHostAddress(), "spring.elasticsearch.connection-timeout=120s", "spring.elasticsearch.socket-timeout=120s").run((context) -> {
        ReactiveElasticsearchClient client = context.getBean(ReactiveElasticsearchClient.class);
        Map<String, String> source = new HashMap<>();
        source.put("a", "alpha");
        source.put("b", "bravo");
        IndexRequest indexRequest = new IndexRequest("foo").id("1").source(source);
        GetRequest getRequest = new GetRequest("foo").id("1");
        GetResult getResult = client.index(indexRequest).then(client.get(getRequest)).block();
        assertThat(getResult).isNotNull();
        assertThat(getResult.isExists()).isTrue();
    });
}
Also used : ReactiveElasticsearchClient(org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient) GetResult(org.elasticsearch.index.get.GetResult) HashMap(java.util.HashMap) GetRequest(org.elasticsearch.action.get.GetRequest) IndexRequest(org.elasticsearch.action.index.IndexRequest) Test(org.junit.jupiter.api.Test)

Example 2 with ReactiveElasticsearchClient

use of org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient in project spring-boot by spring-projects.

the class ElasticsearchReactiveHealthIndicatorTests method setup.

@BeforeEach
void setup() throws Exception {
    this.server = new MockWebServer();
    this.server.start();
    ReactiveElasticsearchClient client = DefaultReactiveElasticsearchClient.create(ClientConfiguration.create(this.server.getHostName() + ":" + this.server.getPort()));
    this.healthIndicator = new ElasticsearchReactiveHealthIndicator(client);
}
Also used : ReactiveElasticsearchClient(org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient) DefaultReactiveElasticsearchClient(org.springframework.data.elasticsearch.client.reactive.DefaultReactiveElasticsearchClient) MockWebServer(okhttp3.mockwebserver.MockWebServer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ReactiveElasticsearchClient (org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient)2 HashMap (java.util.HashMap)1 MockWebServer (okhttp3.mockwebserver.MockWebServer)1 GetRequest (org.elasticsearch.action.get.GetRequest)1 IndexRequest (org.elasticsearch.action.index.IndexRequest)1 GetResult (org.elasticsearch.index.get.GetResult)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 DefaultReactiveElasticsearchClient (org.springframework.data.elasticsearch.client.reactive.DefaultReactiveElasticsearchClient)1