Examples of FetchSourceContext


Examples of org.elasticsearch.search.fetch.source.FetchSourceContext

            for (Symbol output : outputs) {
                process(output, context);
            }
            if (!context.needWholeSource) {
                if (context.fields.isEmpty()) {
                    context.searchContext.fetchSourceContext(new FetchSourceContext(false));
                } else {
                    Set<String> fields = StringUtils.commonAncestors(context.fields);
                    context.searchContext.fetchSourceContext(
                            new FetchSourceContext(fields.toArray(new String[fields.size()])));
                }
            }
        }
View Full Code Here

Examples of org.elasticsearch.search.fetch.source.FetchSourceContext

        }
        for (Symbol symbol : node.sortSymbols()) {
            extractors.add(VISITOR.process(symbol, ctx));
        }

        final FetchSourceContext fsc = new FetchSourceContext(ctx.fields());
        final SettableFuture<QueryResult> result = SettableFuture.create();
        results = Arrays.<ListenableFuture<QueryResult>>asList(result);
        if (node.ids().size() > 1) {
            MultiGetRequest multiGetRequest = prepareMultiGetRequest(node, fsc);
            transportAction = multiGetAction;
View Full Code Here

Examples of org.elasticsearch.search.fetch.source.FetchSourceContext

        String[] fields = generateRandomStringArray(arraySize, stringSize, true);

        long version = Math.abs(randomLong());
        VersionType versionType = RandomPicks.randomFrom(new Random(), VersionType.values());

        FetchSourceContext fetchSourceContext;
        switch (randomIntBetween(0, 3)) {
            case 0 :
                fetchSourceContext = new FetchSourceContext(randomBoolean());
                break;
            case 1 :
                fetchSourceContext = new FetchSourceContext(generateRandomStringArray(arraySize, stringSize, true));
                break;
            case 2 :
                fetchSourceContext = new FetchSourceContext(generateRandomStringArray(arraySize, stringSize, true),
                        generateRandomStringArray(arraySize, stringSize, true));
                break;
            default:
                fetchSourceContext = null;
                break;
View Full Code Here

Examples of org.elasticsearch.search.fetch.source.FetchSourceContext

        assertEquals(items.size(), 3);
        for (MultiGetRequest.Item item : items) {
            assertThat(item.index(), is("test"));
            assertThat(item.type(), is("type"));
            FetchSourceContext fetchSource = item.fetchSourceContext();
            switch (item.id()) {
                case "1" :
                    assertThat(fetchSource.fetchSource(), is(false));
                    break;
                case "2" :
                    assertThat(fetchSource.fetchSource(), is(true));
                    assertThat(fetchSource.includes(), is(new String[]{"field3", "field4"}));
                    break;
                case "3" :
                    assertThat(fetchSource.fetchSource(), is(true));
                    assertThat(fetchSource.includes(), is(new String[]{"user"}));
                    assertThat(fetchSource.excludes(), is(new String[]{"user.location"}));
                    break;
                default:
                    fail("item with id: " + item.id() + " is not 1, 2 or 3");
                    break;
            }
View Full Code Here

Examples of org.elasticsearch.search.fetch.source.FetchSourceContext

                        searchSourceBuilder.field(field);
                    }
                }
            }
        }
        FetchSourceContext fetchSourceContext = FetchSourceContext.parseFromRestRequest(request);
        if (fetchSourceContext != null) {
            if (searchSourceBuilder == null) {
                searchSourceBuilder = new SearchSourceBuilder();
            }
            searchSourceBuilder.fetchSource(fetchSourceContext);
View Full Code Here

Examples of org.elasticsearch.search.fetch.source.FetchSourceContext

            if (randomBoolean()) {
                item.version(randomIntBetween(1, Integer.MAX_VALUE));
                item.versionType(randomFrom(VersionType.values()));
            }
            if (randomBoolean()) {
                item.fetchSourceContext(new FetchSourceContext(randomBoolean()));
            }
            multiGetShardRequest.add(0, item);
        }

        BytesStreamOutput out = new BytesStreamOutput();
View Full Code Here

Examples of org.elasticsearch.search.fetch.source.FetchSourceContext

    /**
     * Indicates whether the response should contain the stored _source.
     * @return this for chaining
     */
    public GetRequestBuilder setFetchSource(boolean fetch) {
        FetchSourceContext context = request.fetchSourceContext();
        if (context == null) {
            request.fetchSourceContext(new FetchSourceContext(fetch));
        }
        else {
            context.fetchSource(fetch);
        }
        return this;
    }
View Full Code Here

Examples of org.elasticsearch.search.fetch.source.FetchSourceContext

     * will automatically turn on source fetching.
     *
     * @return this for chaining
     */
    public GetRequestBuilder setTransformSource(boolean transform) {
        FetchSourceContext context = request.fetchSourceContext();
        if (context == null) {
            context = new FetchSourceContext(true);
            request.fetchSourceContext(context);
        }
        context.transformSource(transform);
        return this;
    }
View Full Code Here

Examples of org.elasticsearch.search.fetch.source.FetchSourceContext

     *
     * @param includes An optional list of include (optionally wildcarded) pattern to filter the returned _source
     * @param excludes An optional list of exclude (optionally wildcarded) pattern to filter the returned _source
     */
    public GetRequestBuilder setFetchSource(@Nullable String[] includes, @Nullable String[] excludes) {
        FetchSourceContext context = request.fetchSourceContext();
        if (context == null) {
            request.fetchSourceContext(new FetchSourceContext(includes, excludes));
        }
        else {
            context.fetchSource(true);
            context.includes(includes);
            context.excludes(excludes);
        }
        return this;
    }
View Full Code Here

Examples of org.elasticsearch.search.fetch.source.FetchSourceContext

            }
            if (this.routing() != null) {
                builder.field("_routing", this.routing());
            }
            if (this.fetchSourceContext() != null) {
                FetchSourceContext source = this.fetchSourceContext();
                String[] includes = source.includes();
                String[] excludes = source.excludes();
                if (includes.length == 0 && excludes.length == 0) {
                    builder.field("_source", source.fetchSource());
                } else if (includes.length > 0 && excludes.length == 0) {
                    builder.array("_source", source.includes());
                } else if (excludes.length > 0) {
                    builder.startObject("_source");
                    if (includes.length > 0) {
                        builder.array("includes", source.includes());
                    }
                    builder.array("excludes", source.excludes());
                    builder.endObject();
                }
            }
            if (this.version() != Versions.MATCH_ANY) {
                builder.field("_version", this.version());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.