Search in sources :

Example 91 with Request

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.

the class MessagesAdapterES7 method createBulkRequest.

private BulkRequest createBulkRequest(List<IndexingRequest> chunk) {
    final BulkRequest bulkRequest = new BulkRequest();
    chunk.forEach(request -> bulkRequest.add(indexRequestFrom(request)));
    return bulkRequest;
}
Also used : BulkRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.bulk.BulkRequest)

Example 92 with Request

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.

the class PlainJsonApi method perform.

public JsonNode perform(Request request, String errorMessage) {
    return client.execute((c, requestOptions) -> {
        request.setOptions(requestOptions);
        final Response response = c.getLowLevelClient().performRequest(request);
        return objectMapper.readTree(response.getEntity().getContent());
    }, errorMessage);
}
Also used : Response(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Response)

Example 93 with Request

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.

the class IndicesAdapterES7 method close.

@Override
public void close(String index) {
    final CloseIndexRequest request = new CloseIndexRequest(index);
    client.execute((c, requestOptions) -> c.indices().close(request, requestOptions), "Unable to close index " + index);
}
Also used : CloseIndexRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.indices.CloseIndexRequest)

Example 94 with Request

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.

the class ElasticsearchBackendSearchTypesWithStreamsOverridesTest method searchTypeWithEmptyStreamsDefaultsToQueriesStreams.

@Test
public void searchTypeWithEmptyStreamsDefaultsToQueriesStreams() throws IOException {
    final Query query = queryFor(Pivot.builder().id("pivot1").series(Collections.singletonList(Average.builder().field("field1").build())).rollup(true).streams(Collections.emptySet()).build());
    final List<SearchRequest> request = run(query);
    assertThat(indicesOf(request).get(0)).isEqualTo("index1,index2");
}
Also used : SearchRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest) Query(org.graylog.plugins.views.search.Query) Test(org.junit.Test)

Example 95 with Request

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.

the class ElasticsearchBackendSearchTypesWithStreamsOverridesTest method searchTypeWithStreamsOverridesQueriesStreams.

@Test
public void searchTypeWithStreamsOverridesQueriesStreams() throws IOException {
    final Query query = queryFor(Pivot.builder().id("pivot1").series(Collections.singletonList(Average.builder().field("field1").build())).rollup(true).streams(Collections.singleton(stream2Id)).build());
    final List<SearchRequest> request = run(query);
    assertThat(indicesOf(request).get(0)).isEqualTo("index3");
}
Also used : SearchRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest) Query(org.graylog.plugins.views.search.Query) Test(org.junit.Test)

Aggregations

Request (org.elasticsearch.client.Request)54 Response (org.elasticsearch.client.Response)34 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 IOException (java.io.IOException)12 Request (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request)12 HttpEntity (org.apache.http.HttpEntity)11 NStringEntity (org.apache.http.nio.entity.NStringEntity)11 Map (java.util.Map)10 Collectors (java.util.stream.Collectors)10 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)9 SearchRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest)7 Response (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Response)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 InputStream (java.io.InputStream)6 StringEntity (org.apache.http.entity.StringEntity)6 RestClient (org.elasticsearch.client.RestClient)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 HashMap (java.util.HashMap)5 Locale (java.util.Locale)5 ContentType (org.apache.http.entity.ContentType)5