當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。