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


Java XContentBuilder.rawField方法代码示例

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


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

示例1: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(NAME);
    builder.field(DOCUMENT_TYPE_FIELD.getPreferredName(), documentType);
    builder.field(QUERY_FIELD.getPreferredName(), field);
    if (document != null) {
        builder.rawField(DOCUMENT_FIELD.getPreferredName(), document);
    }
    if (indexedDocumentIndex != null || indexedDocumentType != null || indexedDocumentId != null) {
        if (indexedDocumentIndex != null) {
            builder.field(INDEXED_DOCUMENT_FIELD_INDEX.getPreferredName(), indexedDocumentIndex);
        }
        if (indexedDocumentType != null) {
            builder.field(INDEXED_DOCUMENT_FIELD_TYPE.getPreferredName(), indexedDocumentType);
        }
        if (indexedDocumentId != null) {
            builder.field(INDEXED_DOCUMENT_FIELD_ID.getPreferredName(), indexedDocumentId);
        }
        if (indexedDocumentRouting != null) {
            builder.field(INDEXED_DOCUMENT_FIELD_ROUTING.getPreferredName(), indexedDocumentRouting);
        }
        if (indexedDocumentPreference != null) {
            builder.field(INDEXED_DOCUMENT_FIELD_PREFERENCE.getPreferredName(), indexedDocumentPreference);
        }
        if (indexedDocumentVersion != null) {
            builder.field(INDEXED_DOCUMENT_FIELD_VERSION.getPreferredName(), indexedDocumentVersion);
        }
    }
    printBoostAndQueryName(builder);
    builder.endObject();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:PercolateQueryBuilder.java

示例2: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    if (hasResponse()) {
        response.toXContent(builder, params);
    } else {
        builder.startObject();
        //we can assume the template is always json as we convert it before compiling it
        builder.rawField("template_output", source, XContentType.JSON);
        builder.endObject();
    }
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:SearchTemplateResponse.java

示例3: innerToXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected XContentBuilder innerToXContent(XContentBuilder builder, Params params) throws IOException {
    if (fuzzyOptions != null) {
        fuzzyOptions.toXContent(builder, params);
    }
    if (regexOptions != null) {
        regexOptions.toXContent(builder, params);
    }
    if (contextBytes != null) {
        builder.rawField(CONTEXTS_FIELD.getPreferredName(), contextBytes);
    }
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:CompletionSuggestionBuilder.java

示例4: doXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject(getName());
    builder.rawField(fieldName, functionBytes);
    builder.field(DecayFunctionParser.MULTI_VALUE_MODE.getPreferredName(), multiValueMode.name());
    builder.endObject();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:DecayFunctionBuilder.java

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

示例6: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.field("full_name", fullName);
    if (params.paramAsBoolean("pretty", false)) {
        builder.field("mapping", sourceAsMap());
    } else {
        builder.rawField("mapping", source, XContentType.JSON);
    }
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:GetFieldMappingsResponse.java

示例7: getQuery

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
private XContentBuilder getQuery(String queryString, CmsCISimple ciSimple) {
    XContentBuilder docBuilder = null;
    try {
        docBuilder = XContentFactory.jsonBuilder().startObject();
        docBuilder.field("query").startObject().field("query_string").startObject().field("query", queryString).endObject().endObject();
        docBuilder.rawField("ci", GSON_ES.toJson(ciSimple).getBytes());
        docBuilder.endObject();

        logger.info(docBuilder.string());
    } catch (IOException e) {
        logger.error("Error in forming percolator query ", e);
    }
    return docBuilder;
}
 
开发者ID:oneops,项目名称:oneops,代码行数:15,代码来源:PolicyProcessor.java

示例8: scriptFieldToXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected XContentBuilder scriptFieldToXContent(String template, ScriptType type, XContentBuilder builder, Params builderParams)
        throws IOException {
    if (type == ScriptType.INLINE && contentType != null && builder.contentType() == contentType) {
        builder.rawField(type.getParseField().getPreferredName(), new BytesArray(template));
    } else {
        builder.field(type.getParseField().getPreferredName(), template);
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:Template.java

示例9: toXContent

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

    if (this.metaData != null) {
        builder.field("meta", this.metaData);
    }
    builder.field(type);
    internalXContent(builder, params);

    if (aggregations != null || aggregationsBinary != null) {

        if (aggregations != null) {
            builder.startObject("aggregations");
            for (AbstractAggregationBuilder subAgg : aggregations) {
                subAgg.toXContent(builder, params);
            }
            builder.endObject();
        }

        if (aggregationsBinary != null) {
            if (XContentFactory.xContentType(aggregationsBinary) == builder.contentType()) {
                builder.rawField("aggregations", aggregationsBinary);
            } else {
                builder.field("aggregations_binary", aggregationsBinary);
            }
        }

    }

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

示例10: innerToXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
protected XContentBuilder innerToXContent(XContentBuilder builder, Params params) throws IOException {
    super.innerToXContent(builder, params);
    if (payload != null && payload.length() > 0) {
        builder.rawField("payload", payload);
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:CompletionSuggestion.java

示例11: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.field("full_name", fullName);
    if (params.paramAsBoolean("pretty", false)) {
        builder.field("mapping", sourceAsMap());
    } else {
        builder.rawField("mapping", source);
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:GetFieldMappingsResponse.java

示例12: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    builder.startObject();
    builder.rawField("template_output", source);
    builder.endObject();
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:RenderSearchTemplateResponse.java

示例13: innerToXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
public void innerToXContent(XContentBuilder builder, Params params) throws IOException {
    if (queryBuilder != null) {
        builder.field("query");
        queryBuilder.toXContent(builder, params);
    }

    if (queryBinary != null) {
        if (XContentFactory.xContentType(queryBinary) == builder.contentType()) {
            builder.rawField("query", queryBinary);
        } else {
            builder.field("query_binary", queryBinary);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:QuerySourceBuilder.java

示例14: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    return builder.rawField("doc", doc);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:PercolateSourceBuilder.java

示例15: toXContent

import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
/**
 * This will build scripts into the following XContent structure:
 *
 * {@code
 * {
 *     "<type (inline, stored, file)>" : "<idOrCode>",
 *     "lang" : "<lang>",
 *     "options" : {
 *         "option0" : "<option0>",
 *         "option1" : "<option1>",
 *         ...
 *     },
 *     "params" : {
 *         "param0" : "<param0>",
 *         "param1" : "<param1>",
 *         ...
 *     }
 * }
 * }
 *
 * Example:
 * {@code
 * {
 *     "inline" : "return Math.log(doc.popularity) * params.multiplier;",
 *     "lang" : "painless",
 *     "params" : {
 *         "multiplier" : 100.0
 *     }
 * }
 * }
 *
 * Note that lang, options, and params will only be included if there have been any specified.
 *
 * This also handles templates in a special way.  If the {@link Script#CONTENT_TYPE_OPTION} option
 * is provided and the {@link ScriptType#INLINE} is specified then the template will be preserved as a raw field.
 *
 * {@code
 * {
 *     "inline" : { "query" : ... },
 *     "lang" : "<lang>",
 *     "options" : {
 *         "option0" : "<option0>",
 *         "option1" : "<option1>",
 *         ...
 *     },
 *     "params" : {
 *         "param0" : "<param0>",
 *         "param1" : "<param1>",
 *         ...
 *     }
 * }
 * }
 */
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params builderParams) throws IOException {
    builder.startObject();

    String contentType = options == null ? null : options.get(CONTENT_TYPE_OPTION);

    if (type == ScriptType.INLINE && contentType != null && builder.contentType().mediaType().equals(contentType)) {
        builder.rawField(type.getParseField().getPreferredName(), new BytesArray(idOrCode));
    } else {
        builder.field(type.getParseField().getPreferredName(), idOrCode);
    }

    if (lang != null) {
        builder.field(LANG_PARSE_FIELD.getPreferredName(), lang);
    }

    if (options != null && !options.isEmpty()) {
        builder.field(OPTIONS_PARSE_FIELD.getPreferredName(), options);
    }

    if (!params.isEmpty()) {
        builder.field(PARAMS_PARSE_FIELD.getPreferredName(), params);
    }

    builder.endObject();

    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:82,代码来源:Script.java


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