當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。