org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequestBuilder Java Examples

The following examples show how to use org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequestBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseClient.java    From elasticsearch-helper with Apache License 2.0 6 votes vote down vote up
public String resolveMostRecentIndex(String alias) {
    if (client() == null) {
        return alias;
    }
    if (alias == null) {
        return null;
    }
    GetAliasesRequestBuilder getAliasesRequestBuilder = new GetAliasesRequestBuilder(client(), GetAliasesAction.INSTANCE);
    GetAliasesResponse getAliasesResponse = getAliasesRequestBuilder.setAliases(alias).execute().actionGet();
    Pattern pattern = Pattern.compile("^(.*?)(\\d+)$");
    Set<String> indices = new TreeSet<>(Collections.reverseOrder());
    for (ObjectCursor<String> indexName : getAliasesResponse.getAliases().keys()) {
        Matcher m = pattern.matcher(indexName.value);
        if (m.matches()) {
            if (alias.equals(m.group(1))) {
                indices.add(indexName.value);
            }
        }
    }
    return indices.isEmpty() ? alias : indices.iterator().next();
}
 
Example #2
Source File: BaseClient.java    From elasticsearch-helper with Apache License 2.0 5 votes vote down vote up
public String resolveAlias(String alias) {
    if (client() == null) {
        return alias;
    }
    GetAliasesRequestBuilder getAliasesRequestBuilder = new GetAliasesRequestBuilder(client(), GetAliasesAction.INSTANCE);
    GetAliasesResponse getAliasesResponse = getAliasesRequestBuilder.setAliases(alias).execute().actionGet();
    if (!getAliasesResponse.getAliases().isEmpty()) {
        return getAliasesResponse.getAliases().keys().iterator().next().value;
    }
    return alias;
}
 
Example #3
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public GetAliasesRequestBuilder prepareGetAliases(String... aliases) {
    return new GetAliasesRequestBuilder(this, GetAliasesAction.INSTANCE, aliases);
}
 
Example #4
Source File: ElasticsearchClusterRunner.java    From elasticsearch-cluster-runner with Apache License 2.0 4 votes vote down vote up
public GetAliasesResponse getAlias(final String alias, final BuilderCallback<GetAliasesRequestBuilder> builder) {
    return builder.apply(client().admin().indices().prepareGetAliases(alias)).execute().actionGet();
}
 
Example #5
Source File: BaseClient.java    From elasticsearch-helper with Apache License 2.0 4 votes vote down vote up
public Map<String,String> getAliasFilters(String alias) {
    GetAliasesRequestBuilder getAliasesRequestBuilder = new GetAliasesRequestBuilder(client(), GetAliasesAction.INSTANCE);
    return getFilters(getAliasesRequestBuilder.setIndices(resolveAlias(alias)).execute().actionGet());
}
 
Example #6
Source File: BaseClient.java    From elasticsearch-helper with Apache License 2.0 4 votes vote down vote up
public Map<String,String> getIndexFilters(String index) {
    GetAliasesRequestBuilder getAliasesRequestBuilder = new GetAliasesRequestBuilder(client(), GetAliasesAction.INSTANCE);
    return getFilters(getAliasesRequestBuilder.setIndices(index).execute().actionGet());
}
 
Example #7
Source File: IndicesAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Get specific index aliases that exists in particular indices and / or by name.
 */
GetAliasesRequestBuilder prepareGetAliases(String... aliases);