當前位置: 首頁>>代碼示例>>Java>>正文


Java XContentFactory.xContentType方法代碼示例

本文整理匯總了Java中org.elasticsearch.common.xcontent.XContentFactory.xContentType方法的典型用法代碼示例。如果您正苦於以下問題:Java XContentFactory.xContentType方法的具體用法?Java XContentFactory.xContentType怎麽用?Java XContentFactory.xContentType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.common.xcontent.XContentFactory的用法示例。


在下文中一共展示了XContentFactory.xContentType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: PercolateQueryBuilder

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
/**
 * Read from a stream.
 */
PercolateQueryBuilder(StreamInput in) throws IOException {
    super(in);
    field = in.readString();
    documentType = in.readString();
    indexedDocumentIndex = in.readOptionalString();
    indexedDocumentType = in.readOptionalString();
    indexedDocumentId = in.readOptionalString();
    indexedDocumentRouting = in.readOptionalString();
    indexedDocumentPreference = in.readOptionalString();
    if (in.readBoolean()) {
        indexedDocumentVersion = in.readVLong();
    } else {
        indexedDocumentVersion = null;
    }
    document = in.readOptionalBytesReference();
    if (document != null) {
        if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
            documentXContentType = XContentType.readFrom(in);
        } else {
            documentXContentType = XContentFactory.xContentType(document);
        }
    } else {
        documentXContentType = null;
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:29,代碼來源:PercolateQueryBuilder.java

示例2: Item

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
/**
 * Read from a stream.
 */
Item(StreamInput in) throws IOException {
    index = in.readOptionalString();
    type = in.readOptionalString();
    if (in.readBoolean()) {
        doc = (BytesReference) in.readGenericValue();
        if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
            xContentType = XContentType.readFrom(in);
        } else {
            xContentType = XContentFactory.xContentType(doc);
        }
    } else {
        id = in.readString();
    }
    fields = in.readOptionalStringArray();
    perFieldAnalyzer = (Map<String, String>) in.readGenericValue();
    routing = in.readOptionalString();
    version = in.readLong();
    versionType = VersionType.readFromStream(in);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:23,代碼來源:MoreLikeThisQueryBuilder.java

示例3: readFrom

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);

    lang = in.readString();

    if (lang.isEmpty()) {
        lang = null;
    }

    id = in.readOptionalString();
    content = in.readBytesReference();
    if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
        xContentType = XContentType.readFrom(in);
    } else {
        xContentType = XContentFactory.xContentType(content);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,代碼來源:PutStoredScriptRequest.java

示例4: readFrom

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    type = in.readOptionalString();
    id = in.readOptionalString();
    routing = in.readOptionalString();
    parent = in.readOptionalString();
    if (in.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) {
        in.readOptionalString(); // timestamp
        in.readOptionalWriteable(TimeValue::new); // ttl
    }
    source = in.readBytesReference();
    opType = OpType.fromId(in.readByte());
    version = in.readLong();
    versionType = VersionType.fromValue(in.readByte());
    pipeline = in.readOptionalString();
    isRetry = in.readBoolean();
    autoGeneratedTimestamp = in.readLong();
    if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
        contentType = in.readOptionalWriteable(XContentType::readFrom);
    } else {
        contentType = XContentFactory.xContentType(source);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:25,代碼來源:IndexRequest.java

示例5: handleRequest

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    String scrollId = request.param("scroll_id");
    SearchScrollRequest searchScrollRequest = new SearchScrollRequest();
    searchScrollRequest.scrollId(scrollId);
    String scroll = request.param("scroll");
    if (scroll != null) {
        searchScrollRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll")));
    }

    if (RestActions.hasBodyContent(request)) {
        XContentType type = XContentFactory.xContentType(RestActions.getRestContent(request));
        if (type == null) {
            if (scrollId == null) {
                scrollId = RestActions.getRestContent(request).toUtf8();
                searchScrollRequest.scrollId(scrollId);
            }
        } else {
            // NOTE: if rest request with xcontent body has request parameters, these parameters override xcontent values
            buildFromContent(RestActions.getRestContent(request), searchScrollRequest);
        }
    }
    client.searchScroll(searchScrollRequest, new RestStatusToXContentListener<SearchResponse>(channel));
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:25,代碼來源:RestSearchScrollAction.java

示例6: restContentBuilder

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
public static XContentBuilder restContentBuilder(RestRequest request)  
        throws IOException {
    XContentType contentType = XContentType  
            .fromRestContentType(request.header("Content-Type"));  
    if (contentType == null) {  
        // try and guess it from the body, if exists  
        if (request.hasContent()) {  
            contentType = XContentFactory.xContentType(request.content());  
        }  
    }  
    if (contentType == null) {  
        // default to JSON  
        contentType = XContentType.JSON;  
    }  
    BytesStreamOutput out = new BytesStreamOutput();  
    XContentBuilder builder = new XContentBuilder(  
            XContentFactory.xContent(contentType), out);  
  
    if (request.paramAsBoolean("pretty", false)) {  
        builder.prettyPrint();  
    }  
    String casing = request.param("case");  
    if (casing != null && "camelCase".equals(casing)) {  
        builder.fieldCaseConversion(  
                XContentBuilder.FieldCaseConversion.CAMELCASE);  
    } else {  
        builder.fieldCaseConversion(  
                XContentBuilder.FieldCaseConversion.NONE);  
    }  
    return builder;  
}
 
開發者ID:ghostboyzone,項目名稱:ESAuthPlugin,代碼行數:32,代碼來源:ContentBuilder.java

示例7: doRewrite

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
@Override
protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) throws IOException {
    if (document != null) {
        return this;
    }

    GetRequest getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentType, indexedDocumentId);
    getRequest.preference("_local");
    getRequest.routing(indexedDocumentRouting);
    getRequest.preference(indexedDocumentPreference);
    if (indexedDocumentVersion != null) {
        getRequest.version(indexedDocumentVersion);
    }
    GetResponse getResponse = queryShardContext.getClient().get(getRequest).actionGet();
    if (getResponse.isExists() == false) {
        throw new ResourceNotFoundException(
                "indexed document [{}/{}/{}] couldn't be found", indexedDocumentIndex, indexedDocumentType, indexedDocumentId
        );
    }
    if(getResponse.isSourceEmpty()) {
        throw new IllegalArgumentException(
            "indexed document [" + indexedDocumentIndex + "/" + indexedDocumentType + "/" + indexedDocumentId + "] source disabled"
        );
    }
    final BytesReference source = getResponse.getSourceAsBytesRef();
    return new PercolateQueryBuilder(field, documentType, source, XContentFactory.xContentType(source));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:28,代碼來源:PercolateQueryBuilder.java

示例8: readFrom

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
public static PipelineConfiguration readFrom(StreamInput in) throws IOException {
    if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
        return new PipelineConfiguration(in.readString(), in.readBytesReference(), XContentType.readFrom(in));
    } else {
        final String id = in.readString();
        final BytesReference config = in.readBytesReference();
        return new PipelineConfiguration(id, config, XContentFactory.xContentType(config));
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,代碼來源:PipelineConfiguration.java

示例9: innerToXContent

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的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

示例10: writeRawValue

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
@Override
public final void writeRawValue(BytesReference content) throws IOException {
    XContentType contentType = XContentFactory.xContentType(content);
    if (contentType == null) {
        throw new IllegalArgumentException("Can't write raw bytes whose xcontent-type can't be guessed");
    }
    writeRawValue(content, contentType);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:9,代碼來源:JsonXContentGenerator.java

示例11: readFrom

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    id = in.readOptionalString();
    verbose = in.readBoolean();
    source = in.readBytesReference();
    if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
        xContentType = XContentType.readFrom(in);
    } else {
        xContentType = XContentFactory.xContentType(source);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,代碼來源:SimulatePipelineRequest.java

示例12: readFrom

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    id = in.readString();
    source = in.readBytesReference();
    if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
        xContentType = XContentType.readFrom(in);
    } else {
        xContentType = XContentFactory.xContentType(source);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:12,代碼來源:PutPipelineRequest.java

示例13: appendField

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
public static void appendField(XContentBuilder builder, String field,
    byte[] data) throws IOException {
  XContentType contentType = XContentFactory.xContentType(data);
  if (contentType == null) {
    addSimpleField(builder, field, data);
  } else {
    addComplexField(builder, field, contentType, data);
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:10,代碼來源:ContentBuilderUtil.java

示例14: toXContent

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的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

示例15: newBuilder

import org.elasticsearch.common.xcontent.XContentFactory; //導入方法依賴的package包/類
public XContentBuilder newBuilder(@Nullable BytesReference autoDetectSource, boolean useFiltering) throws IOException {
    XContentType contentType = XContentType.fromRestContentType(request.param("format", request.header("Content-Type")));
    if (contentType == null) {
        // try and guess it from the auto detect source
        if (autoDetectSource != null) {
            contentType = XContentFactory.xContentType(autoDetectSource);
        }
    }
    if (contentType == null) {
        // default to JSON
        contentType = XContentType.JSON;
    }

    String[] filters = useFiltering ? request.paramAsStringArrayOrEmptyIfAll("filter_path") :  null;
    XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType), bytesOutput(), filters);
    if (request.paramAsBoolean("pretty", false)) {
        builder.prettyPrint().lfAtEnd();
    }

    builder.humanReadable(request.paramAsBoolean("human", builder.humanReadable()));

    String casing = request.param("case");
    if (casing != null) {
        String msg = "Parameter 'case' has been deprecated, all responses will use underscore casing in the future";
        DEPRECATION_LOGGER.deprecated(msg);
    }
    if (casing != null && "camelCase".equals(casing)) {
        builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.CAMELCASE);
    } else {
        // we expect all REST interfaces to write results in underscore casing, so
        // no need for double casing
        builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.NONE);
    }
    return builder;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:36,代碼來源:RestChannel.java


注:本文中的org.elasticsearch.common.xcontent.XContentFactory.xContentType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。