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


Java RestChannel.newBuilder方法代码示例

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


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

示例1: buildXContentBuilder

import org.elasticsearch.rest.RestChannel; //导入方法依赖的package包/类
public static RestResponse buildXContentBuilder(Table table, RestChannel channel) throws Exception {
    RestRequest request = channel.request();
    XContentBuilder builder = channel.newBuilder();
    List<DisplayHeader> displayHeaders = buildDisplayHeaders(table, request);

    builder.startArray();
    List<Integer> rowOrder = getRowOrder(table, request);
    for (Integer row : rowOrder) {
        builder.startObject();
        for (DisplayHeader header : displayHeaders) {
            builder.field(header.display, renderValue(request, table.getAsMap().get(header.name).get(row).value));
        }
        builder.endObject();
    }
    builder.endArray();
    return new BytesRestResponse(RestStatus.OK, builder);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:RestTable.java

示例2: prepareRequest

import org.elasticsearch.rest.RestChannel; //导入方法依赖的package包/类
/**
 *@description 插件的业务处理方法
 *@time 创建时间:2017年8月31日下午4:21:52
 *@param request
 *@param client
 *@return
 *@throws IOException
 *@author dzn
 */
@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client)
        throws IOException {
    LOGGER.info("My Rest Action Handler");  
    Map<String, String> params = request.params();
    LOGGER.info("Param : {}", params);
    final String actionParam = request.param("action");
    LOGGER.info("actionParam : {}", actionParam);
    RestChannelConsumer res = new RestChannelConsumer(){
        @Override
        public void accept(RestChannel channel) throws Exception {
            XContentBuilder builder = channel.newBuilder();
            builder.startObject();  
            //返回给页面的信息
            builder.field("message", "This is my first plugin");
            if(null != actionParam && actionParam.trim().length() > 0){
                builder.field("接收到参数actionParam", actionParam);
            }
            builder.endObject();  
            channel.sendResponse(new BytesRestResponse(RestStatus.OK, builder));
        }
    };
    return res;
}
 
开发者ID:SnailFastGo,项目名称:elasticsearch_plugin,代码行数:34,代码来源:MyRestAction.java

示例3: send

import org.elasticsearch.rest.RestChannel; //导入方法依赖的package包/类
public static void send(final RestChannel channel, final RestStatus status, final String arg) {
    try {

        final XContentBuilder builder = channel.newBuilder();

        builder.startObject();
        builder.field("status", status.getStatus());

        if (arg != null && !arg.isEmpty()) {
            builder.field("message", arg);
        }

        builder.endObject();
        channel.sendResponse(new BytesRestResponse(status, builder));
    } catch (final Exception e) {
        log.error("Failed to send a response.", e);
        try {
            channel.sendResponse(new BytesRestResponse(channel, e));
        } catch (final IOException e1) {
            log.error("Failed to send a failure response.", e1);
        }
    }
}
 
开发者ID:petalmd,项目名称:armor,代码行数:24,代码来源:SecurityUtil.java

示例4: sendQuery

import org.elasticsearch.rest.RestChannel; //导入方法依赖的package包/类
private void sendQuery(int from, final RestRequest request,final RestChannel channel, SearchResponse response, List<String> fieldNames, boolean showMeta){
	XContentBuilder builder;
	try {
		builder = channel.newBuilder();								
		Search.buildQuery(from, builder, response, logger, fieldNames, showMeta);								
		channel.sendResponse(new BytesRestResponse(RestStatus.OK, builder));
	} catch (IOException e) {
		sendFailure(request, channel, e);
	}
}
 
开发者ID:huangchen007,项目名称:elasticsearch-rest-command,代码行数:11,代码来源:JobRestHandler.java

示例5: sendTimeline

import org.elasticsearch.rest.RestChannel; //导入方法依赖的package包/类
private void sendTimeline(final RestRequest request,final RestChannel channel, SearchResponse response){
	XContentBuilder builder;
	try {
		builder = channel.newBuilder();							
		Search.buildTimeline(builder, response, logger);	
		channel.sendResponse(new BytesRestResponse(response.status(), builder));
	} catch (IOException e) {
		sendFailure(request, channel, e);
	}
}
 
开发者ID:huangchen007,项目名称:elasticsearch-rest-command,代码行数:11,代码来源:JobRestHandler.java


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