Package org.elasticsearch.action.admin.indices.alias

Examples of org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder


        execute(IndicesAliasesAction.INSTANCE, request, listener);
    }

    @Override
    public IndicesAliasesRequestBuilder prepareAliases() {
        return new IndicesAliasesRequestBuilder(this);
    }
View Full Code Here


        createIndex("test");

        ensureGreen();

        //invalid filter, invalid json
        IndicesAliasesRequestBuilder indicesAliasesRequestBuilder = admin().indices().prepareAliases().addAlias("test", "alias1", "abcde");
        try {
            indicesAliasesRequestBuilder.get();
            fail("put alias should have been failed due to invalid filter");
        } catch (ElasticsearchIllegalArgumentException e) {
            assertThat(e.getMessage(), equalTo("failed to parse filter for alias [alias1]"));
        }

        //valid json , invalid filter
        indicesAliasesRequestBuilder = admin().indices().prepareAliases().addAlias("test", "alias1", "{ \"test\": {} }");
        try {
            indicesAliasesRequestBuilder.get();
            fail("put alias should have been failed due to invalid filter");
        } catch (ElasticsearchIllegalArgumentException e) {
            assertThat(e.getMessage(), equalTo("failed to parse filter for alias [alias1]"));
        }
    }
View Full Code Here

        System.out.println("Number of aliases: " + numberOfAliases);

        if (numberOfAliases < BASE_ALIAS_COUNT) {
            int diff = BASE_ALIAS_COUNT - numberOfAliases;
            System.out.println("Adding " + diff + " more aliases to get to the start amount of " + BASE_ALIAS_COUNT + " aliases");
            IndicesAliasesRequestBuilder builder = client.admin().indices().prepareAliases();
            for (int i = 1; i <= diff; i++) {
                builder.addAlias(INDEX_NAME, Strings.randomBase64UUID());
                if (i % 1000 == 0) {
                    builder.execute().actionGet();
                    builder = client.admin().indices().prepareAliases();
                }
            }
            if (!builder.request().getAliasActions().isEmpty()) {
                builder.execute().actionGet();
            }
        } else if (numberOfAliases > BASE_ALIAS_COUNT) {
            IndicesAliasesRequestBuilder builder = client.admin().indices().prepareAliases();
            int diff = numberOfAliases - BASE_ALIAS_COUNT;
            System.out.println("Removing " + diff + " aliases to get to the start amount of " + BASE_ALIAS_COUNT + " aliases");
            List<AliasMetaData> aliases= client.admin().indices().prepareGetAliases("*")
                    .addIndices(INDEX_NAME)
                    .execute().actionGet().getAliases().get(INDEX_NAME);
            for (int i = 0; i <= diff; i++) {
                builder.removeAlias(INDEX_NAME, aliases.get(i).alias());
                if (i % 1000 == 0) {
                    builder.execute().actionGet();
                    builder = client.admin().indices().prepareAliases();
                }
            }
            if (!builder.request().getAliasActions().isEmpty()) {
                builder.execute().actionGet();
            }
        }

        numberOfAliases = countAliases(client);
        System.out.println("Number of aliases: " + numberOfAliases);
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.