use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.
the class ClusterStateApi method fields.
public Map<String, Set<String>> fields(Collection<String> indices) {
final Request request = request(indices);
final JsonNode jsonResponse = client.execute((c, requestOptions) -> {
request.setOptions(requestOptions);
final Response response = c.getLowLevelClient().performRequest(request);
return objectMapper.readTree(response.getEntity().getContent());
}, "Unable to retrieve fields from indices: " + String.join(",", indices));
// noinspection UnstableApiUsage
return Streams.stream(jsonResponse.path("metadata").path("indices").fields()).flatMap(index -> allFieldsFromIndex(index.getKey(), index.getValue())).collect(groupingBy(Map.Entry::getKey, mapping(Map.Entry::getValue, Collectors.toSet())));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project graylog2-server by Graylog2.
the class Scroll method scroll.
public ScrollResult scroll(ScrollCommand scrollCommand) {
final SearchSourceBuilder searchQuery = searchRequestFactory.create(scrollCommand);
searchQuery.fetchSource(scrollCommand.fields().toArray(new String[0]), new String[0]);
scrollCommand.batchSize().ifPresent(batchSize -> searchQuery.size(Math.toIntExact(batchSize)));
final SearchRequest request = scrollBuilder(searchQuery, scrollCommand.indices());
final SearchResponse result = client.singleSearch(request, "Unable to perform scroll search");
return scrollResultFactory.create(result, searchQuery.toString(), DEFAULT_SCROLLTIME, scrollCommand.fields(), scrollCommand.limit().orElse(-1));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project sonarqube by SonarSource.
the class EsClient method nodesStats.
// https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html
public NodeStatsResponse nodesStats() {
return execute(() -> {
Request request = new Request("GET", "/_nodes/stats/fs,process,jvm,indices,breaker");
Response response = restHighLevelClient.getLowLevelClient().performRequest(request);
return NodeStatsResponse.toNodeStatsResponse(gson.fromJson(EntityUtils.toString(response.getEntity()), JsonObject.class));
});
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project datashare by ICIJ.
the class ElasticsearchIndexer method executeRaw.
@Override
public String executeRaw(String method, String url, String rawJson) throws IOException {
Request request = new Request(method, url.startsWith("/") ? url : "/" + url);
if (rawJson != null && !rawJson.isEmpty()) {
request.setJsonEntity(rawJson);
}
Response response = client.getLowLevelClient().performRequest(request);
if ("OPTIONS".equals(method)) {
return response.getHeader("Allow");
}
HttpEntity entity = response.getEntity();
return entity != null ? EntityUtils.toString(entity) : null;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request in project datashare by ICIJ.
the class ElasticsearchIndexer method deleteAll.
@Override
public boolean deleteAll(String indexName) throws IOException {
Request post = new Request("POST", indexName + "/_delete_by_query?refresh");
post.setEntity(new NStringEntity("{\"query\":{\"match_all\": {}}}", ContentType.APPLICATION_JSON));
Response response = client.getLowLevelClient().performRequest(post);
return response.getStatusLine().getStatusCode() == RestStatus.OK.getStatus();
}
Aggregations