当前位置: 首页>>代码示例>>Java>>正文


Java XContentBuilder.startObject方法代码示例

本文整理汇总了Java中org.elasticsearch.common.xcontent.XContentBuilder.startObject方法的典型用法代码示例。如果您正苦于以下问题:Java XContentBuilder.startObject方法的具体用法?Java XContentBuilder.startObject怎么用?Java XContentBuilder.startObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.common.xcontent.XContentBuilder的用法示例。


在下文中一共展示了XContentBuilder.startObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFromXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
public void testFromXContent() throws IOException {
    HighlightField highlightField = createTestItem();
    XContentType xcontentType = randomFrom(XContentType.values());
    XContentBuilder builder = XContentFactory.contentBuilder(xcontentType);
    if (randomBoolean()) {
        builder.prettyPrint();
    }
    builder.startObject(); // we need to wrap xContent output in proper object to create a parser for it
    builder = highlightField.toXContent(builder, ToXContent.EMPTY_PARAMS);
    builder.endObject();
    XContentParser parser = createParser(builder);
    parser.nextToken(); // skip to the opening object token, fromXContent advances from here and starts with the field name
    parser.nextToken();
    HighlightField parsedField = HighlightField.fromXContent(parser);
    assertEquals(highlightField, parsedField);
    if (highlightField.fragments() != null) {
        assertEquals(XContentParser.Token.END_ARRAY, parser.currentToken());
    }
    assertEquals(XContentParser.Token.END_OBJECT, parser.nextToken());
    assertNull(parser.nextToken());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:HighlightFieldTests.java

示例2: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.startObject(fieldName);
    builder.field(ORDER_FIELD.getPreferredName(), order);
    if (missing != null) {
        builder.field(MISSING.getPreferredName(), missing);
    }
    if (unmappedType != null) {
        builder.field(UNMAPPED_TYPE.getPreferredName(), unmappedType);
    }
    if (sortMode != null) {
        builder.field(SORT_MODE.getPreferredName(), sortMode);
    }
    if (nestedFilter != null) {
        builder.field(NESTED_FILTER_FIELD.getPreferredName(), nestedFilter, params);
    }
    if (nestedPath != null) {
        builder.field(NESTED_PATH_FIELD.getPreferredName(), nestedPath);
    }
    builder.endObject();
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:FieldSortBuilder.java

示例3: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields.CPU);
    builder.field(Fields.PERCENT, getPercent());
    if (getLoadAverage() != null && Arrays.stream(getLoadAverage()).anyMatch(load -> load != -1)) {
        builder.startObject(Fields.LOAD_AVERAGE);
        if (getLoadAverage()[0] != -1) {
            builder.field(Fields.LOAD_AVERAGE_1M, getLoadAverage()[0]);
        }
        if (getLoadAverage()[1] != -1) {
            builder.field(Fields.LOAD_AVERAGE_5M, getLoadAverage()[1]);
        }
        if (getLoadAverage()[2] != -1) {
            builder.field(Fields.LOAD_AVERAGE_15M, getLoadAverage()[2]);
        }
        builder.endObject();
    }
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:OsStats.java

示例4: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    boolean includeDefaults = params.paramAsBoolean("include_defaults", false);

    // if all defaults, no need to write it at all
    if (!includeDefaults && fieldType().stored() == Defaults.FIELD_TYPE.stored() && enabledState == Defaults.ENABLED_STATE && hasCustomFieldDataSettings() == false) {
        return builder;
    }
    builder.startObject(CONTENT_TYPE);
    if (indexCreatedBefore2x && (includeDefaults || fieldType().stored() != Defaults.FIELD_TYPE.stored())) {
        builder.field("store", fieldType().stored());
    }
    if (includeDefaults || enabledState != Defaults.ENABLED_STATE) {
        builder.field("enabled", enabledState.enabled);
    }
    if (indexCreatedBefore2x && (includeDefaults || hasCustomFieldDataSettings())) {
        builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
    }
    builder.endObject();
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:IndexFieldMapper.java

示例5: 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.field("beta", beta);
    builder.field("gamma", gamma);
    builder.field("period", period);
    if (pad != null) {
        builder.field("pad", pad);
    }
    builder.field("type", seasonalityType.getName());

    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:HoltWintersModel.java

示例6: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(SpanFirstQueryParser.NAME);
    builder.field("match");
    matchBuilder.toXContent(builder, params);
    builder.field("end", end);
    if (boost != -1) {
        builder.field("boost", boost);
    }
    if (queryName != null) {
        builder.field("_name", queryName);
    }
    builder.endObject();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:SpanFirstQueryBuilder.java

示例7: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.field(FILTER_FIELD.getPreferredName());
    filter.toXContent(builder, params);
    scoreFunction.toXContent(builder, params);
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:FunctionScoreQueryBuilder.java

示例8: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields.SEGMENTS);
    builder.field(Fields.COUNT, count);
    builder.byteSizeField(Fields.MEMORY_IN_BYTES, Fields.MEMORY, memoryInBytes);
    builder.byteSizeField(Fields.TERMS_MEMORY_IN_BYTES, Fields.TERMS_MEMORY, termsMemoryInBytes);
    builder.byteSizeField(Fields.STORED_FIELDS_MEMORY_IN_BYTES, Fields.STORED_FIELDS_MEMORY, storedFieldsMemoryInBytes);
    builder.byteSizeField(Fields.TERM_VECTORS_MEMORY_IN_BYTES, Fields.TERM_VECTORS_MEMORY, termVectorsMemoryInBytes);
    builder.byteSizeField(Fields.NORMS_MEMORY_IN_BYTES, Fields.NORMS_MEMORY, normsMemoryInBytes);
    builder.byteSizeField(Fields.POINTS_MEMORY_IN_BYTES, Fields.POINTS_MEMORY, pointsMemoryInBytes);
    builder.byteSizeField(Fields.DOC_VALUES_MEMORY_IN_BYTES, Fields.DOC_VALUES_MEMORY, docValuesMemoryInBytes);
    builder.byteSizeField(Fields.INDEX_WRITER_MEMORY_IN_BYTES, Fields.INDEX_WRITER_MEMORY, indexWriterMemoryInBytes);
    builder.byteSizeField(Fields.VERSION_MAP_MEMORY_IN_BYTES, Fields.VERSION_MAP_MEMORY, versionMapMemoryInBytes);
    builder.byteSizeField(Fields.FIXED_BIT_SET_MEMORY_IN_BYTES, Fields.FIXED_BIT_SET, bitsetMemoryInBytes);
    builder.field(Fields.MAX_UNSAFE_AUTO_ID_TIMESTAMP, maxUnsafeAutoIdTimestamp);
    builder.startObject(Fields.FILE_SIZES);
    for (Iterator<ObjectObjectCursor<String, Long>> it = fileSizes.iterator(); it.hasNext();) {
        ObjectObjectCursor<String, Long> entry = it.next();
        builder.startObject(entry.key);
        builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, entry.value);
        builder.field(Fields.DESCRIPTION, fileDescriptions.getOrDefault(entry.key, "Others"));
        builder.endObject();
    }
    builder.endObject();
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:SegmentsStats.java

示例9: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields._SHARDS);
    shardCounts.toXContent(builder, params);
    builder.endObject();
    for (Map.Entry<String, List<ShardsSyncedFlushResult>> indexEntry : shardsResultPerIndex.entrySet()) {
        List<ShardsSyncedFlushResult> indexResult = indexEntry.getValue();
        builder.startObject(indexEntry.getKey());
        ShardCounts indexShardCounts = calculateShardCounts(indexResult);
        indexShardCounts.toXContent(builder, params);
        if (indexShardCounts.failed > 0) {
            builder.startArray(Fields.FAILURES);
            for (ShardsSyncedFlushResult shardResults : indexResult) {
                if (shardResults.failed()) {
                    builder.startObject();
                    builder.field(Fields.SHARD, shardResults.shardId().id());
                    builder.field(Fields.REASON, shardResults.failureReason());
                    builder.endObject();
                    continue;
                }
                Map<ShardRouting, SyncedFlushService.ShardSyncedFlushResponse> failedShards = shardResults.failedShards();
                for (Map.Entry<ShardRouting, SyncedFlushService.ShardSyncedFlushResponse> shardEntry : failedShards.entrySet()) {
                    builder.startObject();
                    builder.field(Fields.SHARD, shardResults.shardId().id());
                    builder.field(Fields.REASON, shardEntry.getValue().failureReason());
                    builder.field(Fields.ROUTING, shardEntry.getKey());
                    builder.endObject();
                }
            }
            builder.endArray();
        }
        builder.endObject();
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:36,代码来源:SyncedFlushResponse.java

示例10: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(FunctionScoreQueryParser.NAME);
    if (queryBuilder != null) {
        builder.field("query");
        queryBuilder.toXContent(builder, params);
    }
    builder.startArray("functions");
    for (int i = 0; i < filters.size(); i++) {
        builder.startObject();
        if (filters.get(i) != null) {
            builder.field("filter");
            filters.get(i).toXContent(builder, params);
        }
        scoreFunctions.get(i).toXContent(builder, params);
        builder.endObject();
    }
    builder.endArray();

    if (scoreMode != null) {
        builder.field("score_mode", scoreMode);
    }
    if (boostMode != null) {
        builder.field("boost_mode", boostMode);
    }
    if (maxBoost != null) {
        builder.field("max_boost", maxBoost);
    }
    if (boost != null) {
        builder.field("boost", boost);
    }
    if (minScore != null) {
        builder.field("min_score", minScore);
    }

    builder.endObject();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:38,代码来源:FunctionScoreQueryBuilder.java

示例11: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject("refresh");
    builder.field("total", total);
    builder.timeValueField("total_time_in_millis", "total_time", totalTimeInMillis);
    builder.field("listeners", listeners);
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:RefreshStats.java

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

示例13: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    if (!active()) {
        return builder;
    }
    boolean includeDefaults = params.paramAsBoolean("include_defaults", false);

    builder.startObject(CONTENT_TYPE);
    builder.field("type", parentType);
    if (includeDefaults || joinFieldHasCustomFieldDataSettings()) {
        builder.field("fielddata", (Map) childJoinFieldType.fieldDataType().getSettings().getAsMap());
    }
    builder.endObject();
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:ParentFieldMapper.java

示例14: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject("store");
    {
        if (matchingBytes < 0) {
            // dealing with a primary shard
            if (allocationId == null && storeException == null) {
                // there was no information we could obtain of any shard data on the node
                builder.field("found", false);
            } else {
                builder.field("in_sync", inSync);
            }
        }
        if (allocationId != null) {
            builder.field("allocation_id", allocationId);
        }
        if (matchingBytes >= 0) {
            if (hasMatchingSyncId()) {
                builder.field("matching_sync_id", true);
            } else {
                builder.byteSizeField("matching_size_in_bytes", "matching_size", matchingBytes);
            }
        }
        if (storeException != null) {
            builder.startObject("store_exception");
            ElasticsearchException.generateThrowableXContent(builder, params, storeException);
            builder.endObject();
        }
    }
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:NodeAllocationResult.java

示例15: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(NAME);
    builder.field(TYPE_FIELD.getPreferredName(), type);
    builder.field(ID_FIELD.getPreferredName(), id);
    builder.field(IGNORE_UNMAPPED_FIELD.getPreferredName(), ignoreUnmapped);
    printBoostAndQueryName(builder);
    builder.endObject();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ParentIdQueryBuilder.java


注:本文中的org.elasticsearch.common.xcontent.XContentBuilder.startObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。