Search in sources :

Example 6 with GetSettingsRequest

use of org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest in project sonarqube by SonarSource.

the class IndexCreatorTest method isNotReadOnly.

private boolean isNotReadOnly(IndexMainType mainType) {
    String indexName = mainType.getIndex().getName();
    String readOnly = es.client().getSettings(new GetSettingsRequest().indices(indexName)).getSetting(indexName, "index.blocks.read_only_allow_delete");
    return readOnly == null;
}
Also used : GetSettingsRequest(org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest)

Example 7 with GetSettingsRequest

use of org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest in project openk9 by smclab.

the class ReindexDatasourceConsumer method activate.

@Activate
void activate() {
    RestHighLevelClient restHighLevelClient = _restHighLevelClientProvider.get();
    _disposable = _datasourceEventConsumer.datasourceUpdateEvents().flatMap(datasource -> _pluginDriverManagerClient.getPluginDriver(datasource.getDriverServiceName()).onErrorResume(throwable -> {
        if (_log.isErrorEnabled()) {
            _log.error(throwable.getMessage());
        }
        return Mono.empty();
    }).map(pluginDriverDTO -> Tuples.of(datasource, datasource.getTenantId() + "-" + pluginDriverDTO.getName() + "-data"))).filterWhen(t2 -> Mono.create(sink -> restHighLevelClient.indices().existsAsync(new GetIndexRequest(t2.getT2()), RequestOptions.DEFAULT, new ReactorActionListener<>(sink)))).flatMap(t2 -> Mono.<GetSettingsResponse>create(sink -> restHighLevelClient.indices().getSettingsAsync(new GetSettingsRequest().indices(t2.getT2()).names("index.creation_date"), RequestOptions.DEFAULT, new ReactorActionListener<>(sink))).map(response -> Tuples.of(t2.getT1(), t2.getT2(), Instant.ofEpochMilli(Long.parseLong(response.getSetting(t2.getT2(), "index.creation_date")))))).log().filter(t3 -> t3.getT1().getLastIngestionDate().isBefore(t3.getT3())).flatMap(t3 -> Mono.<AcknowledgedResponse>create(sink -> restHighLevelClient.indices().deleteAsync(new DeleteIndexRequest(t3.getT2()), RequestOptions.DEFAULT, new ReactorActionListener<>(sink)))).onErrorContinue((throwable, ignore) -> {
        if (_log.isErrorEnabled()) {
            _log.error(throwable.getMessage());
        }
    }).subscribe();
}
Also used : ReactorActionListener(io.openk9.search.client.api.ReactorActionListener) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) DatasourceEventConsumer(io.openk9.datasource.event.consumer.api.DatasourceEventConsumer) Logger(org.slf4j.Logger) Disposable(reactor.core.Disposable) GetSettingsResponse(org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse) Deactivate(org.osgi.service.component.annotations.Deactivate) LoggerFactory(org.slf4j.LoggerFactory) Tuples(reactor.util.function.Tuples) Mono(reactor.core.publisher.Mono) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) RestHighLevelClient(org.elasticsearch.client.RestHighLevelClient) Instant(java.time.Instant) Component(org.osgi.service.component.annotations.Component) RequestOptions(org.elasticsearch.client.RequestOptions) PluginDriverManagerClient(io.openk9.plugin.driver.manager.client.api.PluginDriverManagerClient) Activate(org.osgi.service.component.annotations.Activate) GetSettingsRequest(org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest) Reference(org.osgi.service.component.annotations.Reference) RestHighLevelClientProvider(io.openk9.search.client.api.RestHighLevelClientProvider) GetIndexRequest(org.elasticsearch.client.indices.GetIndexRequest) ReactorActionListener(io.openk9.search.client.api.ReactorActionListener) GetSettingsRequest(org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest) GetSettingsResponse(org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse) GetIndexRequest(org.elasticsearch.client.indices.GetIndexRequest) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) RestHighLevelClient(org.elasticsearch.client.RestHighLevelClient) Activate(org.osgi.service.component.annotations.Activate)

Example 8 with GetSettingsRequest

use of org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest in project search by craftercms.

the class ElasticsearchAdminServiceImpl method doGetIndexSettings.

protected Map<String, String> doGetIndexSettings(RestHighLevelClient client, String indexName) throws IOException {
    GetSettingsResponse response = client.indices().getSettings(new GetSettingsRequest().indices(indexName), RequestOptions.DEFAULT);
    Map<String, String> settings = new HashMap<>(defaultSettings);
    defaultSettings.keySet().forEach(key -> {
        String value = response.getSetting(indexName, key);
        if (isNotEmpty(value)) {
            logger.debug("Using existing setting {}={} from index {}", key, value, indexName);
            settings.put(key, value);
        }
    });
    return settings;
}
Also used : GetSettingsRequest(org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest) GetSettingsResponse(org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse) HashMap(java.util.HashMap)

Example 9 with GetSettingsRequest

use of org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest in project spring-data-elasticsearch by spring-projects.

the class RequestConverters method getSettings.

public static Request getSettings(GetSettingsRequest getSettingsRequest) {
    String[] indices = getSettingsRequest.indices() == null ? Strings.EMPTY_ARRAY : getSettingsRequest.indices();
    String[] names = getSettingsRequest.names() == null ? Strings.EMPTY_ARRAY : getSettingsRequest.names();
    Request request = new Request(HttpMethod.GET.name(), RequestConverters.endpoint(indices, "_settings", names));
    RequestConverters.Params parameters = new RequestConverters.Params(request);
    parameters.withIndicesOptions(getSettingsRequest.indicesOptions());
    parameters.withLocal(getSettingsRequest.local());
    parameters.withIncludeDefaults(getSettingsRequest.includeDefaults());
    parameters.withMasterTimeout(getSettingsRequest.masterNodeTimeout());
    return request;
}
Also used : ExplainRequest(org.elasticsearch.action.explain.ExplainRequest) GetMappingsRequest(org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest) SearchTemplateRequest(org.elasticsearch.script.mustache.SearchTemplateRequest) DeleteRequest(org.elasticsearch.action.delete.DeleteRequest) IndexRequest(org.elasticsearch.action.index.IndexRequest) DeleteByQueryRequest(org.elasticsearch.index.reindex.DeleteByQueryRequest) FieldCapabilitiesRequest(org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest) CountRequest(org.elasticsearch.client.core.CountRequest) IndexTemplatesExistRequest(org.elasticsearch.client.indices.IndexTemplatesExistRequest) GetStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest) GetRequest(org.elasticsearch.action.get.GetRequest) RankEvalRequest(org.elasticsearch.index.rankeval.RankEvalRequest) GetAliasesRequest(org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest) IndicesAliasesRequest(org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest) AbstractBulkByScrollRequest(org.elasticsearch.index.reindex.AbstractBulkByScrollRequest) DeleteIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest) ClusterHealthRequest(org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest) GetSettingsRequest(org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest) PutStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest) ClearScrollRequest(org.elasticsearch.action.search.ClearScrollRequest) PutIndexTemplateRequest(org.elasticsearch.client.indices.PutIndexTemplateRequest) DeleteStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest) MultiGetRequest(org.elasticsearch.action.get.MultiGetRequest) SearchRequest(org.elasticsearch.action.search.SearchRequest) OpenIndexRequest(org.elasticsearch.action.admin.indices.open.OpenIndexRequest) MultiSearchRequest(org.elasticsearch.action.search.MultiSearchRequest) CreateIndexRequest(org.elasticsearch.action.admin.indices.create.CreateIndexRequest) RefreshRequest(org.elasticsearch.action.admin.indices.refresh.RefreshRequest) UpdateByQueryRequest(org.elasticsearch.index.reindex.UpdateByQueryRequest) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) GetIndexRequest(org.elasticsearch.action.admin.indices.get.GetIndexRequest) GetIndexTemplatesRequest(org.elasticsearch.client.indices.GetIndexTemplatesRequest) GetFieldMappingsRequest(org.elasticsearch.client.indices.GetFieldMappingsRequest) UpdateRequest(org.elasticsearch.action.update.UpdateRequest) DocWriteRequest(org.elasticsearch.action.DocWriteRequest) Request(org.elasticsearch.client.Request) AnalyzeRequest(org.elasticsearch.client.indices.AnalyzeRequest) CloseIndexRequest(org.elasticsearch.action.admin.indices.close.CloseIndexRequest) RethrottleRequest(org.elasticsearch.client.RethrottleRequest) FlushRequest(org.elasticsearch.action.admin.indices.flush.FlushRequest) PutMappingRequest(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest) SearchScrollRequest(org.elasticsearch.action.search.SearchScrollRequest) BulkRequest(org.elasticsearch.action.bulk.BulkRequest) ReindexRequest(org.elasticsearch.index.reindex.ReindexRequest)

Example 10 with GetSettingsRequest

use of org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest in project spring-data-elasticsearch by spring-projects.

the class ReactiveIndexTemplate method getSettings.

@Override
public Mono<Settings> getSettings(boolean includeDefaults) {
    String indexName = getIndexCoordinates().getIndexName();
    GetSettingsRequest request = requestFactory.getSettingsRequest(indexName, includeDefaults);
    return Mono.from(operations.executeWithIndicesClient(client -> client.getSettings(request))).map(getSettingsResponse -> ResponseConverter.fromSettingsResponse(getSettingsResponse, indexName));
}
Also used : GetSettingsRequest(org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest)

Aggregations

GetSettingsRequest (org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest)15 GetSettingsResponse (org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse)8 IOException (java.io.IOException)3 DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)3 DocWriteRequest (org.elasticsearch.action.DocWriteRequest)2 IndicesAliasesRequest (org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest)2 GetAliasesRequest (org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest)2 CloseIndexRequest (org.elasticsearch.action.admin.indices.close.CloseIndexRequest)2 CreateIndexRequest (org.elasticsearch.action.admin.indices.create.CreateIndexRequest)2 FlushRequest (org.elasticsearch.action.admin.indices.flush.FlushRequest)2 GetIndexRequest (org.elasticsearch.action.admin.indices.get.GetIndexRequest)2 GetMappingsRequest (org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest)2 PutMappingRequest (org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest)2 OpenIndexRequest (org.elasticsearch.action.admin.indices.open.OpenIndexRequest)2 RefreshRequest (org.elasticsearch.action.admin.indices.refresh.RefreshRequest)2 DeleteIndexTemplateRequest (org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest)2 BulkRequest (org.elasticsearch.action.bulk.BulkRequest)2 FieldCapabilitiesRequest (org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest)2 MultiGetRequest (org.elasticsearch.action.get.MultiGetRequest)2 ObjectObjectCursor (com.carrotsearch.hppc.cursors.ObjectObjectCursor)1