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


Java XContentBuilder.endArray方法代碼示例

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


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

示例1: testEvaluateArrayElementObject

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void testEvaluateArrayElementObject() throws Exception {
    XContentBuilder xContentBuilder = randomXContentBuilder();
    xContentBuilder.startObject();
    xContentBuilder.startObject("field1");
    xContentBuilder.startArray("array1");
    xContentBuilder.startObject();
    xContentBuilder.field("element", "value1");
    xContentBuilder.endObject();
    xContentBuilder.startObject();
    xContentBuilder.field("element", "value2");
    xContentBuilder.endObject();
    xContentBuilder.endArray();
    xContentBuilder.endObject();
    xContentBuilder.endObject();
    ObjectPath objectPath = ObjectPath.createFromXContent(xContentBuilder.contentType().xContent(), xContentBuilder.bytes());
    Object object = objectPath.evaluate("field1.array1.1.element");
    assertThat(object, instanceOf(String.class));
    assertThat(object, equalTo("value2"));
    object = objectPath.evaluate("");
    assertThat(object, notNullValue());
    assertThat(object, instanceOf(Map.class));
    assertThat(((Map<String, Object>)object).containsKey("field1"), equalTo(true));
    object = objectPath.evaluate("field1.array2.1.element");
    assertThat(object, nullValue());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:27,代碼來源:ObjectPathTests.java

示例2: coordinatesToXcontent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
/**
 * builds an array of coordinates to a {@link XContentBuilder}
 *
 * @param builder builder to use
 * @param closed repeat the first point at the end of the array if it's not already defines as last element of the array
 * @return the builder
 */
protected XContentBuilder coordinatesToXcontent(XContentBuilder builder, boolean closed) throws IOException {
    builder.startArray();
    for(Coordinate coord : coordinates) {
        toXContent(builder, coord);
    }
    if(closed) {
        Coordinate start = coordinates.get(0);
        Coordinate end = coordinates.get(coordinates.size()-1);
        if(start.x != end.x || start.y != end.y) {
            toXContent(builder, coordinates.get(0));
        }
    }
    builder.endArray();
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:23,代碼來源:CoordinateCollection.java

示例3: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    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();
    builder.endObject();
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,代碼來源:PendingClusterTasksResponse.java

示例4: toXContent

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

    if (this.metaData != null) {
        builder.field("meta", this.metaData);
    }
    builder.startObject(type);

    if (!overrideBucketsPath() && bucketsPaths != null) {
        builder.startArray(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName());
        for (String path : bucketsPaths) {
            builder.value(path);
        }
        builder.endArray();
    }

    internalXContent(builder, params);

    builder.endObject();

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

示例5: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    if (hasRecoveries()) {
        for (String index : shardRecoveryStates.keySet()) {
            List<RecoveryState> recoveryStates = shardRecoveryStates.get(index);
            if (recoveryStates == null || recoveryStates.size() == 0) {
                continue;
            }
            builder.startObject(index);
            builder.startArray("shards");
            for (RecoveryState recoveryState : recoveryStates) {
                builder.startObject();
                recoveryState.toXContent(builder, params);
                builder.endObject();
            }
            builder.endArray();
            builder.endObject();
        }
    }
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:22,代碼來源:RecoveryResponse.java

示例6: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.field(FIELD_TYPE, TYPE.shapename);
    builder.startArray(FIELD_COORDINATES);
    toXContent(builder, topLeft);
    toXContent(builder, bottomRight);
    builder.endArray();
    return builder.endObject();
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:11,代碼來源:EnvelopeBuilder.java

示例7: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(NAME);
    builder.field(TIE_BREAKER_FIELD.getPreferredName(), tieBreaker);
    builder.startArray(QUERIES_FIELD.getPreferredName());
    for (QueryBuilder queryBuilder : queries) {
        queryBuilder.toXContent(builder, params);
    }
    builder.endArray();
    printBoostAndQueryName(builder);
    builder.endObject();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,代碼來源:DisMaxQueryBuilder.java

示例8: convert

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
private static XContentBuilder convert(RestChannel channel, RestStatus status, Throwable t) throws IOException {
    XContentBuilder builder = channel.newErrorBuilder().startObject();
    if (t == null) {
        builder.field("error", "unknown");
    } else if (channel.detailedErrorsEnabled()) {
        final ToXContent.Params params;
        if (channel.request().paramAsBoolean("error_trace", !ElasticsearchException.REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT)) {
            params =  new ToXContent.DelegatingMapParams(Collections.singletonMap(ElasticsearchException.REST_EXCEPTION_SKIP_STACK_TRACE, "false"), channel.request());
        } else {
            if (status.getStatus() < 500) {
                SUPPRESSED_ERROR_LOGGER.debug("{} Params: {}", t, channel.request().path(), channel.request().params());
            } else {
                SUPPRESSED_ERROR_LOGGER.warn("{} Params: {}", t, channel.request().path(), channel.request().params());
            }
            params = channel.request();
        }
        builder.field("error");
        builder.startObject();
        final ElasticsearchException[] rootCauses = ElasticsearchException.guessRootCauses(t);
        builder.field("root_cause");
        builder.startArray();
        for (ElasticsearchException rootCause : rootCauses){
            builder.startObject();
            rootCause.toXContent(builder, new ToXContent.DelegatingMapParams(Collections.singletonMap(ElasticsearchException.REST_EXCEPTION_SKIP_CAUSE, "true"), params));
            builder.endObject();
        }
        builder.endArray();

        ElasticsearchException.toXContent(builder, params, t);
        builder.endObject();
    } else {
        builder.field("error", simpleMessage(t));
    }
    builder.field("status", status.getStatus());
    builder.endObject();
    return builder;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:38,代碼來源:BytesRestResponse.java

示例9: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
static void toXContent(XContentBuilder builder, Accountable tree) throws IOException {
    builder.startObject();
    builder.field(Fields.DESCRIPTION, tree.toString());
    builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, new ByteSizeValue(tree.ramBytesUsed()));
    Collection<Accountable> children = tree.getChildResources();
    if (children.isEmpty() == false) {
        builder.startArray(Fields.CHILDREN);
        for (Accountable child : children) {
            toXContent(builder, child);
        }
        builder.endArray();
    }
    builder.endObject();
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:15,代碼來源:IndicesSegmentResponse.java

示例10: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.field(FIELD_TYPE, TYPE.shapename);
    builder.startArray(FIELD_COORDINATES);
    coordinatesArray(builder, params);
    builder.endArray();
    builder.endObject();
    return builder;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:11,代碼來源:BasePolygonBuilder.java

示例11: doXContentBody

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
    builder.field("doc_count", subsetSize);
    builder.startArray(CommonFields.BUCKETS);
    for (InternalSignificantTerms.Bucket bucket : buckets) {
        //There is a condition (presumably when only one shard has a bucket?) where reduce is not called
        // and I end up with buckets that contravene the user's min_doc_count criteria in my reducer
        if (bucket.subsetDf >= minDocCount) {
            bucket.toXContent(builder, params);
        }
    }
    builder.endArray();
    return builder;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:15,代碼來源:SignificantStringTerms.java

示例12: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startArray("explanations");
    for (RerouteExplanation explanation : explanations) {
        explanation.toXContent(builder, params);
    }
    builder.endArray();
    return builder;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:10,代碼來源:RoutingExplanations.java

示例13: nodeDecisionsToXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
/**
 * Generates X-Content for the node-level decisions, creating the outer "node_decisions" object
 * in which they are serialized.
 */
public XContentBuilder nodeDecisionsToXContent(List<NodeAllocationResult> nodeDecisions, XContentBuilder builder, Params params)
    throws IOException {

    if (nodeDecisions != null && nodeDecisions.isEmpty() == false) {
        builder.startArray("node_allocation_decisions");
        {
            for (NodeAllocationResult explanation : nodeDecisions) {
                explanation.toXContent(builder, params);
            }
        }
        builder.endArray();
    }
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,代碼來源:AbstractAllocationDecision.java

示例14: toXContentWithoutObject

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
public XContentBuilder toXContentWithoutObject(XContentBuilder builder, Params params) throws IOException {
    builder.field(Fields.NAME, this.name);
    builder.startArray(AnalyzeResponse.Fields.TOKENS);
    for (AnalyzeResponse.AnalyzeToken token : tokens) {
        token.toXContent(builder, params);
    }
    builder.endArray();
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,代碼來源:DetailAnalyzeResponse.java

示例15: doXContentBody

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
    builder.field(InternalTerms.DOC_COUNT_ERROR_UPPER_BOUND_FIELD_NAME, docCountError);
    builder.field(SUM_OF_OTHER_DOC_COUNTS, otherDocCount);
    builder.startArray(CommonFields.BUCKETS);
    for (InternalTerms.Bucket bucket : buckets) {
        bucket.toXContent(builder, params);
    }
    builder.endArray();
    return builder;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:12,代碼來源:DoubleTerms.java


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