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


Java XContentBuilder.startArray方法代碼示例

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


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

示例1: contexts

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
/**
 * Sets query contexts for completion
 * @param queryContexts named query contexts
 *                      see {@link org.elasticsearch.search.suggest.completion.context.CategoryQueryContext}
 *                      and {@link org.elasticsearch.search.suggest.completion.context.GeoQueryContext}
 */
public CompletionSuggestionBuilder contexts(Map<String, List<? extends ToXContent>> queryContexts) {
    Objects.requireNonNull(queryContexts, "contexts must not be null");
    try {
        XContentBuilder contentBuilder = XContentFactory.jsonBuilder();
        contentBuilder.startObject();
        for (Map.Entry<String, List<? extends ToXContent>> contextEntry : queryContexts.entrySet()) {
            contentBuilder.startArray(contextEntry.getKey());
            for (ToXContent queryContext : contextEntry.getValue()) {
                queryContext.toXContent(contentBuilder, EMPTY_PARAMS);
            }
            contentBuilder.endArray();
        }
        contentBuilder.endObject();
        return contexts(contentBuilder);
    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:25,代碼來源:CompletionSuggestionBuilder.java

示例2: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(DisMaxQueryParser.NAME);
    if (tieBreaker != -1) {
        builder.field("tie_breaker", tieBreaker);
    }
    if (boost != -1) {
        builder.field("boost", boost);
    }
    if (queryName != null) {
        builder.field("_name", queryName);
    }
    builder.startArray("queries");
    for (QueryBuilder queryBuilder : queries) {
        queryBuilder.toXContent(builder, params);
    }
    builder.endArray();
    builder.endObject();
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:20,代碼來源:DisMaxQueryBuilder.java

示例3: 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

示例4: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
    if (clauses.isEmpty()) {
        throw new IllegalArgumentException("Must have at least one clause when building a spanOr query");
    }
    builder.startObject(SpanOrQueryParser.NAME);
    builder.startArray("clauses");
    for (SpanQueryBuilder clause : clauses) {
        clause.toXContent(builder, params);
    }
    builder.endArray();
    if (boost != -1) {
        builder.field("boost", boost);
    }
    if (queryName != null) {
        builder.field("_name", queryName);
    }
    builder.endObject();
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:20,代碼來源:SpanOrQueryBuilder.java

示例5: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    writeSharedAttributes(builder);
    builder.startArray(Fields.ROWS);
    if (rows != null) {
        for (Object[] row : rows) {
            builder.startArray();
            for (int j = 0, len = cols().length; j < len; j++) {
                builder.value(row[j]);
            }
            builder.endArray();
        }
    }
    builder.endArray();
    builder.field(Fields.ROWCOUNT, rowCount());
    builder.endObject();
    return builder;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:20,代碼來源:SQLResponse.java

示例6: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.startArray(Fields.DOCS);
    for (MultiTermVectorsItemResponse response : responses) {
        if (response.isFailed()) {
            builder.startObject();
            Failure failure = response.getFailure();
            builder.field(Fields._INDEX, failure.getIndex());
            builder.field(Fields._TYPE, failure.getType());
            builder.field(Fields._ID, failure.getId());
            ElasticsearchException.generateFailureXContent(builder, params, failure.getCause(), true);
            builder.endObject();
        } else {
            TermVectorsResponse getResponse = response.getResponse();
            getResponse.toXContent(builder, params);
        }
    }
    builder.endArray();
    builder.endObject();
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:23,代碼來源:MultiTermVectorsResponse.java

示例7: 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

示例8: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.timeValueField(Fields.MAX_UPTIME_IN_MILLIS, Fields.MAX_UPTIME, maxUptime);
    builder.startArray(Fields.VERSIONS);
    for (ObjectIntCursor<JvmVersion> v : versions) {
        builder.startObject();
        builder.field(Fields.VERSION, v.key.version);
        builder.field(Fields.VM_NAME, v.key.vmName);
        builder.field(Fields.VM_VERSION, v.key.vmVersion);
        builder.field(Fields.VM_VENDOR, v.key.vmVendor);
        builder.field(Fields.COUNT, v.value);
        builder.endObject();
    }
    builder.endArray();
    builder.startObject(Fields.MEM);
    builder.byteSizeField(Fields.HEAP_USED_IN_BYTES, Fields.HEAP_USED, heapUsed);
    builder.byteSizeField(Fields.HEAP_MAX_IN_BYTES, Fields.HEAP_MAX, heapMax);
    builder.endObject();

    builder.field(Fields.THREADS, threads);
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:23,代碼來源:ClusterStatsNodes.java

示例9: xContentHeader

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
private void xContentHeader(XContentBuilder builder, String key, List<String> values) throws IOException {
    if (values != null && values.isEmpty() == false) {
        if(values.size() == 1) {
            builder.field(key, values.get(0));
        } else {
            builder.startArray(key);
            for (String value : values) {
                builder.value(value);
            }
            builder.endArray();
        }
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:14,代碼來源:ElasticsearchException.java

示例10: innerXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
public XContentBuilder innerXContent(XContentBuilder builder, Params params)
        throws IOException {
    if (sliceId != null) {
        builder.field("slice_id", sliceId);
    }
    builder.field("total", total);
    if (params.paramAsBoolean(INCLUDE_UPDATED, true)) {
        builder.field("updated", updated);
    }
    if (params.paramAsBoolean(INCLUDE_CREATED, true)) {
        builder.field("created", created);
    }
    builder.field("deleted", deleted);
    builder.field("batches", batches);
    builder.field("version_conflicts", versionConflicts);
    builder.field("noops", noops);
    builder.startObject("retries"); {
        builder.field("bulk", bulkRetries);
        builder.field("search", searchRetries);
    }
    builder.endObject();
    builder.timeValueField("throttled_millis", "throttled", throttled);
    builder.field("requests_per_second", requestsPerSecond == Float.POSITIVE_INFINITY ? -1 : requestsPerSecond);
    if (reasonCancelled != null) {
        builder.field("canceled", reasonCancelled);
    }
    builder.timeValueField("throttled_until_millis", "throttled_until", throttledUntil);
    if (false == sliceStatuses.isEmpty()) {
        builder.startArray("slices");
        for (StatusOrException slice : sliceStatuses) {
            if (slice == null) {
                builder.nullValue();
            } else {
                slice.toXContent(builder, params);
            }
        }
        builder.endArray();
    }
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:41,代碼來源:BulkByScrollTask.java

示例11: doInternalXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
protected XContentBuilder doInternalXContent(XContentBuilder builder, Params params) throws IOException {
    if (ranges.isEmpty()) {
        throw new SearchSourceBuilderException("at least one range must be defined for range aggregation [" + getName() + "]");
    }
    builder.startArray("ranges");
    for (Range range : ranges) {
        range.toXContent(builder, params);
    }
    return builder.endArray();
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:12,代碼來源:AbstractRangeBuilder.java

示例12: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject("nodes");
    for (DiscoveryNode node : nodes) {
        node.toXContent(builder, params);
    }
    builder.endObject();
    builder.startArray("shards");
    for (ClusterSearchShardsGroup group : groups) {
        group.toXContent(builder, params);
    }
    builder.endArray();
    return builder;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:15,代碼來源:ClusterSearchShardsResponse.java

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

示例14: 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 (Bucket bucket : buckets) {
        bucket.toXContent(builder, params);
    }
    builder.endArray();
    return builder;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:SignificantLongTerms.java

示例15: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //導入方法依賴的package包/類
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields.FS);
    builder.field(Fields.TIMESTAMP, timestamp);
    builder.field(Fields.TOTAL);
    total().toXContent(builder, params);
    builder.startArray(Fields.DATA);
    for (Path path : paths) {
        path.toXContent(builder, params);
    }
    builder.endArray();
    builder.endObject();
    return builder;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:15,代碼來源:FsInfo.java


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