Search in sources :

Example 26 with IndicesAdminClient

use of org.elasticsearch.client.IndicesAdminClient in project vertigo by KleeGroup.

the class AbstractESSearchServicesPlugin method logMappings.

private void logMappings(final String myIndexName) {
    final IndicesAdminClient indicesAdmin = esClient.admin().indices();
    final ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> indexMappings = indicesAdmin.prepareGetMappings(myIndexName).get().getMappings();
    for (final ObjectObjectCursor<String, ImmutableOpenMap<String, MappingMetaData>> indexMapping : indexMappings) {
        LOGGER.info("Index " + indexMapping.key + " CurrentMapping:");
        for (final ObjectObjectCursor<String, MappingMetaData> dtoMapping : indexMapping.value) {
            LOGGER.info(dtoMapping.key + " -> " + dtoMapping.value.source());
        }
    }
}
Also used : IndicesAdminClient(org.elasticsearch.client.IndicesAdminClient) ImmutableOpenMap(org.elasticsearch.common.collect.ImmutableOpenMap) MappingMetaData(org.elasticsearch.cluster.metadata.MappingMetaData)

Example 27 with IndicesAdminClient

use of org.elasticsearch.client.IndicesAdminClient in project metasfresh-webui-api by metasfresh.

the class KPIDataLoader method assertESTypesExists.

/**
 * Checks if KPI's elasticsearch Index and Type exists
 */
public KPIDataLoader assertESTypesExists() {
    final IndicesAdminClient admin = elasticsearchClient.admin().indices();
    // 
    // Check index exists
    final String esSearchIndex = kpi.getESSearchIndex();
    final GetIndexResponse indexResponse = admin.prepareGetIndex().addIndices(esSearchIndex).get();
    final List<String> indexesFound = Arrays.asList(indexResponse.getIndices());
    if (!indexesFound.contains(esSearchIndex)) {
        throw new AdempiereException("ES index '" + esSearchIndex + "' not found in " + indexesFound);
    }
    logger.debug("Indexes found: {}", indexesFound);
    // 
    // Check type exists
    final String esTypes = kpi.getESSearchTypes();
    final boolean esTypesExists = admin.prepareTypesExists(esSearchIndex).setTypes(kpi.getESSearchTypes()).get().isExists();
    if (!esTypesExists) {
        throw new AdempiereException("Elasticseatch types " + esTypes + " does not exist");
    }
    // All good
    return this;
}
Also used : GetIndexResponse(org.elasticsearch.action.admin.indices.get.GetIndexResponse) AdempiereException(org.adempiere.exceptions.AdempiereException) IndicesAdminClient(org.elasticsearch.client.IndicesAdminClient)

Aggregations

IndicesAdminClient (org.elasticsearch.client.IndicesAdminClient)27 IndicesExistsResponse (org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse)6 Test (org.junit.Test)6 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)4 IndicesAliasesResponse (org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse)3 CreateIndexResponse (org.elasticsearch.action.admin.indices.create.CreateIndexResponse)3 DeleteIndexTemplateResponse (org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateResponse)3 GetIndexTemplatesResponse (org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse)3 ImmutableOpenMap (org.elasticsearch.common.collect.ImmutableOpenMap)3 UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ElasticsearchException (org.elasticsearch.ElasticsearchException)2 IndicesAliasesRequest (org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest)2 GetAliasesResponse (org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse)2 DeleteIndexResponse (org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse)2 IndicesExistsRequest (org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest)2 GetIndexResponse (org.elasticsearch.action.admin.indices.get.GetIndexResponse)2 GetMappingsResponse (org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse)2