Search in sources :

Example 11 with RequestOptions

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

the class ElasticsearchClient method search.

public SearchResponse search(SearchRequest searchRequest, String errorMessage) {
    final MultiSearchRequest multiSearchRequest = new MultiSearchRequest().add(searchRequest);
    final MultiSearchResponse result = this.execute((c, requestOptions) -> c.msearch(multiSearchRequest, requestOptions), errorMessage);
    return firstResponseFrom(result, errorMessage);
}
Also used : MultiSearchResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.MultiSearchResponse) MultiSearchRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.MultiSearchRequest)

Example 12 with RequestOptions

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

the class IndicesAdapterES7 method create.

@Override
public void create(String index, IndexSettings indexSettings) {
    final Map<String, Object> settings = new HashMap<>();
    settings.put("number_of_shards", indexSettings.shards());
    settings.put("number_of_replicas", indexSettings.replicas());
    final CreateIndexRequest request = new CreateIndexRequest(index).settings(settings);
    client.execute((c, requestOptions) -> c.indices().create(request, requestOptions), "Unable to create index " + index);
}
Also used : HashMap(java.util.HashMap) CreateIndexRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.indices.CreateIndexRequest)

Example 13 with RequestOptions

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

the class IndicesAdapterES7 method delete.

@Override
public void delete(String index) {
    final DeleteIndexRequest request = new DeleteIndexRequest(index);
    client.execute((c, requestOptions) -> c.indices().delete(request, requestOptions));
}
Also used : DeleteIndexRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)

Example 14 with RequestOptions

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

the class IndicesAdapterES7 method deleteIndexTemplate.

@Override
public boolean deleteIndexTemplate(String templateName) {
    final DeleteIndexTemplateRequest request = new DeleteIndexTemplateRequest(templateName);
    final AcknowledgedResponse result = client.execute((c, requestOptions) -> c.indices().deleteTemplate(request, requestOptions), "Unable to delete index template " + templateName);
    return result.isAcknowledged();
}
Also used : AcknowledgedResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse) DeleteIndexTemplateRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest)

Example 15 with RequestOptions

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

the class IndicesAdapterES7 method resolveAlias.

@Override
public Set<String> resolveAlias(String alias) {
    final GetAliasesRequest request = new GetAliasesRequest().aliases(alias);
    final GetAliasesResponse result = client.execute((c, requestOptions) -> c.indices().getAlias(request, requestOptions));
    return result.getAliases().keySet();
}
Also used : GetAliasesResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.GetAliasesResponse) GetAliasesRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest)

Aggregations

IndicesAliasesRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 Response (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Response)8 CreateIndexRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.indices.CreateIndexRequest)8 Collectors (java.util.stream.Collectors)7 ClusterHealthRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest)7 Request (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Request)7 Inject (javax.inject.Inject)6 DeleteIndexRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)6 UpdateSettingsRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest)6 DeleteIndexTemplateRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest)6 IndexRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.index.IndexRequest)6 PutIndexTemplateRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.indices.PutIndexTemplateRequest)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 Collection (java.util.Collection)5 List (java.util.List)5 Map (java.util.Map)5 ClusterUpdateSettingsRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)5 BulkRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.bulk.BulkRequest)5 ElasticsearchClient (org.graylog.storage.elasticsearch7.ElasticsearchClient)5