当前位置: 首页>>代码示例>>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;未经允许,请勿转载。