当前位置: 首页>>代码示例>>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;未经允许,请勿转载。