本文整理汇总了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);
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}