当前位置: 首页>>代码示例>>Java>>正文


Java MultiGetRequest.preference方法代码示例

本文整理汇总了Java中org.elasticsearch.action.get.MultiGetRequest.preference方法的典型用法代码示例。如果您正苦于以下问题:Java MultiGetRequest.preference方法的具体用法?Java MultiGetRequest.preference怎么用?Java MultiGetRequest.preference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.action.get.MultiGetRequest的用法示例。


在下文中一共展示了MultiGetRequest.preference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareRequest

import org.elasticsearch.action.get.MultiGetRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    MultiGetRequest multiGetRequest = new MultiGetRequest();
    multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh()));
    multiGetRequest.preference(request.param("preference"));
    multiGetRequest.realtime(request.paramAsBoolean("realtime", multiGetRequest.realtime()));
    if (request.param("fields") != null) {
        throw new IllegalArgumentException("The parameter [fields] is no longer supported, " +
            "please use [stored_fields] to retrieve stored fields or _source filtering if the field is not stored");
    }
    String[] sFields = null;
    String sField = request.param("stored_fields");
    if (sField != null) {
        sFields = Strings.splitStringByCommaToArray(sField);
    }

    FetchSourceContext defaultFetchSource = FetchSourceContext.parseFromRestRequest(request);
    try (XContentParser parser = request.contentOrSourceParamParser()) {
        multiGetRequest.add(request.param("index"), request.param("type"), sFields, defaultFetchSource,
            request.param("routing"), parser, allowExplicitIndex);
    }

    return channel -> client.multiGet(multiGetRequest, new RestToXContentListener<>(channel));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:RestMultiGetAction.java

示例2: handleRequest

import org.elasticsearch.action.get.MultiGetRequest; //导入方法依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception {
    MultiGetRequest multiGetRequest = new MultiGetRequest();
    multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh()));
    multiGetRequest.preference(request.param("preference"));
    multiGetRequest.realtime(request.paramAsBoolean("realtime", null));
    multiGetRequest.ignoreErrorsOnGeneratedFields(request.paramAsBoolean("ignore_errors_on_generated_fields", false));

    String[] sFields = null;
    String sField = request.param("fields");
    if (sField != null) {
        sFields = Strings.splitStringByCommaToArray(sField);
    }

    FetchSourceContext defaultFetchSource = FetchSourceContext.parseFromRestRequest(request);
    multiGetRequest.add(request.param("index"), request.param("type"), sFields, defaultFetchSource, request.param("routing"), RestActions.getRestContent(request), allowExplicitIndex);

    client.multiGet(multiGetRequest, new RestToXContentListener<MultiGetResponse>(channel));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:RestMultiGetAction.java

示例3: toMultiSearchRequest

import org.elasticsearch.action.get.MultiGetRequest; //导入方法依赖的package包/类
protected MultiSearchRequest toMultiSearchRequest(final RestRequest request) throws Exception {

        final MultiGetRequest multiGetRequest = new MultiGetRequest();
        multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh()));
        multiGetRequest.preference(request.param("preference"));
        multiGetRequest.realtime(request.paramAsBoolean("realtime", null));
        multiGetRequest.ignoreErrorsOnGeneratedFields(request.paramAsBoolean("ignore_errors_on_generated_fields", false));

        String[] sFields = null;
        final String sField = request.param("fields");
        if (sField != null) {
            sFields = Strings.splitStringByCommaToArray(sField);
        }

        final FetchSourceContext defaultFetchSource = FetchSourceContext.parseFromRestRequest(request);
        multiGetRequest.add(request.param("index"), request.param("type"), sFields, defaultFetchSource, request.param("routing"),
                RestActions.getRestContent(request),
                settings.getAsBoolean(AbstractACRestFilter.REST_ACTION_MULTI_ALLOW_EXPLICIT_INDEX, true));

        final MultiSearchRequest msearch = new MultiSearchRequest();
        msearch.copyContextFrom(request);

        for (final Iterator<Item> iterator = multiGetRequest.iterator(); iterator.hasNext();) {
            final Item item = iterator.next();

            final SearchRequest st = new SearchRequest();
            st.routing(item.routing());
            st.indices(item.indices());
            st.types(item.type());
            st.preference(request.param("preference"));
            st.source(SearchSourceBuilder.searchSource().query(new IdsQueryBuilder(item.type()).addIds(item.id())));
            msearch.add(st);
        }

        return msearch;

    }
 
开发者ID:petalmd,项目名称:armor,代码行数:38,代码来源:AbstractACRestFilter.java


注:本文中的org.elasticsearch.action.get.MultiGetRequest.preference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。