本文整理汇总了Java中org.elasticsearch.common.xcontent.XContentBuilder.string方法的典型用法代码示例。如果您正苦于以下问题:Java XContentBuilder.string方法的具体用法?Java XContentBuilder.string怎么用?Java XContentBuilder.string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.xcontent.XContentBuilder
的用法示例。
在下文中一共展示了XContentBuilder.string方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filter
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
/**
* Associates a filter to the alias
*/
public Alias filter(QueryBuilder filterBuilder) {
if (filterBuilder == null) {
this.filter = null;
return this;
}
try {
XContentBuilder builder = XContentFactory.jsonBuilder();
filterBuilder.toXContent(builder, ToXContent.EMPTY_PARAMS);
builder.close();
this.filter = builder.string();
return this;
} catch (IOException e) {
throw new ElasticsearchGenerationException("Failed to build json for alias request", e);
}
}
示例2: executeGet
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected GetResponse executeGet(GetRequest getRequest) {
assertThat(indexedShapeToReturn, notNullValue());
assertThat(indexedShapeId, notNullValue());
assertThat(indexedShapeType, notNullValue());
assertThat(getRequest.id(), equalTo(indexedShapeId));
assertThat(getRequest.type(), equalTo(indexedShapeType));
String expectedShapeIndex = indexedShapeIndex == null ? GeoShapeQueryBuilder.DEFAULT_SHAPE_INDEX_NAME : indexedShapeIndex;
assertThat(getRequest.index(), equalTo(expectedShapeIndex));
String expectedShapePath = indexedShapePath == null ? GeoShapeQueryBuilder.DEFAULT_SHAPE_FIELD_NAME : indexedShapePath;
String json;
try {
XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
builder.startObject();
builder.field(expectedShapePath, indexedShapeToReturn);
builder.endObject();
json = builder.string();
} catch (IOException ex) {
throw new ElasticsearchException("boom", ex);
}
return new GetResponse(new GetResult(indexedShapeIndex, indexedShapeType, indexedShapeId, 0, true, new BytesArray(json), null));
}
示例3: toString
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public String toString() {
try {
XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
builder.startObject();
toXContent(builder, EMPTY_PARAMS);
builder.endObject();
return builder.string();
} catch (IOException e) {
return "{ \"error\" : \"" + e.getMessage() + "\"}";
}
}
示例4: toString
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public synchronized String toString() {
try {
XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
builder.startObject();
toXContent(builder, EMPTY_PARAMS);
builder.endObject();
return builder.string();
} catch (IOException e) {
return "{ \"error\" : \"" + e.getMessage() + "\"}";
}
}
示例5: toJsonString
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
/**
* Returns a JSON version of this exception for debugging.
*/
public String toJsonString() {
try {
XContentBuilder json = XContentFactory.jsonBuilder().prettyPrint();
json.startObject();
toXContent(json, ToXContent.EMPTY_PARAMS);
json.endObject();
return json.string();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例6: toString
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public String toString() {
try {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.prettyPrint();
toXContent(builder, EMPTY_PARAMS);
return builder.string();
} catch (Exception e) {
throw new ElasticsearchException("Failed to build xcontent.", e);
}
}
示例7: toString
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public String toString() {
try {
XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
builder.startObject();
suggest.toXContent(builder, EMPTY_PARAMS);
builder.endObject();
return builder.string();
} catch (IOException e) {
return "{ \"error\" : \"" + e.getMessage() + "\"}";
}
}
示例8: toString
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public String toString() {
try {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.prettyPrint();
toXContent(builder, EMPTY_PARAMS);
return builder.string();
} catch (Exception e) {
return "{ \"error\" : \"" + ExceptionsHelper.detailedMessage(e) + "\"}";
}
}
示例9: filter
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
public AliasAction filter(QueryBuilder queryBuilder) {
if (queryBuilder == null) {
this.filter = null;
return this;
}
try {
XContentBuilder builder = XContentFactory.jsonBuilder();
queryBuilder.toXContent(builder, ToXContent.EMPTY_PARAMS);
builder.close();
this.filter = builder.string();
return this;
} catch (IOException e) {
throw new ElasticsearchGenerationException("Failed to build json for alias request", e);
}
}
示例10: toString
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
/**
* Return a {@link String} that is the json representation of the provided
* {@link ToXContent}.
*/
public static String toString(ToXContent toXContent) {
try {
XContentBuilder builder = JsonXContent.contentBuilder();
toXContent.toXContent(builder, ToXContent.EMPTY_PARAMS);
return builder.string();
} catch (IOException e) {
throw new AssertionError("Cannot happen", e);
}
}
示例11: filter
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
public static CompressedXContent filter(QueryBuilder filterBuilder) throws IOException {
XContentBuilder builder = XContentFactory.jsonBuilder();
filterBuilder.toXContent(builder, ToXContent.EMPTY_PARAMS);
builder.close();
return new CompressedXContent(builder.string());
}