本文整理匯總了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());
}