Search in sources :

Example 1 with GetSettings

use of io.searchbox.indices.settings.GetSettings in project graylog2-server by Graylog2.

the class IndicesAdapterES6 method indexCreationDate.

@Override
public Optional<DateTime> indexCreationDate(String index) {
    final GetSettings request = new GetSettings.Builder().addIndex(index).ignoreUnavailable(true).build();
    final JestResult jestResult = JestUtils.execute(jestClient, request, () -> "Couldn't read settings of index " + index);
    return Optional.of(jestResult.getJsonObject().path(index).path("settings").path("index").path("creation_date")).filter(JsonNode::isValueNode).map(JsonNode::asLong).map(creationDate -> new DateTime(creationDate, DateTimeZone.UTC));
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) JestResult(io.searchbox.client.JestResult) DateTime(org.joda.time.DateTime) GetSettings(io.searchbox.indices.settings.GetSettings)

Example 2 with GetSettings

use of io.searchbox.indices.settings.GetSettings in project herd by FINRAOS.

the class IndexFunctionsDaoImpl method getIndexSettings.

@Override
public Settings getIndexSettings(String indexName) {
    GetSettings getSettings = new GetSettings.Builder().addIndex(indexName).build();
    JestResult result = jestClientHelper.executeAction(getSettings);
    Assert.isTrue(result.isSucceeded(), result.getErrorMessage());
    JsonObject json = result.getJsonObject().getAsJsonObject(indexName).getAsJsonObject("settings");
    return Settings.builder().loadFromSource(json.toString()).build();
}
Also used : SearchSourceBuilder(org.elasticsearch.search.builder.SearchSourceBuilder) SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) JsonObject(com.google.gson.JsonObject) JestResult(io.searchbox.client.JestResult) GetSettings(io.searchbox.indices.settings.GetSettings)

Aggregations

JestResult (io.searchbox.client.JestResult)2 GetSettings (io.searchbox.indices.settings.GetSettings)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 JsonObject (com.google.gson.JsonObject)1 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)1 SearchSourceBuilder (org.elasticsearch.search.builder.SearchSourceBuilder)1 DateTime (org.joda.time.DateTime)1