Package org.elasticsearch.action.support

Examples of org.elasticsearch.action.support.IndicesOptions


        MultiSearchRequest multiSearchRequest = new MultiSearchRequest();
        multiSearchRequest.listenerThreaded(false);

        String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
        String[] types = Strings.splitStringByCommaToArray(request.param("type"));
        IndicesOptions indicesOptions = IndicesOptions.fromRequest(request, multiSearchRequest.indicesOptions());
        multiSearchRequest.add(RestActions.getRestContent(request), request.contentUnsafe(), indices, types, request.param("search_type"), request.param("routing"), indicesOptions, allowExplicitIndex);

        client.multiSearch(multiSearchRequest, new RestToXContentListener<MultiSearchResponse>(channel));
    }
View Full Code Here


                .put(indexBuilder("foobar").putAlias(AliasMetaData.builder("foofoobar")))
                .put(indexBuilder("foofoo-closed").state(IndexMetaData.State.CLOSE))
                .put(indexBuilder("foofoo").putAlias(AliasMetaData.builder("barbaz")));
        MetaData md = mdBuilder.build();

        IndicesOptions lenientExpand = IndicesOptions.fromOptions(true, true, true, true);
        IndicesOptions[] indicesOptions = new IndicesOptions[]{ IndicesOptions.lenientExpandOpen(), lenientExpand};

        for (IndicesOptions options : indicesOptions) {
            String[] results = md.concreteIndices(options, "foo");
            assertEquals(1, results.length);
View Full Code Here

                .put(indexBuilder("foobar"))
                .put(indexBuilder("foofoo-closed").state(IndexMetaData.State.CLOSE))
                .put(indexBuilder("foofoo").putAlias(AliasMetaData.builder("barbaz")));
        MetaData md = mdBuilder.build();

        IndicesOptions expandOpen = IndicesOptions.fromOptions(true, false, true, false);
        IndicesOptions expand = IndicesOptions.fromOptions(true, false, true, true);
        IndicesOptions[] indicesOptions = new IndicesOptions[]{expandOpen, expand};

        for (IndicesOptions options : indicesOptions) {
            String[] results = md.concreteIndices(options, "foo");
            assertEquals(1, results.length);
View Full Code Here

                .put(indexBuilder("bar"))
                .put(indexBuilder("foobar").putAlias(AliasMetaData.builder("barbaz")));
        MetaData md = mdBuilder.build();

        // Only closed
        IndicesOptions options = IndicesOptions.fromOptions(false, true, false, true);
        String[] results = md.concreteIndices(options, Strings.EMPTY_ARRAY);
        assertEquals(1, results.length);
        assertEquals("foo", results[0]);

        results = md.concreteIndices(options, "foo*");
 
View Full Code Here

                .put(indexBuilder("foofoo").putAlias(AliasMetaData.builder("barbaz")));
        MetaData md = mdBuilder.build();

        //ignore unavailable and allow no indices
        {
            IndicesOptions noExpandLenient = IndicesOptions.fromOptions(true, true, false, false);

            String[] results = md.concreteIndices(noExpandLenient, "baz*");
            assertThat(results, emptyArray());

            results = md.concreteIndices(noExpandLenient, "foo", "baz*");
            assertEquals(1, results.length);
            assertEquals("foo", results[0]);

            results = md.concreteIndices(noExpandLenient, "foofoobar");
            assertEquals(2, results.length);
            assertThat(results, arrayContainingInAnyOrder("foo", "foobar"));
        }

        //ignore unavailable but don't allow no indices
        {
            IndicesOptions noExpandDisallowEmpty = IndicesOptions.fromOptions(true, false, false, false);

            try {
                md.concreteIndices(noExpandDisallowEmpty, "baz*");
                fail();
            } catch (IndexMissingException e) {
                assertThat(e.index().name(), equalTo("baz*"));
            }

            String[] results = md.concreteIndices(noExpandDisallowEmpty, "foo", "baz*");
            assertEquals(1, results.length);
            assertEquals("foo", results[0]);

            results = md.concreteIndices(noExpandDisallowEmpty, "foofoobar");
            assertEquals(2, results.length);
            assertThat(results, arrayContainingInAnyOrder("foo", "foobar"));
        }

        //error on unavailable but allow no indices
        {
            IndicesOptions noExpandErrorUnavailable = IndicesOptions.fromOptions(false, true, false, false);

            String[] results = md.concreteIndices(noExpandErrorUnavailable, "baz*");
            assertThat(results, emptyArray());

            try {
                md.concreteIndices(noExpandErrorUnavailable, "foo", "baz*");
                fail();
            } catch (IndexMissingException e) {
                assertThat(e.index().name(), equalTo("baz*"));
            }

            results = md.concreteIndices(noExpandErrorUnavailable, "foofoobar");
            assertEquals(2, results.length);
            assertThat(results, arrayContainingInAnyOrder("foo", "foobar"));
        }

        //error on both unavailable and no indices
        {
            IndicesOptions noExpandStrict = IndicesOptions.fromOptions(false, false, false, false);

            try {
                md.concreteIndices(noExpandStrict, "baz*");
                fail();
            } catch (IndexMissingException e) {
View Full Code Here

    }

    @Test
    public void testIndexOptions_emptyCluster() {
        MetaData md = MetaData.builder().build();
        IndicesOptions options = IndicesOptions.strictExpandOpen();

        String[] results = md.concreteIndices(options, Strings.EMPTY_ARRAY);
        assertThat(results, emptyArray());
        try {
            md.concreteIndices(options, "foo");
View Full Code Here

        int numIndices = randomInt(10);
        String[] indices = new String[numIndices];
        for (int j = 0; j < indices.length; j++) {
            indices[j] = randomAsciiOfLength(randomIntBetween(1, 10));
        }
        IndicesOptions indicesOptions = randomFrom(indicesOptionsValues);
        return new OriginalIndices(indices, indicesOptions);
    }
View Full Code Here

            } else if (token == XContentParser.Token.START_ARRAY) {
                header.put(currentFieldName, parseArray(parser));
            }
        }

        IndicesOptions defaultOptions = indicesOptions;
        boolean ignoreUnavailable = defaultOptions.ignoreUnavailable();
        boolean allowNoIndices = defaultOptions.allowNoIndices();
        boolean expandWildcardsOpen = defaultOptions.expandWildcardsOpen();
        boolean expandWildcardsClosed = defaultOptions.expandWildcardsClosed();

        if (header.containsKey("id")) {
            GetRequest getRequest = new GetRequest(globalIndex);
            percolateRequest.getRequest(getRequest);
            for (Map.Entry<String, Object> entry : header.entrySet()) {
View Full Code Here

            if (routing != null) {
                searchRequest.routing(routing);
            }
            searchRequest.searchType(searchType);

            IndicesOptions defaultOptions = IndicesOptions.strictExpandOpenAndForbidClosed();
            boolean ignoreUnavailable = defaultOptions.ignoreUnavailable();
            boolean allowNoIndices = defaultOptions.allowNoIndices();
            boolean expandWildcardsOpen = defaultOptions.expandWildcardsOpen();
            boolean expandWildcardsClosed = defaultOptions.expandWildcardsClosed();

            // now parse the action
            if (nextMarker - from > 0) {
                try (XContentParser parser = xContent.createParser(data.slice(from, nextMarker - from))) {
                    // Move to START_OBJECT, if token is null, its an empty data
View Full Code Here

    }

    @Override
    protected ClusterBlockException checkBlock(IndicesExistsRequest request, ClusterState state) {
        //make sure through indices options that the concrete indices call never throws IndexMissingException
        IndicesOptions indicesOptions = IndicesOptions.fromOptions(true, true, request.indicesOptions().expandWildcardsOpen(), request.indicesOptions().expandWildcardsClosed());
        return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA, clusterService.state().metaData().concreteIndices(indicesOptions, request.indices()));
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.support.IndicesOptions

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.