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


Java XContentBuilderString类代码示例

本文整理汇总了Java中org.elasticsearch.common.xcontent.XContentBuilderString的典型用法代码示例。如果您正苦于以下问题:Java XContentBuilderString类的具体用法?Java XContentBuilderString怎么用?Java XContentBuilderString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: respForbidden

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
public static void respForbidden(final HttpRequest request, final HttpChannel channel, ESLogger logger) {
	XContentBuilder builder;
	try {
		builder = ContentBuilder.restContentBuilder(request);
		builder.startObject()  
        .field(new XContentBuilderString("status"), RestStatus.FORBIDDEN)  
        .field(new XContentBuilderString("message"),  
                "You are not login")  
        .endObject();
		
		channel.sendResponse(  
                new BytesRestResponse(RestStatus.FORBIDDEN, builder)); 
	} catch (IOException e) {
		if (logger != null) {
			logger.error("Get Exception in checkPermission: " + e.getMessage());
		}
		e.printStackTrace();
	}
}
 
开发者ID:ghostboyzone,项目名称:ESAuthPlugin,代码行数:20,代码来源:ContentBuilder.java

示例2: respIpForbidden

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
public static void respIpForbidden(final HttpRequest request, final HttpChannel channel, ESLogger logger) {
	XContentBuilder builder;
	try {
		builder = ContentBuilder.restContentBuilder(request);
		builder.startObject()  
        .field(new XContentBuilderString("status"), RestStatus.FORBIDDEN)  
        .field(new XContentBuilderString("message"),  
                "Your ip is not in auth list")  
        .endObject();
		
		channel.sendResponse(  
                new BytesRestResponse(RestStatus.FORBIDDEN, builder)); 
	} catch (IOException e) {
		if (logger != null) {
			logger.error("Get Exception in checkIpPermission: " + e.getMessage());
		}
		e.printStackTrace();
	}
}
 
开发者ID:ghostboyzone,项目名称:ESAuthPlugin,代码行数:20,代码来源:ContentBuilder.java

示例3: doXContentBody

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
@Override
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
    builder.startArray(CommonFields.BUCKETS);
    for (Bucket bucket : buckets) {
        builder.startObject();
        builder.field(CommonFields.KEY, bucket.getKeyAsText());
        builder.field(CommonFields.DOC_COUNT, bucket.getDocCount());
        Set<String> geohashGridsString = new HashSet<String>(bucket.geohashesList.size());
        for (long geohash: bucket.geohashesList) {
            geohashGridsString.add(GeoHashUtils.toString(geohash));
        }
        builder.array(new XContentBuilderString("geohash_grids"), geohashGridsString);
        builder.field(new XContentBuilderString("cluster_center"));
        ShapeBuilder.newPoint(bucket.getClusterCenter().getLon(), bucket.getClusterCenter().getLat()).toXContent(builder,params);
        ((InternalAggregations) bucket.getAggregations()).toXContentInternal(builder, params);
        builder.endObject();
    }
    builder.endArray();
    return builder;
}
 
开发者ID:opendatasoft,项目名称:elasticsearch-aggregation-geoclustering,代码行数:21,代码来源:InternalGeoHashClustering.java

示例4: handleRequest

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
@Override
protected void handleRequest(final RestRequest request, final RestChannel channel, Client client) throws Exception {
	
	// logger.info("Path:" + request.path() + "uri:" + request.uri());
	
	XContentBuilder builder = ContentBuilder.restContentBuilder(request);
	
	if (request.path().equals("/_auth/config_reload")) {
		this.config.reloadConfig();
		
		builder.startObject()  
        .field(new XContentBuilderString("status"), RestStatus.OK)  
        .field(new XContentBuilderString("message"),  
                "config reload success")  
        .endObject();
		channel.sendResponse(  
                new BytesRestResponse(RestStatus.OK, builder));
	} else if (request.path().equals("/_auth/config_show")) {
		builder.startObject() 
		.field("open_auth", this.config.getSet().getAsBoolean("open_auth", false))
		.field("username", config.getSet().get("username", "").trim())
		.field("password", config.getSet().get("password", "").trim())
		
		.field("open_ip_auth", this.config.getSet().getAsBoolean("open_ip_auth", false))
		.field("ip_auth_list", this.config.getSet().getAsArray("ip_auth_list", new String[0]))
        .endObject();
		channel.sendResponse(  
                new BytesRestResponse(RestStatus.OK, builder));
	}
	
	//super.handleRequest(request, channel);
}
 
开发者ID:ghostboyzone,项目名称:ESAuthPlugin,代码行数:33,代码来源:ESAuthPluginAction.java

示例5: addIntMinMax

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
private void addIntMinMax(XContentBuilderString field, int min, int max, double avg, XContentBuilder builder) throws IOException {
    builder.startObject(field);
    builder.field(Fields.MIN, min);
    builder.field(Fields.MAX, max);
    builder.field(Fields.AVG, avg);
    builder.endObject();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:ClusterStatsIndices.java

示例6: addDoubleMinMax

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
private void addDoubleMinMax(XContentBuilderString field, double min, double max, double avg, XContentBuilder builder) throws IOException {
    builder.startObject(field);
    builder.field(Fields.MIN, min);
    builder.field(Fields.MAX, max);
    builder.field(Fields.AVG, avg);
    builder.endObject();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:ClusterStatsIndices.java

示例7: mapping

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
/**
 * Gets the mappings for the given schema and table as a formatted json string.
 */
public String mapping(String schema, String table) throws IOException {
  if(USE_EXTERNAL_ES5){
    return "";
  }

  GetMappingsResponse response = getElasticInternalClient().admin().indices().prepareGetMappings(schema).setTypes(table).execute().actionGet();

  XContentBuilder builder = XContentFactory.jsonBuilder();
  builder.prettyPrint().lfAtEnd();

  builder.startObject();
  ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappingsByIndex = response.getMappings();
  if (mappingsByIndex.isEmpty()) {
    return "";
  }

  for (ObjectObjectCursor<String, ImmutableOpenMap<String, MappingMetaData>> indexEntry : mappingsByIndex) {
    if (indexEntry.value.isEmpty()) {
      continue;
    }
    builder.startObject(indexEntry.key, XContentBuilder.FieldCaseConversion.NONE);
    builder.startObject(new XContentBuilderString("mappings"));
    for (ObjectObjectCursor<String, MappingMetaData> typeEntry : indexEntry.value) {
      builder.field(typeEntry.key);
      builder.map(typeEntry.value.sourceAsMap());
    }
    builder.endObject();
    builder.endObject();
  }

  builder.endObject();
  return builder.string();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:37,代码来源:ElasticsearchCluster.java

示例8: array

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
public XmlXContentBuilder array(XContentBuilderString name, String... values) throws IOException {
    startArray(name);
    for (String value : values) {
        value(value);
    }
    endArray();
    return this;
}
 
开发者ID:jprante,项目名称:elasticsearch-xml,代码行数:9,代码来源:XmlXContentBuilder.java

示例9: field

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
public XmlXContentBuilder field(XContentBuilderString name) throws IOException {
    if (fieldCaseConversion == FieldCaseConversion.UNDERSCORE) {
        generator.writeFieldName(name.underscore());
    } else if (fieldCaseConversion == FieldCaseConversion.CAMELCASE) {
        generator.writeFieldName(name.camelCase());
    } else {
        generator.writeFieldName(name.underscore());
    }
    return this;
}
 
开发者ID:jprante,项目名称:elasticsearch-xml,代码行数:11,代码来源:XmlXContentBuilder.java

示例10: timeValueField

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
public XmlXContentBuilder timeValueField(XContentBuilderString rawFieldName, XContentBuilderString readableFieldName, TimeValue timeValue) throws IOException {
    if (humanReadable) {
        field(readableFieldName, timeValue.toString());
    }
    field(rawFieldName, timeValue.millis());
    return this;
}
 
开发者ID:jprante,项目名称:elasticsearch-xml,代码行数:8,代码来源:XmlXContentBuilder.java

示例11: byteSizeField

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
public XmlXContentBuilder byteSizeField(XContentBuilderString rawFieldName, XContentBuilderString readableFieldName, ByteSizeValue byteSizeValue) throws IOException {
    if (humanReadable) {
        field(readableFieldName, byteSizeValue.toString());
    }
    field(rawFieldName, byteSizeValue.bytes());
    return this;
}
 
开发者ID:jprante,项目名称:elasticsearch-xml,代码行数:8,代码来源:XmlXContentBuilder.java

示例12: handleRequest

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
@Override
public void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception{
   if (logger.isDebugEnabled()){
      logger.debug("REST S3ManageAction called");
   }
   
   String rivername = request.param("rivername");
   String command = request.param("command");
   
   String status = null;
   if (START_COMMAND.equals(command)){
      status = "STARTED";
   } else if (STOP_COMMAND.equals(command)){
      status = "STOPPED";
   }
   
   try{
      if (status != null){
         XContentBuilder xb = jsonBuilder()
            .startObject()
               .startObject("amazon-s3")
                  .field("feedname", rivername)
                  .field("status", status)
               .endObject()
            .endObject();
         client.prepareIndex("_river", rivername, "_s3status").setSource(xb).execute().actionGet();
      }
      
      XContentBuilder builder = jsonBuilder();
      builder
         .startObject()
            .field(new XContentBuilderString("ok"), true)
         .endObject();
      channel.sendResponse(new BytesRestResponse(RestStatus.OK, builder));
   } catch (IOException e) {
      onFailure(request, channel, e);
   }
}
 
开发者ID:lbroudoux,项目名称:es-amazon-s3-river,代码行数:39,代码来源:S3ManageAction.java

示例13: handleRequest

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
@Override
public void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception{
   if (logger.isDebugEnabled()){
      logger.debug("REST DriveManageAction called");
   }
   
   String rivername = request.param("rivername");
   String command = request.param("command");
   
   String status = null;
   if (START_COMMAND.equals(command)){
      status = "STARTED";
   } else if (STOP_COMMAND.equals(command)){
      status = "STOPPED";
   }
   
   try{
      if (status != null){
         XContentBuilder xb = jsonBuilder()
            .startObject()
               .startObject("google-drive")
                  .field("feedname", rivername)
                  .field("status", status)
               .endObject()
            .endObject();
         client.prepareIndex("_river", rivername, "_drivestatus").setSource(xb).execute().actionGet();
      }
      
      XContentBuilder builder = jsonBuilder();
      builder
         .startObject()
            .field(new XContentBuilderString("ok"), true)
         .endObject();
      channel.sendResponse(new BytesRestResponse(RestStatus.OK, builder));
   } catch (IOException e) {
      onFailure(request, channel, e);
   }
}
 
开发者ID:lbroudoux,项目名称:es-google-drive-river,代码行数:39,代码来源:DriveManageAction.java

示例14: Suggest

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
public Suggest(XContentBuilderString name) {
    this.name = name;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:4,代码来源:Suggest.java

示例15: readSuggest

import org.elasticsearch.common.xcontent.XContentBuilderString; //导入依赖的package包/类
public static Suggest readSuggest(XContentBuilderString name, StreamInput in) throws IOException {
    Suggest result = new Suggest(name);
    result.readFrom(in);
    return result;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:Suggest.java


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