use of org.elasticsearch.client.Request in project immutables by immutables.
the class ElasticsearchOps method nextScroll.
/**
* Fetches next results given a scrollId.
*/
Single<Json.Result> nextScroll(String scrollId) {
// fetch next scroll
final Request request = new Request("POST", "/_search/scroll");
final ObjectNode payload = mapper.createObjectNode().put("scroll", "1m").put("scroll_id", scrollId);
request.setJsonEntity(payload.toString());
return transport.execute(request).map(r -> responseConverter().apply(r));
}
use of org.elasticsearch.client.Request in project immutables by immutables.
the class ElasticsearchOps method closeScroll.
Completable closeScroll(Iterable<String> scrollIds) {
final ObjectNode payload = mapper.createObjectNode();
final ArrayNode array = payload.withArray("scroll_id");
scrollIds.forEach(array::add);
final Request request = new Request("DELETE", "/_search/scroll");
request.setJsonEntity(payload.toString());
return transport.execute(request).ignoreElement();
}
use of org.elasticsearch.client.Request in project immutables by immutables.
the class ElasticsearchOps method insertDocument.
Single<WriteResult> insertDocument(ObjectNode document) throws IOException {
Objects.requireNonNull(document, "document");
String uri = String.format(Locale.ROOT, "/%s/_doc?refresh", index);
StringEntity entity = new StringEntity(mapper().writeValueAsString(document), ContentType.APPLICATION_JSON);
final Request r = new Request("POST", uri);
r.setEntity(entity);
return transport.execute(r).map(x -> WriteResult.unknown());
}
use of org.elasticsearch.client.Request in project immutables by immutables.
the class ElasticsearchOps method searchRaw.
Single<Json.Result> searchRaw(ObjectNode query, Map<String, String> httpParams) {
final Request request = new Request("POST", String.format("/%s/_search", index));
httpParams.forEach(request::addParameter);
request.setJsonEntity(query.toString());
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Performing search {0} on {1}", new Object[] { query, request });
}
return transport.execute(request).map(r -> responseConverter().apply(r));
}
use of org.elasticsearch.client.Request in project immutables by immutables.
the class IndexOps method version.
Single<Version> version() {
final Request request = new Request("GET", "/");
// version extract function
final Function<ObjectNode, Version> fn = node -> Version.of(node.get("version").get("number").asText());
return transport.execute(request).map(response -> mapper.readValue(response.getEntity().getContent(), ObjectNode.class)).map(fn::apply);
}
Aggregations