當前位置: 首頁>>代碼示例>>Java>>正文


Java XContentBuilder.endObject方法代碼示例

本文整理匯總了Java中org.elasticsearch.common.xcontent.XContentBuilder.endObject方法的典型用法代碼示例。如果您正苦於以下問題:Java XContentBuilder.endObject方法的具體用法?Java XContentBuilder.endObject怎麽用?Java XContentBuilder.endObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.common.xcontent.XContentBuilder的用法示例。


在下文中一共展示了XContentBuilder.endObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testParseDist

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
/**
 * test correct parsing of `dist` parameter, this should create builder with pre/post set to same value
 */
public void testParseDist() throws IOException {
    XContentBuilder builder = XContentFactory.jsonBuilder();
    builder.startObject();
    builder.startObject(SpanNotQueryBuilder.NAME);
    builder.field("exclude");
    spanTermQuery("description", "jumped").toXContent(builder, null);
    builder.field("include");
    spanNearQuery(QueryBuilders.spanTermQuery("description", "quick"), 1)
            .addClause(QueryBuilders.spanTermQuery("description", "fox")).toXContent(builder, null);
    builder.field("dist", 3);
    builder.endObject();
    builder.endObject();
    SpanNotQueryBuilder query = (SpanNotQueryBuilder)parseQuery(builder.string());
    assertThat(query.pre(), equalTo(3));
    assertThat(query.post(), equalTo(3));
    assertNotNull(query.includeQuery());
    assertNotNull(query.excludeQuery());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:22,代碼來源:SpanNotQueryBuilderTests.java

示例2: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.startObject(opType.getLowercase());
    if (failure == null) {
        response.innerToXContent(builder, params);
        builder.field(STATUS, response.status().getStatus());
    } else {
        builder.field(_INDEX, failure.getIndex());
        builder.field(_TYPE, failure.getType());
        builder.field(_ID, failure.getId());
        builder.field(STATUS, failure.getStatus().getStatus());
        builder.startObject(ERROR);
        ElasticsearchException.generateThrowableXContent(builder, params, failure.getCause());
        builder.endObject();
    }
    builder.endObject();
    builder.endObject();
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:21,代碼來源:BulkItemResponse.java

示例3: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(simpleName())
        .field(Fields.TYPE, CONTENT_TYPE);

    builder.field(Fields.ANALYZER, fieldType().indexAnalyzer().name());
    if (fieldType().indexAnalyzer().name().equals(fieldType().searchAnalyzer().name()) == false) {
        builder.field(Fields.SEARCH_ANALYZER.getPreferredName(), fieldType().searchAnalyzer().name());
    }
    builder.field(Fields.PAYLOADS, fieldType().analyzingSuggestLookupProvider.hasPayloads());
    builder.field(Fields.PRESERVE_SEPARATORS.getPreferredName(), fieldType().analyzingSuggestLookupProvider.getPreserveSep());
    builder.field(Fields.PRESERVE_POSITION_INCREMENTS.getPreferredName(), fieldType().analyzingSuggestLookupProvider.getPreservePositionsIncrements());
    builder.field(Fields.MAX_INPUT_LENGTH.getPreferredName(), this.maxInputLength);
    multiFields.toXContent(builder, params);

    if (fieldType().requiresContext()) {
        builder.startObject(Fields.CONTEXT);
        for (ContextMapping mapping : fieldType().getContextMapping().values()) {
            builder.value(mapping);
        }
        builder.endObject();
    }

    return builder.endObject();
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:26,代碼來源:CompletionFieldMapper.java

示例4: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields._SHARDS);
    builder.field(Fields.TOTAL, total);
    builder.field(Fields.SUCCESSFUL, successful);
    builder.field(Fields.FAILED, getFailed());
    if (failures.length > 0) {
        builder.startArray(Fields.FAILURES);
        for (Failure failure : failures) {
            failure.toXContent(builder, params);
        }
        builder.endArray();
    }
    builder.endObject();
    return builder;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:17,代碼來源:ActionWriteResponse.java

示例5: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Integer.toString(id));
    builder.field("description", description);
    builder.field("retryable", retryable);
    if (disableStatePersistence) {
        builder.field("disable_state_persistence", disableStatePersistence);
    }
    builder.startArray("levels");
    for (ClusterBlockLevel level : levels) {
        builder.value(level.name().toLowerCase(Locale.ROOT));
    }
    builder.endArray();
    builder.endObject();
    return builder;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:17,代碼來源:ClusterBlock.java

示例6: buildXContentBuilder

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
public static RestResponse buildXContentBuilder(Table table, RestChannel channel) throws Exception {
    RestRequest request = channel.request();
    XContentBuilder builder = channel.newBuilder();
    List<DisplayHeader> displayHeaders = buildDisplayHeaders(table, request);

    builder.startArray();
    for (int row = 0; row < table.getRows().size(); row++) {
        builder.startObject();
        for (DisplayHeader header : displayHeaders) {
            builder.field(header.display, renderValue(request, table.getAsMap().get(header.name).get(row).value));
        }
        builder.endObject();

    }
    builder.endArray();
    return new BytesRestResponse(RestStatus.OK, builder);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:18,代碼來源:RestTable.java

示例7: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startArray(Fields.TASKS);
    for (PendingClusterTask pendingClusterTask : this) {
        builder.startObject();
        builder.field(Fields.INSERT_ORDER, pendingClusterTask.getInsertOrder());
        builder.field(Fields.PRIORITY, pendingClusterTask.getPriority());
        builder.field(Fields.SOURCE, pendingClusterTask.getSource());
        builder.field(Fields.EXECUTING, pendingClusterTask.isExecuting());
        builder.field(Fields.TIME_IN_QUEUE_MILLIS, pendingClusterTask.getTimeInQueueInMillis());
        builder.field(Fields.TIME_IN_QUEUE, pendingClusterTask.getTimeInQueue());
        builder.endObject();
    }
    builder.endArray();
    return builder;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:17,代碼來源:PendingClusterTasksResponse.java

示例8: testHighlightingWithWildcardName

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
public void testHighlightingWithWildcardName() throws IOException {
    // test the kibana case with * as fieldname that will try highlight all fields including meta fields
    XContentBuilder mappings = jsonBuilder();
    mappings.startObject();
    mappings.startObject("type")
            .startObject("properties")
            .startObject("text")
            .field("type", "text")
            .field("analyzer", "keyword")
            .field("index_options", "offsets")
            .field("term_vector", "with_positions_offsets")
            .endObject()
            .endObject()
            .endObject();
    mappings.endObject();
    assertAcked(prepareCreate("test")
            .addMapping("type", mappings));
    client().prepareIndex("test", "type", "1")
            .setSource(jsonBuilder().startObject().field("text", "text").endObject())
            .get();
    refresh();
    for (String type : ALL_TYPES) {
        SearchResponse search = client().prepareSearch().setQuery(constantScoreQuery(matchQuery("text", "text")))
            .highlighter(new HighlightBuilder().field(new Field("*").highlighterType(type))).get();
        assertHighlight(search, 0, "text", 0, equalTo("<em>text</em>"));
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:28,代碼來源:HighlighterSearchIT.java

示例9: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.field(MovAvgPipelineAggregationBuilder.MODEL.getPreferredName(), NAME);
    builder.startObject(MovAvgPipelineAggregationBuilder.SETTINGS.getPreferredName());
    builder.field("alpha", alpha);

    builder.endObject();
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,代碼來源:EwmaModel.java

示例10: toRestRequest

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
private RestRequest toRestRequest(ClusterRerouteRequest original) throws IOException {
    Map<String, String> params = new HashMap<>();
    XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values()));
    boolean hasBody = false;
    if (randomBoolean()) {
        builder.prettyPrint();
    }
    builder.startObject();
    if (randomBoolean()) {
        params.put("dry_run", Boolean.toString(original.dryRun()));
    } else {
        hasBody = true;
        builder.field("dry_run", original.dryRun());
    }
    params.put("explain", Boolean.toString(original.explain()));
    if (false == original.timeout().equals(AcknowledgedRequest.DEFAULT_ACK_TIMEOUT) || randomBoolean()) {
        params.put("timeout", original.timeout().toString());
    }
    if (original.isRetryFailed() || randomBoolean()) {
        params.put("retry_failed", Boolean.toString(original.isRetryFailed()));
    }
    if (false == original.masterNodeTimeout().equals(MasterNodeRequest.DEFAULT_MASTER_NODE_TIMEOUT) || randomBoolean()) {
        params.put("master_timeout", original.masterNodeTimeout().toString());
    }
    if (original.getCommands() != null) {
        hasBody = true;
        original.getCommands().toXContent(builder, ToXContent.EMPTY_PARAMS);
    }
    builder.endObject();

    FakeRestRequest.Builder requestBuilder = new FakeRestRequest.Builder(xContentRegistry());
    requestBuilder.withParams(params);
    if (hasBody) {
        requestBuilder.withContent(builder.bytes(), builder.contentType());
    }
    return requestBuilder.build();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:38,代碼來源:ClusterRerouteRequestTests.java

示例11: 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:justor,項目名稱:elasticsearch_my,代碼行數:13,代碼來源:Suggest.java

示例12: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(simpleName());
    builder.field("type", mapperName);
    multiFields.toXContent(builder, params);
    builder.endObject();
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:9,代碼來源:ExternalMapper.java

示例13: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields.THREAD_POOL);
    for (ThreadPool.Info info : infos) {
        info.toXContent(builder, params);
    }
    builder.endObject();
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,代碼來源:ThreadPoolInfo.java

示例14: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(getName());
    if (seed != null) {
        builder.field("seed", seed);
    }
    builder.endObject();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:9,代碼來源:RandomScoreFunctionBuilder.java

示例15: DecayFunctionBuilder

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
/**
 * Convenience constructor that converts its parameters into json to parse on the data nodes.
 */
protected DecayFunctionBuilder(String fieldName, Object origin, Object scale, Object offset, double decay) {
    if (fieldName == null) {
        throw new IllegalArgumentException("decay function: field name must not be null");
    }
    if (scale == null) {
        throw new IllegalArgumentException("decay function: scale must not be null");
    }
    if (decay <= 0 || decay >= 1.0) {
        throw new IllegalStateException("decay function: decay must be in range 0..1!");
    }
    this.fieldName = fieldName;
    try {
        XContentBuilder builder = XContentFactory.jsonBuilder();
        builder.startObject();
        if (origin != null) {
            builder.field(ORIGIN, origin);
        }
        builder.field(SCALE, scale);
        if (offset != null) {
            builder.field(OFFSET, offset);
        }
        builder.field(DECAY, decay);
        builder.endObject();
        this.functionBytes = builder.bytes();
    } catch (IOException e) {
        throw new IllegalArgumentException("unable to build inner function object",e);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:32,代碼來源:DecayFunctionBuilder.java


注:本文中的org.elasticsearch.common.xcontent.XContentBuilder.endObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。