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


Java RestRequest.hasParam方法代码示例

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


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

示例1: prepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest(request.param("name"));
    if (request.hasParam("template")) {
        DEPRECATION_LOGGER.deprecated("Deprecated parameter[template] used, replaced by [index_patterns]");
        putRequest.patterns(Collections.singletonList(request.param("template")));
    } else {
        putRequest.patterns(Arrays.asList(request.paramAsStringArray("index_patterns", Strings.EMPTY_ARRAY)));
    }
    putRequest.order(request.paramAsInt("order", putRequest.order()));
    putRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRequest.masterNodeTimeout()));
    putRequest.create(request.paramAsBoolean("create", false));
    putRequest.cause(request.param("cause", ""));
    putRequest.source(request.content(), request.getXContentType());
    return channel -> client.admin().indices().putTemplate(putRequest, new AcknowledgedRestListener<>(channel));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:RestPutIndexTemplateAction.java

示例2: prepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    IndicesShardStoresRequest indicesShardStoresRequest = new IndicesShardStoresRequest(
            Strings.splitStringByCommaToArray(request.param("index")));
    if (request.hasParam("status")) {
        indicesShardStoresRequest.shardStatuses(Strings.splitStringByCommaToArray(request.param("status")));
    }
    indicesShardStoresRequest.indicesOptions(IndicesOptions.fromRequest(request, indicesShardStoresRequest.indicesOptions()));
    return channel ->
        client.admin()
            .indices()
            .shardStores(indicesShardStoresRequest, new RestBuilderListener<IndicesShardStoresResponse>(channel) {
                @Override
                public RestResponse buildResponse(
                    IndicesShardStoresResponse response,
                    XContentBuilder builder) throws Exception {
                    builder.startObject();
                    response.toXContent(builder, request);
                    builder.endObject();
                    return new BytesRestResponse(OK, builder);
                }
            });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:RestIndicesShardStoresAction.java

示例3: parseRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
/**
 * Parses a {@link RestRequest} body and returns a {@link MultiSearchRequest}
 */
public static MultiSearchRequest parseRequest(RestRequest restRequest, boolean allowExplicitIndex) throws IOException {
    MultiSearchRequest multiRequest = new MultiSearchRequest();
    if (restRequest.hasParam("max_concurrent_searches")) {
        multiRequest.maxConcurrentSearchRequests(restRequest.paramAsInt("max_concurrent_searches", 0));
    }

    parseMultiLineRequest(restRequest, multiRequest.indicesOptions(), allowExplicitIndex, (searchRequest, parser) -> {
        try {
            final QueryParseContext queryParseContext = new QueryParseContext(parser);
            searchRequest.source(SearchSourceBuilder.fromXContent(queryParseContext));
            multiRequest.add(searchRequest);
        } catch (IOException e) {
            throw new ElasticsearchParseException("Exception when parsing search request", e);
        }
    });

    return multiRequest;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RestMultiSearchAction.java

示例4: doCatRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
protected RestChannelConsumer doCatRequest(final RestRequest request, NodeClient client) {
    final String matchPattern = request.hasParam("name") ? request.param("name") : null;
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().metaData(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    return channel -> client.admin().cluster().state(clusterStateRequest, new RestResponseListener<ClusterStateResponse>(channel) {
        @Override
        public RestResponse buildResponse(ClusterStateResponse clusterStateResponse) throws Exception {
            return RestTable.buildResponse(buildTable(request, clusterStateResponse, matchPattern), channel);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:RestTemplatesAction.java

示例5: prepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
	// final String func = request.hasParam("func") ? request.param("func") : "con";
	// final String funcAction = request.hasParam("action") ? request.param("action") : "jquery.js";

	final String action = request.hasParam("action") ? request.param("action") : "show";

	RestChannelConsumer rr = null;

	if ("show".equals(action)) {
		rr = returnConsloe(request, client);
	} else {

		if (action.endsWith("js") || action.endsWith("css")) {
			rr = returnRs(request, client, action);
		}

	}

	return rr;
}
 
开发者ID:psfu,项目名称:es-sp-console,代码行数:22,代码来源:RestConsoleAction.java

示例6: buildRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
protected ReindexRequest buildRequest(RestRequest request) throws IOException {
    if (request.hasParam("pipeline")) {
        throw new IllegalArgumentException("_reindex doesn't support [pipeline] as a query parmaeter. "
                + "Specify it in the [dest] object instead.");
    }
    ReindexRequest internal = new ReindexRequest(new SearchRequest(), new IndexRequest());
    try (XContentParser parser = request.contentParser()) {
        PARSER.parse(parser, internal, null);
    }
    return internal;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:RestReindexAction.java

示例7: prepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    ClusterHealthRequest clusterHealthRequest = clusterHealthRequest(Strings.splitStringByCommaToArray(request.param("index")));
    clusterHealthRequest.local(request.paramAsBoolean("local", clusterHealthRequest.local()));
    clusterHealthRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterHealthRequest.masterNodeTimeout()));
    clusterHealthRequest.timeout(request.paramAsTime("timeout", clusterHealthRequest.timeout()));
    String waitForStatus = request.param("wait_for_status");
    if (waitForStatus != null) {
        clusterHealthRequest.waitForStatus(ClusterHealthStatus.valueOf(waitForStatus.toUpperCase(Locale.ROOT)));
    }
    clusterHealthRequest.waitForNoRelocatingShards(
            request.paramAsBoolean("wait_for_no_relocating_shards", clusterHealthRequest.waitForNoRelocatingShards()));
    if (request.hasParam("wait_for_relocating_shards")) {
        // wait_for_relocating_shards has been removed in favor of wait_for_no_relocating_shards
        throw new IllegalArgumentException("wait_for_relocating_shards has been removed, " +
                                           "use wait_for_no_relocating_shards [true/false] instead");
    }
    String waitForActiveShards = request.param("wait_for_active_shards");
    if (waitForActiveShards != null) {
        clusterHealthRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards));
    }
    clusterHealthRequest.waitForNodes(request.param("wait_for_nodes", clusterHealthRequest.waitForNodes()));
    if (request.param("wait_for_events") != null) {
        clusterHealthRequest.waitForEvents(Priority.valueOf(request.param("wait_for_events").toUpperCase(Locale.ROOT)));
    }
    return channel -> client.admin().cluster().health(clusterHealthRequest, new RestStatusToXContentListener<>(channel));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:RestClusterHealthAction.java

示例8: parseVersion

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
public static long parseVersion(RestRequest request) {
    if (request.hasParam("version")) {
        return request.paramAsLong("version", Versions.MATCH_ANY);
    }
    String ifMatch = request.header("If-Match");
    if (ifMatch != null) {
        return Long.parseLong(ifMatch);
    }
    return Versions.MATCH_ANY;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:RestActions.java

示例9: doCatRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
protected RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    final GetAliasesRequest getAliasesRequest = request.hasParam("alias") ?
            new GetAliasesRequest(request.param("alias")) :
            new GetAliasesRequest();
    getAliasesRequest.local(request.paramAsBoolean("local", getAliasesRequest.local()));

    return channel -> client.admin().indices().getAliases(getAliasesRequest, new RestResponseListener<GetAliasesResponse>(channel) {
        @Override
        public RestResponse buildResponse(GetAliasesResponse response) throws Exception {
            Table tab = buildTable(request, response);
            return RestTable.buildResponse(tab, channel);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:RestAliasAction.java

示例10: convertMainResponse

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
static BytesRestResponse convertMainResponse(MainResponse response, RestRequest request, XContentBuilder builder) throws IOException {
    RestStatus status = response.isAvailable() ? RestStatus.OK : RestStatus.SERVICE_UNAVAILABLE;

    // Default to pretty printing, but allow ?pretty=false to disable
    if (request.hasParam("pretty") == false) {
        builder.prettyPrint().lfAtEnd();
    }
    response.toXContent(builder, request);
    return new BytesRestResponse(status, builder);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:RestMainAction.java

示例11: prepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request,
                                          final NodeClient client) throws IOException {
    if (request.hasContentOrSourceParam() && request.hasParam("fields")) {
        throw new IllegalArgumentException("can't specify a request body and [fields] request parameter, " +
            "either specify a request body or the [fields] request parameter");
    }

    final FieldStatsRequest fieldStatsRequest = new FieldStatsRequest();
    fieldStatsRequest.indices(Strings.splitStringByCommaToArray(request.param("index")));
    fieldStatsRequest.indicesOptions(IndicesOptions.fromRequest(request, fieldStatsRequest.indicesOptions()));
    fieldStatsRequest.level(request.param("level", FieldStatsRequest.DEFAULT_LEVEL));
    if (request.hasContentOrSourceParam()) {
        try (XContentParser parser = request.contentOrSourceParamParser()) {
            fieldStatsRequest.source(parser);
        }
    } else {
        fieldStatsRequest.setFields(Strings.splitStringByCommaToArray(request.param("fields")));
    }

    return channel -> client.fieldStats(fieldStatsRequest, new RestBuilderListener<FieldStatsResponse>(channel) {
        @Override
        public RestResponse buildResponse(FieldStatsResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            buildBroadcastShardsHeader(builder, request, response);

            builder.startObject("indices");
            for (Map.Entry<String, Map<String, FieldStats>> entry1 :
                    response.getIndicesMergedFieldStats().entrySet()) {
                builder.startObject(entry1.getKey());
                builder.startObject("fields");
                for (Map.Entry<String, FieldStats> entry2 : entry1.getValue().entrySet()) {
                    builder.field(entry2.getKey());
                    entry2.getValue().toXContent(builder, request);
                }
                builder.endObject();
                builder.endObject();
            }
            builder.endObject();
            if (response.getConflicts().size() > 0) {
                builder.startObject("conflicts");
                for (Map.Entry<String, String> entry : response.getConflicts().entrySet()) {
                    builder.field(entry.getKey(), entry.getValue());
                }
                builder.endObject();
            }
            builder.endObject();
            return new BytesRestResponse(RestStatus.OK, builder);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:52,代码来源:RestFieldStatsAction.java

示例12: prepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest();
    indicesStatsRequest.indicesOptions(IndicesOptions.fromRequest(request, indicesStatsRequest.indicesOptions()));
    indicesStatsRequest.indices(Strings.splitStringByCommaToArray(request.param("index")));
    indicesStatsRequest.types(Strings.splitStringByCommaToArray(request.param("types")));

    Set<String> metrics = Strings.splitStringByCommaToSet(request.param("metric", "_all"));
    // short cut, if no metrics have been specified in URI
    if (metrics.size() == 1 && metrics.contains("_all")) {
        indicesStatsRequest.all();
    } else if (metrics.contains("_all")) {
        throw new IllegalArgumentException(
            String.format(Locale.ROOT,
                "request [%s] contains _all and individual metrics [%s]",
                request.path(),
                request.param("metric")));
    } else {
        indicesStatsRequest.clear();
        // use a sorted set so the unrecognized parameters appear in a reliable sorted order
        final Set<String> invalidMetrics = new TreeSet<>();
        for (final String metric : metrics) {
            final Consumer<IndicesStatsRequest> consumer = METRICS.get(metric);
            if (consumer != null) {
                consumer.accept(indicesStatsRequest);
            } else {
                invalidMetrics.add(metric);
            }
        }

        if (!invalidMetrics.isEmpty()) {
            throw new IllegalArgumentException(unrecognized(request, invalidMetrics, METRICS.keySet(), "metric"));
        }
    }

    if (request.hasParam("groups")) {
        indicesStatsRequest.groups(Strings.splitStringByCommaToArray(request.param("groups")));
    }

    if (request.hasParam("types")) {
        indicesStatsRequest.types(Strings.splitStringByCommaToArray(request.param("types")));
    }

    if (indicesStatsRequest.completion() && (request.hasParam("fields") || request.hasParam("completion_fields"))) {
        indicesStatsRequest.completionFields(
                request.paramAsStringArray("completion_fields", request.paramAsStringArray("fields", Strings.EMPTY_ARRAY)));
    }

    if (indicesStatsRequest.fieldData() && (request.hasParam("fields") || request.hasParam("fielddata_fields"))) {
        indicesStatsRequest.fieldDataFields(
                request.paramAsStringArray("fielddata_fields", request.paramAsStringArray("fields", Strings.EMPTY_ARRAY)));
    }

    if (indicesStatsRequest.segments()) {
        indicesStatsRequest.includeSegmentFileSizes(request.paramAsBoolean("include_segment_file_sizes", false));
    }

    return channel -> client.admin().indices().stats(indicesStatsRequest, new RestBuilderListener<IndicesStatsResponse>(channel) {
        @Override
        public RestResponse buildResponse(IndicesStatsResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            buildBroadcastShardsHeader(builder, request, response);
            response.toXContent(builder, request);
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:69,代码来源:RestIndicesStatsAction.java

示例13: prepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    String[] nodeIds;
    Set<String> metrics;

    // special case like /_nodes/os (in this case os are metrics and not the nodeId)
    // still, /_nodes/_local (or any other node id) should work and be treated as usual
    // this means one must differentiate between allowed metrics and arbitrary node ids in the same place
    if (request.hasParam("nodeId") && !request.hasParam("metrics")) {
        Set<String> metricsOrNodeIds = Strings.splitStringByCommaToSet(request.param("nodeId", "_all"));
        boolean isMetricsOnly = ALLOWED_METRICS.containsAll(metricsOrNodeIds);
        if (isMetricsOnly) {
            nodeIds = new String[]{"_all"};
            metrics = metricsOrNodeIds;
        } else {
            nodeIds = metricsOrNodeIds.toArray(new String[]{});
            metrics = Sets.newHashSet("_all");
        }
    } else {
        nodeIds = Strings.splitStringByCommaToArray(request.param("nodeId", "_all"));
        metrics = Strings.splitStringByCommaToSet(request.param("metrics", "_all"));
    }

    final NodesInfoRequest nodesInfoRequest = new NodesInfoRequest(nodeIds);
    nodesInfoRequest.timeout(request.param("timeout"));
    // shortcut, don't do checks if only all is specified
    if (metrics.size() == 1 && metrics.contains("_all")) {
        nodesInfoRequest.all();
    } else {
        nodesInfoRequest.clear();
        nodesInfoRequest.settings(metrics.contains("settings"));
        nodesInfoRequest.os(metrics.contains("os"));
        nodesInfoRequest.process(metrics.contains("process"));
        nodesInfoRequest.jvm(metrics.contains("jvm"));
        nodesInfoRequest.threadPool(metrics.contains("thread_pool"));
        nodesInfoRequest.transport(metrics.contains("transport"));
        nodesInfoRequest.http(metrics.contains("http"));
        nodesInfoRequest.plugins(metrics.contains("plugins"));
        nodesInfoRequest.ingest(metrics.contains("ingest"));
        nodesInfoRequest.indices(metrics.contains("indices"));
    }

    settingsFilter.addFilterSettingParams(request);

    return channel -> client.admin().cluster().nodesInfo(nodesInfoRequest, new NodesResponseRestListener<>(channel));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:47,代码来源:RestNodesInfoAction.java

示例14: prepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    final ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest();
    clusterStateRequest.indicesOptions(IndicesOptions.fromRequest(request, clusterStateRequest.indicesOptions()));
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    final String[] indices = Strings.splitStringByCommaToArray(request.param("indices", "_all"));
    boolean isAllIndicesOnly = indices.length == 1 && "_all".equals(indices[0]);
    if (!isAllIndicesOnly) {
        clusterStateRequest.indices(indices);
    }

    if (request.hasParam("metric")) {
        EnumSet<ClusterState.Metric> metrics = ClusterState.Metric.parseString(request.param("metric"), true);
        // do not ask for what we do not need.
        clusterStateRequest.nodes(metrics.contains(ClusterState.Metric.NODES) || metrics.contains(ClusterState.Metric.MASTER_NODE));
        /*
         * there is no distinction in Java api between routing_table and routing_nodes, it's the same info set over the wire, one single
         * flag to ask for it
         */
        clusterStateRequest.routingTable(
                metrics.contains(ClusterState.Metric.ROUTING_TABLE) || metrics.contains(ClusterState.Metric.ROUTING_NODES));
        clusterStateRequest.metaData(metrics.contains(ClusterState.Metric.METADATA));
        clusterStateRequest.blocks(metrics.contains(ClusterState.Metric.BLOCKS));
        clusterStateRequest.customs(metrics.contains(ClusterState.Metric.CUSTOMS));
    }
    settingsFilter.addFilterSettingParams(request);

    return channel -> client.admin().cluster().state(clusterStateRequest, new RestBuilderListener<ClusterStateResponse>(channel) {
        @Override
        public RestResponse buildResponse(ClusterStateResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            builder.field(Fields.CLUSTER_NAME, response.getClusterName().value());
            builder.byteSizeField(Fields.CLUSTER_STATE_SIZE_IN_BYTES, Fields.CLUSTER_STATE_SIZE, response.getTotalCompressedSize());
            response.getState().toXContent(builder, request);
            builder.endObject();
            return new BytesRestResponse(RestStatus.OK, builder);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:42,代码来源:RestClusterStateAction.java

示例15: buildDisplayHeaders

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
static List<DisplayHeader> buildDisplayHeaders(Table table, RestRequest request) {
    List<DisplayHeader> display = new ArrayList<>();
    if (request.hasParam("h")) {
        Set<String> headers = expandHeadersFromRequest(table, request);

        for (String possibility : headers) {
            DisplayHeader dispHeader = null;

            if (table.getAsMap().containsKey(possibility)) {
                dispHeader = new DisplayHeader(possibility, possibility);
            } else {
                for (Table.Cell headerCell : table.getHeaders()) {
                    String aliases = headerCell.attr.get("alias");
                    if (aliases != null) {
                        for (String alias : Strings.splitStringByCommaToArray(aliases)) {
                            if (possibility.equals(alias)) {
                                dispHeader = new DisplayHeader(headerCell.value.toString(), alias);
                                break;
                            }
                        }
                    }
                }
            }

            if (dispHeader != null && checkOutputTimestamp(dispHeader, request)) {
                // We know we need the header asked for:
                display.add(dispHeader);

                // Look for accompanying sibling column
                Table.Cell hcell = table.getHeaderMap().get(dispHeader.name);
                String siblingFlag = hcell.attr.get("sibling");
                if (siblingFlag != null) {
                    // ...link the sibling and check that its flag is set
                    String sibling = siblingFlag + "." + dispHeader.name;
                    Table.Cell c = table.getHeaderMap().get(sibling);
                    if (c != null && request.paramAsBoolean(siblingFlag, false)) {
                        display.add(new DisplayHeader(c.value.toString(), siblingFlag + "." + dispHeader.display));
                    }
                }
            }
        }
    } else {
        for (Table.Cell cell : table.getHeaders()) {
            String d = cell.attr.get("default");
            if (Booleans.parseBoolean(d, true) && checkOutputTimestamp(cell.value.toString(), request)) {
                display.add(new DisplayHeader(cell.value.toString(), cell.value.toString()));
            }
        }
    }
    return display;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:52,代码来源:RestTable.java


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