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


Java XContentBuilder.endObject方法代码示例

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


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

示例1: testParseDist

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
/**
 * test correct parsing of `dist` parameter, this should create builder with pre/post set to same value
 */
public void testParseDist() throws IOException {
    XContentBuilder builder = XContentFactory.jsonBuilder();
    builder.startObject();
    builder.startObject(SpanNotQueryBuilder.NAME);
    builder.field("exclude");
    spanTermQuery("description", "jumped").toXContent(builder, null);
    builder.field("include");
    spanNearQuery(QueryBuilders.spanTermQuery("description", "quick"), 1)
            .addClause(QueryBuilders.spanTermQuery("description", "fox")).toXContent(builder, null);
    builder.field("dist", 3);
    builder.endObject();
    builder.endObject();
    SpanNotQueryBuilder query = (SpanNotQueryBuilder)parseQuery(builder.string());
    assertThat(query.pre(), equalTo(3));
    assertThat(query.post(), equalTo(3));
    assertNotNull(query.includeQuery());
    assertNotNull(query.excludeQuery());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:SpanNotQueryBuilderTests.java

示例2: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.startObject(opType.getLowercase());
    if (failure == null) {
        response.innerToXContent(builder, params);
        builder.field(STATUS, response.status().getStatus());
    } else {
        builder.field(_INDEX, failure.getIndex());
        builder.field(_TYPE, failure.getType());
        builder.field(_ID, failure.getId());
        builder.field(STATUS, failure.getStatus().getStatus());
        builder.startObject(ERROR);
        ElasticsearchException.generateThrowableXContent(builder, params, failure.getCause());
        builder.endObject();
    }
    builder.endObject();
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:BulkItemResponse.java

示例3: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(simpleName())
        .field(Fields.TYPE, CONTENT_TYPE);

    builder.field(Fields.ANALYZER, fieldType().indexAnalyzer().name());
    if (fieldType().indexAnalyzer().name().equals(fieldType().searchAnalyzer().name()) == false) {
        builder.field(Fields.SEARCH_ANALYZER.getPreferredName(), fieldType().searchAnalyzer().name());
    }
    builder.field(Fields.PAYLOADS, fieldType().analyzingSuggestLookupProvider.hasPayloads());
    builder.field(Fields.PRESERVE_SEPARATORS.getPreferredName(), fieldType().analyzingSuggestLookupProvider.getPreserveSep());
    builder.field(Fields.PRESERVE_POSITION_INCREMENTS.getPreferredName(), fieldType().analyzingSuggestLookupProvider.getPreservePositionsIncrements());
    builder.field(Fields.MAX_INPUT_LENGTH.getPreferredName(), this.maxInputLength);
    multiFields.toXContent(builder, params);

    if (fieldType().requiresContext()) {
        builder.startObject(Fields.CONTEXT);
        for (ContextMapping mapping : fieldType().getContextMapping().values()) {
            builder.value(mapping);
        }
        builder.endObject();
    }

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

示例4: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields._SHARDS);
    builder.field(Fields.TOTAL, total);
    builder.field(Fields.SUCCESSFUL, successful);
    builder.field(Fields.FAILED, getFailed());
    if (failures.length > 0) {
        builder.startArray(Fields.FAILURES);
        for (Failure failure : failures) {
            failure.toXContent(builder, params);
        }
        builder.endArray();
    }
    builder.endObject();
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:ActionWriteResponse.java

示例5: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Integer.toString(id));
    builder.field("description", description);
    builder.field("retryable", retryable);
    if (disableStatePersistence) {
        builder.field("disable_state_persistence", disableStatePersistence);
    }
    builder.startArray("levels");
    for (ClusterBlockLevel level : levels) {
        builder.value(level.name().toLowerCase(Locale.ROOT));
    }
    builder.endArray();
    builder.endObject();
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:ClusterBlock.java

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

示例7: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    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();
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:PendingClusterTasksResponse.java

示例8: testHighlightingWithWildcardName

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
public void testHighlightingWithWildcardName() throws IOException {
    // test the kibana case with * as fieldname that will try highlight all fields including meta fields
    XContentBuilder mappings = jsonBuilder();
    mappings.startObject();
    mappings.startObject("type")
            .startObject("properties")
            .startObject("text")
            .field("type", "text")
            .field("analyzer", "keyword")
            .field("index_options", "offsets")
            .field("term_vector", "with_positions_offsets")
            .endObject()
            .endObject()
            .endObject();
    mappings.endObject();
    assertAcked(prepareCreate("test")
            .addMapping("type", mappings));
    client().prepareIndex("test", "type", "1")
            .setSource(jsonBuilder().startObject().field("text", "text").endObject())
            .get();
    refresh();
    for (String type : ALL_TYPES) {
        SearchResponse search = client().prepareSearch().setQuery(constantScoreQuery(matchQuery("text", "text")))
            .highlighter(new HighlightBuilder().field(new Field("*").highlighterType(type))).get();
        assertHighlight(search, 0, "text", 0, equalTo("<em>text</em>"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:HighlighterSearchIT.java

示例9: 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.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:EwmaModel.java

示例10: toRestRequest

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
private RestRequest toRestRequest(ClusterRerouteRequest original) throws IOException {
    Map<String, String> params = new HashMap<>();
    XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values()));
    boolean hasBody = false;
    if (randomBoolean()) {
        builder.prettyPrint();
    }
    builder.startObject();
    if (randomBoolean()) {
        params.put("dry_run", Boolean.toString(original.dryRun()));
    } else {
        hasBody = true;
        builder.field("dry_run", original.dryRun());
    }
    params.put("explain", Boolean.toString(original.explain()));
    if (false == original.timeout().equals(AcknowledgedRequest.DEFAULT_ACK_TIMEOUT) || randomBoolean()) {
        params.put("timeout", original.timeout().toString());
    }
    if (original.isRetryFailed() || randomBoolean()) {
        params.put("retry_failed", Boolean.toString(original.isRetryFailed()));
    }
    if (false == original.masterNodeTimeout().equals(MasterNodeRequest.DEFAULT_MASTER_NODE_TIMEOUT) || randomBoolean()) {
        params.put("master_timeout", original.masterNodeTimeout().toString());
    }
    if (original.getCommands() != null) {
        hasBody = true;
        original.getCommands().toXContent(builder, ToXContent.EMPTY_PARAMS);
    }
    builder.endObject();

    FakeRestRequest.Builder requestBuilder = new FakeRestRequest.Builder(xContentRegistry());
    requestBuilder.withParams(params);
    if (hasBody) {
        requestBuilder.withContent(builder.bytes(), builder.contentType());
    }
    return requestBuilder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:38,代码来源:ClusterRerouteRequestTests.java

示例11: toString

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public String toString() {
    try {
        XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
        builder.startObject();
        toXContent(builder, EMPTY_PARAMS);
        builder.endObject();
        return builder.string();
    } catch (IOException e) {
        return "{ \"error\" : \"" + e.getMessage() + "\"}";
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:Suggest.java

示例12: toXContent

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

示例13: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(Fields.THREAD_POOL);
    for (ThreadPool.Info info : infos) {
        info.toXContent(builder, params);
    }
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ThreadPoolInfo.java

示例14: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(getName());
    if (seed != null) {
        builder.field("seed", seed);
    }
    builder.endObject();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:RandomScoreFunctionBuilder.java

示例15: DecayFunctionBuilder

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
/**
 * Convenience constructor that converts its parameters into json to parse on the data nodes.
 */
protected DecayFunctionBuilder(String fieldName, Object origin, Object scale, Object offset, double decay) {
    if (fieldName == null) {
        throw new IllegalArgumentException("decay function: field name must not be null");
    }
    if (scale == null) {
        throw new IllegalArgumentException("decay function: scale must not be null");
    }
    if (decay <= 0 || decay >= 1.0) {
        throw new IllegalStateException("decay function: decay must be in range 0..1!");
    }
    this.fieldName = fieldName;
    try {
        XContentBuilder builder = XContentFactory.jsonBuilder();
        builder.startObject();
        if (origin != null) {
            builder.field(ORIGIN, origin);
        }
        builder.field(SCALE, scale);
        if (offset != null) {
            builder.field(OFFSET, offset);
        }
        builder.field(DECAY, decay);
        builder.endObject();
        this.functionBytes = builder.bytes();
    } catch (IOException e) {
        throw new IllegalArgumentException("unable to build inner function object",e);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:DecayFunctionBuilder.java


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