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


Java XContentBuilder.string方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:Alias.java

示例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));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:GeoShapeQueryBuilderTests.java

示例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() + "\"}";
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:SearchResponse.java

示例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() + "\"}";
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:RecoveryState.java

示例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);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:ScriptException.java

示例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);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:SearchAfterBuilder.java

示例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() + "\"}";
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:SuggestResponse.java

示例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) + "\"}";
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:MoreLikeThisQueryBuilder.java

示例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);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:AliasAction.java

示例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);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:Strings.java

示例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());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:IndexServiceTests.java


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