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


Java SortBuilder.toXContent方法代码示例

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


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

示例1: toXContent

import org.elasticsearch.search.sort.SortBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    if (docBuilder != null) {
        docBuilder.toXContent(builder, params);
    }
    if (queryBuilder != null) {
        builder.field("query");
        queryBuilder.toXContent(builder, params);
    }
    if (size != null) {
        builder.field("size", size);
    }
    if (sorts != null) {
        builder.startArray("sort");
        for (SortBuilder sort : sorts) {
            builder.startObject();
            sort.toXContent(builder, params);
            builder.endObject();
        }
        builder.endArray();
    }
    if (trackScores != null) {
        builder.field("track_scores", trackScores);
    }
    if (highlightBuilder != null) {
        highlightBuilder.toXContent(builder, params);
    }
    if (aggregations != null) {
        builder.field("aggregations");
        builder.startObject();
        for (AbstractAggregationBuilder aggregation : aggregations) {
            aggregation.toXContent(builder, params);
        }
        builder.endObject();
    }
    builder.endObject();
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:40,代码来源:PercolateSourceBuilder.java

示例2: internalXContent

import org.elasticsearch.search.sort.SortBuilder; //导入方法依赖的package包/类
@Override
protected XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.field(SearchSourceBuilder.FROM_FIELD.getPreferredName(), from);
    builder.field(SearchSourceBuilder.SIZE_FIELD.getPreferredName(), size);
    builder.field(SearchSourceBuilder.VERSION_FIELD.getPreferredName(), version);
    builder.field(SearchSourceBuilder.EXPLAIN_FIELD.getPreferredName(), explain);
    if (fetchSourceContext != null) {
        builder.field(SearchSourceBuilder._SOURCE_FIELD.getPreferredName(), fetchSourceContext);
    }
    if (storedFieldsContext != null) {
        storedFieldsContext.toXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), builder);
    }
    if (fieldDataFields != null) {
        builder.startArray(SearchSourceBuilder.DOCVALUE_FIELDS_FIELD.getPreferredName());
        for (String fieldDataField : fieldDataFields) {
            builder.value(fieldDataField);
        }
        builder.endArray();
    }
    if (scriptFields != null) {
        builder.startObject(SearchSourceBuilder.SCRIPT_FIELDS_FIELD.getPreferredName());
        for (ScriptField scriptField : scriptFields) {
            scriptField.toXContent(builder, params);
        }
        builder.endObject();
    }
    if (sorts != null) {
        builder.startArray(SearchSourceBuilder.SORT_FIELD.getPreferredName());
        for (SortBuilder<?> sort : sorts) {
                sort.toXContent(builder, params);
        }
        builder.endArray();
    }
    if (trackScores) {
        builder.field(SearchSourceBuilder.TRACK_SCORES_FIELD.getPreferredName(), true);
    }
    if (highlightBuilder != null) {
        builder.field(SearchSourceBuilder.HIGHLIGHT_FIELD.getPreferredName(), highlightBuilder);
    }
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:44,代码来源:TopHitsAggregationBuilder.java

示例3: toXContent

import org.elasticsearch.search.sort.SortBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    if (name != null) {
        builder.field(NAME_FIELD.getPreferredName(), name);
    }
    builder.field(IGNORE_UNMAPPED.getPreferredName(), ignoreUnmapped);
    builder.field(SearchSourceBuilder.FROM_FIELD.getPreferredName(), from);
    builder.field(SearchSourceBuilder.SIZE_FIELD.getPreferredName(), size);
    builder.field(SearchSourceBuilder.VERSION_FIELD.getPreferredName(), version);
    builder.field(SearchSourceBuilder.EXPLAIN_FIELD.getPreferredName(), explain);
    builder.field(SearchSourceBuilder.TRACK_SCORES_FIELD.getPreferredName(), trackScores);
    if (fetchSourceContext != null) {
        builder.field(SearchSourceBuilder._SOURCE_FIELD.getPreferredName(), fetchSourceContext, params);
    }
    if (storedFieldsContext != null) {
        storedFieldsContext.toXContent(SearchSourceBuilder.STORED_FIELDS_FIELD.getPreferredName(), builder);
    }
    if (docValueFields != null) {
        builder.startArray(SearchSourceBuilder.DOCVALUE_FIELDS_FIELD.getPreferredName());
        for (String fieldDataField : docValueFields) {
            builder.value(fieldDataField);
        }
        builder.endArray();
    }
    if (scriptFields != null) {
        builder.startObject(SearchSourceBuilder.SCRIPT_FIELDS_FIELD.getPreferredName());
        for (ScriptField scriptField : scriptFields) {
            scriptField.toXContent(builder, params);
        }
        builder.endObject();
    }
    if (sorts != null) {
        builder.startArray(SearchSourceBuilder.SORT_FIELD.getPreferredName());
        for (SortBuilder<?> sort : sorts) {
            sort.toXContent(builder, params);
        }
        builder.endArray();
    }
    if (highlightBuilder != null) {
        builder.field(SearchSourceBuilder.HIGHLIGHT_FIELD.getPreferredName(), highlightBuilder, params);
    }
    if (childInnerHits != null) {
        builder.startObject(INNER_HITS_FIELD.getPreferredName());
        for (Map.Entry<String, InnerHitBuilder> entry : childInnerHits.entrySet()) {
            builder.field(entry.getKey(), entry.getValue(), params);
        }
        builder.endObject();
    }
    builder.endObject();
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:53,代码来源:InnerHitBuilder.java


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