當前位置: 首頁>>代碼示例>>Java>>正文


Java RestRequest.paramAsInt方法代碼示例

本文整理匯總了Java中org.elasticsearch.rest.RestRequest.paramAsInt方法的典型用法代碼示例。如果您正苦於以下問題:Java RestRequest.paramAsInt方法的具體用法?Java RestRequest.paramAsInt怎麽用?Java RestRequest.paramAsInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.rest.RestRequest的用法示例。


在下文中一共展示了RestRequest.paramAsInt方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseSearchRequest

import org.elasticsearch.rest.RestRequest; //導入方法依賴的package包/類
/**
 * Parses the rest request on top of the SearchRequest, preserving values that are not overridden by the rest request.
 *
 * @param requestContentParser body of the request to read. This method does not attempt to read the body from the {@code request}
 *        parameter
 */
public static void parseSearchRequest(SearchRequest searchRequest, RestRequest request,
                                      XContentParser requestContentParser) throws IOException {

    if (searchRequest.source() == null) {
        searchRequest.source(new SearchSourceBuilder());
    }
    searchRequest.indices(Strings.splitStringByCommaToArray(request.param("index")));
    if (requestContentParser != null) {
        QueryParseContext context = new QueryParseContext(requestContentParser);
        searchRequest.source().parseXContent(context);
    }

    final int batchedReduceSize = request.paramAsInt("batched_reduce_size", searchRequest.getBatchedReduceSize());
    searchRequest.setBatchedReduceSize(batchedReduceSize);

    // do not allow 'query_and_fetch' or 'dfs_query_and_fetch' search types
    // from the REST layer. these modes are an internal optimization and should
    // not be specified explicitly by the user.
    String searchType = request.param("search_type");
    if ("query_and_fetch".equals(searchType) ||
            "dfs_query_and_fetch".equals(searchType)) {
        throw new IllegalArgumentException("Unsupported search type [" + searchType + "]");
    } else {
        searchRequest.searchType(searchType);
    }
    parseSearchSource(searchRequest.source(), request);
    searchRequest.requestCache(request.paramAsBoolean("request_cache", null));

    String scroll = request.param("scroll");
    if (scroll != null) {
        searchRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll")));
    }

    searchRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
    searchRequest.routing(request.param("routing"));
    searchRequest.preference(request.param("preference"));
    searchRequest.indicesOptions(IndicesOptions.fromRequest(request, searchRequest.indicesOptions()));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:45,代碼來源:RestSearchAction.java

示例2: prepareGetRequest

import org.elasticsearch.rest.RestRequest; //導入方法依賴的package包/類
private RestChannelConsumer prepareGetRequest(final RestRequest request) {
    final String index = request.param("index");
    final int from = request.paramAsInt("from", 0);
    final int size = request.paramAsInt("size", 10);
    final boolean pretty = request.paramAsBoolean("pretty", false);
    return channel -> {
        if (index == null || index.trim().length() == 0) {
            indexingProxyService.getRequestSenderInfos(from, size,
                    wrap(res -> sendResponse(channel, res, pretty), e -> sendErrorResponse(channel, e)));
        } else {
            indexingProxyService.getRequestSenderInfo(index,
                    wrap(res -> sendResponse(channel, res, pretty), e -> sendErrorResponse(channel, e)));
        }
    };
}
 
開發者ID:codelibs,項目名稱:elasticsearch-indexing-proxy,代碼行數:16,代碼來源:RestIndexingProxyProcessAction.java

示例3: prepareRequest

import org.elasticsearch.rest.RestRequest; //導入方法依賴的package包/類
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    SearchRequest countRequest = new SearchRequest(Strings.splitStringByCommaToArray(request.param("index")));
    countRequest.indicesOptions(IndicesOptions.fromRequest(request, countRequest.indicesOptions()));
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(0);
    countRequest.source(searchSourceBuilder);
    request.withContentOrSourceParamParserOrNull(parser -> {
        if (parser == null) {
            QueryBuilder queryBuilder = RestActions.urlParamsToQueryBuilder(request);
            if (queryBuilder != null) {
                searchSourceBuilder.query(queryBuilder);
            }
        } else {
            searchSourceBuilder.query(RestActions.getQueryContent(parser));
        }
    });
    countRequest.routing(request.param("routing"));
    float minScore = request.paramAsFloat("min_score", -1f);
    if (minScore != -1f) {
        searchSourceBuilder.minScore(minScore);
    }
    countRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
    countRequest.preference(request.param("preference"));

    final int terminateAfter = request.paramAsInt("terminate_after", DEFAULT_TERMINATE_AFTER);
    if (terminateAfter < 0) {
        throw new IllegalArgumentException("terminateAfter must be > 0");
    } else if (terminateAfter > 0) {
        searchSourceBuilder.terminateAfter(terminateAfter);
    }
    return channel -> client.search(countRequest, new RestBuilderListener<SearchResponse>(channel) {
        @Override
        public RestResponse buildResponse(SearchResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            if (terminateAfter != DEFAULT_TERMINATE_AFTER) {
                builder.field("terminated_early", response.isTerminatedEarly());
            }
            builder.field("count", response.getHits().getTotalHits());
            buildBroadcastShardsHeader(builder, request, response.getTotalShards(), response.getSuccessfulShards(),
                    response.getFailedShards(), response.getShardFailures());

            builder.endObject();
            return new BytesRestResponse(response.status(), builder);
        }
    });
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:47,代碼來源:RestCountAction.java

示例4: prepareGetRequest

import org.elasticsearch.rest.RestRequest; //導入方法依賴的package包/類
private RestChannelConsumer prepareGetRequest(final RestRequest request) {
    final int position = request.paramAsInt("position", -1);
    return channel -> indexingProxyService.dumpRequests(position,
            wrap(res -> channel.sendResponse(new BytesRestResponse(RestStatus.OK, res)), e -> sendErrorResponse(channel, e)));
}
 
開發者ID:codelibs,項目名稱:elasticsearch-indexing-proxy,代碼行數:6,代碼來源:RestIndexingProxyRequestAction.java


注:本文中的org.elasticsearch.rest.RestRequest.paramAsInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。