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


Java XContentBuilder.array方法代码示例

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


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

示例1: testParseIndexAndIndicesThrowsError

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
public void testParseIndexAndIndicesThrowsError() throws IOException {
    XContentBuilder b = XContentBuilder.builder(randomFrom(XContentType.values()).xContent());
    b.startObject(); {
        b.startObject(randomFrom("add", "remove")); {
            b.field("index", randomAsciiOfLength(5));
            b.array("indices", generateRandomStringArray(10, 5, false, false));
            b.field("alias", randomAsciiOfLength(5));
        }
        b.endObject();
    }
    b.endObject();
    try (XContentParser parser = createParser(b)) {
        Exception e = expectThrows(ParsingException.class, () -> AliasActions.PARSER.apply(parser, null));
        assertThat(e.getCause().getCause(), instanceOf(IllegalArgumentException.class));
        assertEquals("Only one of [index] and [indices] is supported", e.getCause().getCause().getMessage());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:AliasActionsTests.java

示例2: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(NAME);

    builder.startObject(fieldName);
    builder.array(TOP_LEFT_FIELD.getPreferredName(), topLeft.getLon(), topLeft.getLat());
    builder.array(BOTTOM_RIGHT_FIELD.getPreferredName(), bottomRight.getLon(), bottomRight.getLat());
    builder.endObject();
    builder.field(VALIDATION_METHOD_FIELD.getPreferredName(), validationMethod);
    builder.field(TYPE_FIELD.getPreferredName(), type);
    builder.field(IGNORE_UNMAPPED_FIELD.getPreferredName(), ignoreUnmapped);

    printBoostAndQueryName(builder);

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

示例3: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields.TRANSPORT);
    builder.array(Fields.BOUND_ADDRESS, (Object[]) address.boundAddresses());
    builder.field(Fields.PUBLISH_ADDRESS, address.publishAddress().toString());
    builder.startObject(Fields.PROFILES);
    if (profileAddresses != null && profileAddresses.size() > 0) {
        for (Map.Entry<String, BoundTransportAddress> entry : profileAddresses.entrySet()) {
            builder.startObject(entry.getKey());
            builder.array(Fields.BOUND_ADDRESS, (Object[]) entry.getValue().boundAddresses());
            builder.field(Fields.PUBLISH_ADDRESS, entry.getValue().publishAddress().toString());
            builder.endObject();
        }
    }
    builder.endObject();
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:TransportInfo.java

示例4: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields.JVM);
    builder.field(Fields.PID, pid);
    builder.field(Fields.VERSION, version);
    builder.field(Fields.VM_NAME, vmName);
    builder.field(Fields.VM_VERSION, vmVersion);
    builder.field(Fields.VM_VENDOR, vmVendor);
    builder.dateField(Fields.START_TIME_IN_MILLIS, Fields.START_TIME, startTime);

    builder.startObject(Fields.MEM);
    builder.byteSizeField(Fields.HEAP_INIT_IN_BYTES, Fields.HEAP_INIT, mem.heapInit);
    builder.byteSizeField(Fields.HEAP_MAX_IN_BYTES, Fields.HEAP_MAX, mem.heapMax);
    builder.byteSizeField(Fields.NON_HEAP_INIT_IN_BYTES, Fields.NON_HEAP_INIT, mem.nonHeapInit);
    builder.byteSizeField(Fields.NON_HEAP_MAX_IN_BYTES, Fields.NON_HEAP_MAX, mem.nonHeapMax);
    builder.byteSizeField(Fields.DIRECT_MAX_IN_BYTES, Fields.DIRECT_MAX, mem.directMemoryMax);
    builder.endObject();

    builder.array(Fields.GC_COLLECTORS, gcCollectors);
    builder.array(Fields.MEMORY_POOLS, memoryPools);

    builder.field(Fields.USING_COMPRESSED_OOPS, useCompressedOops);

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

示例5: doXContentBody

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
    builder.array(VALUES_FIELD.getPreferredName(), values);
    builder.field(PercentilesAggregationBuilder.KEYED_FIELD.getPreferredName(), keyed);
    builder.startObject(method.toString());
    if (method == PercentilesMethod.TDIGEST) {
        builder.field(PercentilesAggregationBuilder.COMPRESSION_FIELD.getPreferredName(), compression);
    } else {
        builder.field(PercentilesAggregationBuilder.NUMBER_SIGNIFICANT_DIGITS_FIELD.getPreferredName(), numberOfSignificantValueDigits);
    }
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:PercentileRanksAggregationBuilder.java

示例6: doXContentBody

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
    builder.array(PERCENTS_FIELD.getPreferredName(), percents);
    builder.field(KEYED_FIELD.getPreferredName(), keyed);
    builder.startObject(method.toString());
    if (method == PercentilesMethod.TDIGEST) {
        builder.field(COMPRESSION_FIELD.getPreferredName(), compression);
    } else {
        builder.field(NUMBER_SIGNIFICANT_DIGITS_FIELD.getPreferredName(), numberOfSignificantValueDigits);
    }
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:PercentilesAggregationBuilder.java

示例7: doXContentBody

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
    if (percents != null) {
        builder.array(PERCENTS_FIELD.getPreferredName(), percents);
    }
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:PercentilesBucketPipelineAggregationBuilder.java

示例8: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    if (fetchSource) {
        builder.startObject();
        builder.array(INCLUDES_FIELD.getPreferredName(), includes);
        builder.array(EXCLUDES_FIELD.getPreferredName(), excludes);
        builder.endObject();
    } else {
        builder.value(false);
    }
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:FetchSourceContext.java

示例9: innerXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public void innerXContent(XContentBuilder builder) throws IOException {
    builder.startObject(name);
    // write common options
    commonOptionsToXContent(builder);
    // write special field-highlighter options
    if (fragmentOffset != -1) {
        builder.field(FRAGMENT_OFFSET_FIELD.getPreferredName(), fragmentOffset);
    }
    if (matchedFields != null) {
        builder.array(MATCHED_FIELDS_FIELD.getPreferredName(), matchedFields);
    }
    builder.endObject();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:HighlightBuilder.java

示例10: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
    // check values
    if(Double.isNaN(box[TOP])) {
        throw new IllegalArgumentException("geo_bounding_box requires top latitude to be set");
    } else if(Double.isNaN(box[BOTTOM])) {
        throw new IllegalArgumentException("geo_bounding_box requires bottom latitude to be set");
    } else if(Double.isNaN(box[RIGHT])) {
        throw new IllegalArgumentException("geo_bounding_box requires right longitude to be set");
    } else if(Double.isNaN(box[LEFT])) {
        throw new IllegalArgumentException("geo_bounding_box requires left longitude to be set");
    }

    builder.startObject(GeoBoundingBoxQueryParser.NAME);

    builder.startObject(name);
    builder.array(TOP_LEFT, box[LEFT], box[TOP]);
    builder.array(BOTTOM_RIGHT, box[RIGHT], box[BOTTOM]);
    builder.endObject();

    if (queryName != null) {
        builder.field("_name", queryName);
    }
    if (type != null) {
        builder.field("type", type);
    }
    if (coerce != null) {
        builder.field("coerce", coerce);
    }
    if (ignoreMalformed != null) {
        builder.field("ignore_malformed", ignoreMalformed);
    }

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

示例11: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    if (this.index != null) {
        builder.field(Field.INDEX.getPreferredName(), this.index);
    }
    if (this.type != null) {
        builder.field(Field.TYPE.getPreferredName(), this.type);
    }
    if (this.id != null) {
        builder.field(Field.ID.getPreferredName(), this.id);
    }
    if (this.doc != null) {
        builder.rawField(Field.DOC.getPreferredName(), this.doc, xContentType);
    }
    if (this.fields != null) {
        builder.array(Field.FIELDS.getPreferredName(), this.fields);
    }
    if (this.perFieldAnalyzer != null) {
        builder.field(Field.PER_FIELD_ANALYZER.getPreferredName(), this.perFieldAnalyzer);
    }
    if (this.routing != null) {
        builder.field(Field.ROUTING.getPreferredName(), this.routing);
    }
    if (this.version != Versions.MATCH_ANY) {
        builder.field(Field.VERSION.getPreferredName(), this.version);
    }
    if (this.versionType != VersionType.INTERNAL) {
        builder.field(Field.VERSION_TYPE.getPreferredName(), this.versionType.toString().toLowerCase(Locale.ROOT));
    }
    return builder.endObject();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:MoreLikeThisQueryBuilder.java

示例12: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(NAME);
    if (fields != null) {
        builder.array(Field.FIELDS.getPreferredName(), fields);
    }
    buildLikeField(builder, Field.LIKE.getPreferredName(), likeTexts, likeItems);
    buildLikeField(builder, Field.UNLIKE.getPreferredName(), unlikeTexts, unlikeItems);
    builder.field(Field.MAX_QUERY_TERMS.getPreferredName(), maxQueryTerms);
    builder.field(Field.MIN_TERM_FREQ.getPreferredName(), minTermFreq);
    builder.field(Field.MIN_DOC_FREQ.getPreferredName(), minDocFreq);
    builder.field(Field.MAX_DOC_FREQ.getPreferredName(), maxDocFreq);
    builder.field(Field.MIN_WORD_LENGTH.getPreferredName(), minWordLength);
    builder.field(Field.MAX_WORD_LENGTH.getPreferredName(), maxWordLength);
    if (stopWords != null) {
        builder.array(Field.STOP_WORDS.getPreferredName(), stopWords);
    }
    if (analyzer != null) {
        builder.field(Field.ANALYZER.getPreferredName(), analyzer);
    }
    builder.field(Field.MINIMUM_SHOULD_MATCH.getPreferredName(), minimumShouldMatch);
    builder.field(Field.BOOST_TERMS.getPreferredName(), boostTerms);
    builder.field(Field.INCLUDE.getPreferredName(), include);
    builder.field(Field.FAIL_ON_UNSUPPORTED_FIELD.getPreferredName(), failOnUnsupportedField);
    printBoostAndQueryName(builder);
    builder.endObject();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:MoreLikeThisQueryBuilder.java

示例13: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(NAME);
    builder.array(TYPE_FIELD.getPreferredName(), types);
    builder.startArray(VALUES_FIELD.getPreferredName());
    for (String value : ids) {
        builder.value(value);
    }
    builder.endArray();
    printBoostAndQueryName(builder);
    builder.endObject();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:IdsQueryBuilder.java

示例14: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields.HTTP);
    builder.array(Fields.BOUND_ADDRESS, (Object[]) address.boundAddresses());
    builder.field(Fields.PUBLISH_ADDRESS, address.publishAddress().toString());
    builder.byteSizeField(Fields.MAX_CONTENT_LENGTH_IN_BYTES, Fields.MAX_CONTENT_LENGTH, maxContentLength);
    builder.endObject();
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:HttpInfo.java

示例15: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.field(Fields.NAME, name);
    builder.array(Fields.FILTERED_TEXT, texts);
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:DetailAnalyzeResponse.java


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