use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RequestOptions in project graylog2-server by Graylog2.
the class MessagesAdapterES7 method runBulkRequest.
private BulkResponse runBulkRequest(int indexedSuccessfully, List<IndexingRequest> chunk) throws ChunkedBulkIndexer.EntityTooLargeException {
final BulkRequest bulkRequest = createBulkRequest(chunk);
final BulkResponse result;
try {
result = this.client.execute((c, requestOptions) -> c.bulk(bulkRequest, requestOptions));
} catch (ElasticsearchException e) {
for (ElasticsearchException cause : e.guessRootCauses()) {
if (cause.status().equals(RestStatus.REQUEST_ENTITY_TOO_LARGE)) {
throw new ChunkedBulkIndexer.EntityTooLargeException(indexedSuccessfully, indexingErrorsFrom(chunk));
}
}
throw new org.graylog2.indexer.ElasticsearchException(e);
}
return result;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RequestOptions in project graylog2-server by Graylog2.
the class FieldMappingApi method fieldTypes.
public Map<String, FieldMapping> fieldTypes(String index) {
final JsonNode result = client.execute((c, requestOptions) -> {
final Response response = c.getLowLevelClient().performRequest(request(index));
return objectMapper.readTree(response.getEntity().getContent());
}, "Unable to retrieve field types of index " + index);
final JsonNode fields = result.path(index).path("mappings").path("properties");
// noinspection UnstableApiUsage
return Streams.stream(fields.fields()).collect(Collectors.toMap(Map.Entry::getKey, entry -> FieldMapping.create(entry.getValue().path("type").asText(), entry.getValue().path("fielddata").asBoolean())));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RequestOptions in project graylog2-server by Graylog2.
the class StatsApi method stats.
private JsonNode stats(Collection<String> indices, Collection<String> metrics, Consumer<Request> prepareRequest) {
final StringBuilder endpoint = new StringBuilder();
if (!indices.isEmpty()) {
final String joinedIndices = String.join(",", indices);
endpoint.append("/");
endpoint.append(joinedIndices);
}
endpoint.append("/_stats");
if (!metrics.isEmpty()) {
final String joinedMetrics = String.join(",", metrics);
endpoint.append("/");
endpoint.append(joinedMetrics);
}
final Request request = new Request("GET", endpoint.toString());
prepareRequest.accept(request);
return client.execute((c, requestOptions) -> {
request.setOptions(requestOptions);
final Response response = c.getLowLevelClient().performRequest(request);
return objectMapper.readTree(response.getEntity().getContent());
}, "Unable to retrieve index stats for " + String.join(",", indices));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RequestOptions in project graylog2-server by Graylog2.
the class ScrollResultES7 method nextSearchResult.
private SearchResponse nextSearchResult() throws IOException {
final SearchScrollRequest scrollRequest = new SearchScrollRequest(this.scrollId);
scrollRequest.scroll(TimeValue.parseTimeValue(this.scroll, DEFAULT_SCROLL, "scroll time"));
return client.executeWithIOException((c, requestOptions) -> c.scroll(scrollRequest, requestOptions), "Unable to retrieve next chunk from search: ");
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RequestOptions in project graylog2-server by Graylog2.
the class ScrollResultES7 method cancel.
@Override
public void cancel() throws IOException {
final ClearScrollRequest request = new ClearScrollRequest();
request.addScrollId(scrollId);
client.executeWithIOException((c, requestOptions) -> c.clearScroll(request, requestOptions), "Unable to cancel scrolling search request");
}
Aggregations