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


Java VersionType.fromString方法代码示例

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


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

示例1: ParsedVersion

import org.elasticsearch.index.VersionType; //导入方法依赖的package包/类
public ParsedVersion(String path, String versionType) {
    this.path = path;
    if (path == null) {
        this.pathElements = Strings.EMPTY_ARRAY;
        this.versionType = VersionType.INTERNAL;
    } else {
        this.versionType = VersionType.fromString(versionType);
        this.pathElements = Strings.delimitedListToStringArray(path, ".");
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:MappingMetaData.java

示例2: parse

import org.elasticsearch.index.VersionType; //导入方法依赖的package包/类
/**
 * Parses and returns the given item.
 */
public static Item parse(XContentParser parser, Item item) throws IOException {
    XContentParser.Token token;
    String currentFieldName = null;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (currentFieldName != null) {
            if (Field.INDEX.match(currentFieldName)) {
                item.index = parser.text();
            } else if (Field.TYPE.match(currentFieldName)) {
                item.type = parser.text();
            } else if (Field.ID.match(currentFieldName)) {
                item.id = parser.text();
            } else if (Field.DOC.match(currentFieldName)) {
                item.doc = jsonBuilder().copyCurrentStructure(parser).bytes();
                item.xContentType = XContentType.JSON;
            } else if (Field.FIELDS.match(currentFieldName)) {
                if (token == XContentParser.Token.START_ARRAY) {
                    List<String> fields = new ArrayList<>();
                    while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
                        fields.add(parser.text());
                    }
                    item.fields(fields.toArray(new String[fields.size()]));
                } else {
                    throw new ElasticsearchParseException(
                            "failed to parse More Like This item. field [fields] must be an array");
                }
            } else if (Field.PER_FIELD_ANALYZER.match(currentFieldName)) {
                item.perFieldAnalyzer(TermVectorsRequest.readPerFieldAnalyzer(parser.map()));
            } else if ("_routing".equals(currentFieldName) || "routing".equals(currentFieldName)) {
                item.routing = parser.text();
            } else if ("_version".equals(currentFieldName) || "version".equals(currentFieldName)) {
                item.version = parser.longValue();
            } else if ("_version_type".equals(currentFieldName) || "_versionType".equals(currentFieldName)
                    || "version_type".equals(currentFieldName) || "versionType".equals(currentFieldName)) {
                item.versionType = VersionType.fromString(parser.text());
            } else {
                throw new ElasticsearchParseException(
                        "failed to parse More Like This item. unknown field [{}]", currentFieldName);
            }
        }
    }
    if (item.id != null && item.doc != null) {
        throw new ElasticsearchParseException(
                "failed to parse More Like This item. either [id] or [doc] can be specified, but not both!");
    }
    if (item.id == null && item.doc == null) {
        throw new ElasticsearchParseException(
                "failed to parse More Like This item. neither [id] nor [doc] is specified!");
    }
    return item;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:56,代码来源:MoreLikeThisQueryBuilder.java

示例3: parseRequest

import org.elasticsearch.index.VersionType; //导入方法依赖的package包/类
/**
 * populates a request object (pre-populated with defaults) based on a parser.
 */
public static void parseRequest(TermVectorsRequest termVectorsRequest, XContentParser parser) throws IOException {
    XContentParser.Token token;
    String currentFieldName = null;
    List<String> fields = new ArrayList<>();
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (currentFieldName != null) {
            if (currentFieldName.equals("fields")) {
                if (token == XContentParser.Token.START_ARRAY) {
                    while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
                        fields.add(parser.text());
                    }
                } else {
                    throw new ElasticsearchParseException("failed to parse term vectors request. field [fields] must be an array");
                }
            } else if (currentFieldName.equals("offsets")) {
                termVectorsRequest.offsets(parser.booleanValue());
            } else if (currentFieldName.equals("positions")) {
                termVectorsRequest.positions(parser.booleanValue());
            } else if (currentFieldName.equals("payloads")) {
                termVectorsRequest.payloads(parser.booleanValue());
            } else if (currentFieldName.equals("term_statistics") || currentFieldName.equals("termStatistics")) {
                termVectorsRequest.termStatistics(parser.booleanValue());
            } else if (currentFieldName.equals("field_statistics") || currentFieldName.equals("fieldStatistics")) {
                termVectorsRequest.fieldStatistics(parser.booleanValue());
            } else if (currentFieldName.equals("dfs")) {
                throw new IllegalArgumentException("distributed frequencies is not supported anymore for term vectors");
            } else if (currentFieldName.equals("per_field_analyzer") || currentFieldName.equals("perFieldAnalyzer")) {
                termVectorsRequest.perFieldAnalyzer(readPerFieldAnalyzer(parser.map()));
            } else if (currentFieldName.equals("filter")) {
                termVectorsRequest.filterSettings(readFilterSettings(parser));
            } else if ("_index".equals(currentFieldName)) { // the following is important for multi request parsing.
                termVectorsRequest.index = parser.text();
            } else if ("_type".equals(currentFieldName)) {
                termVectorsRequest.type = parser.text();
            } else if ("_id".equals(currentFieldName)) {
                if (termVectorsRequest.doc != null) {
                    throw new ElasticsearchParseException("failed to parse term vectors request. either [id] or [doc] can be specified, but not both!");
                }
                termVectorsRequest.id = parser.text();
            } else if ("doc".equals(currentFieldName)) {
                if (termVectorsRequest.id != null) {
                    throw new ElasticsearchParseException("failed to parse term vectors request. either [id] or [doc] can be specified, but not both!");
                }
                termVectorsRequest.doc(jsonBuilder().copyCurrentStructure(parser));
            } else if ("_routing".equals(currentFieldName) || "routing".equals(currentFieldName)) {
                termVectorsRequest.routing = parser.text();
            } else if ("_parent".equals(currentFieldName) || "parent".equals(currentFieldName)) {
                termVectorsRequest.parent = parser.text();
            } else if ("_version".equals(currentFieldName) || "version".equals(currentFieldName)) {
                termVectorsRequest.version = parser.longValue();
            } else if ("_version_type".equals(currentFieldName) || "_versionType".equals(currentFieldName) || "version_type".equals(currentFieldName) || "versionType".equals(currentFieldName)) {
                termVectorsRequest.versionType = VersionType.fromString(parser.text());
            } else {
                throw new ElasticsearchParseException("failed to parse term vectors request. unknown field [{}]", currentFieldName);
            }
        }
    }
    if (fields.size() > 0) {
        String[] fieldsAsArray = new String[fields.size()];
        termVectorsRequest.selectedFields(fields.toArray(fieldsAsArray));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:68,代码来源:TermVectorsRequest.java

示例4: parse

import org.elasticsearch.index.VersionType; //导入方法依赖的package包/类
/**
 * Parses and returns the given item.
 */
public static Item parse(XContentParser parser, ParseFieldMatcher parseFieldMatcher, Item item) throws IOException {
    XContentParser.Token token;
    String currentFieldName = null;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (currentFieldName != null) {
            if (parseFieldMatcher.match(currentFieldName, Field.INDEX)) {
                item.index = parser.text();
            } else if (parseFieldMatcher.match(currentFieldName, Field.TYPE)) {
                item.type = parser.text();
            } else if (parseFieldMatcher.match(currentFieldName, Field.ID)) {
                item.id = parser.text();
            } else if (parseFieldMatcher.match(currentFieldName, Field.DOC)) {
                item.doc(jsonBuilder().copyCurrentStructure(parser));
            } else if (parseFieldMatcher.match(currentFieldName, Field.FIELDS)) {
                if (token == XContentParser.Token.START_ARRAY) {
                    List<String> fields = new ArrayList<>();
                    while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
                        fields.add(parser.text());
                    }
                    item.fields(fields.toArray(new String[fields.size()]));
                } else {
                    throw new ElasticsearchParseException(
                            "failed to parse More Like This item. field [fields] must be an array");
                }
            } else if (parseFieldMatcher.match(currentFieldName, Field.PER_FIELD_ANALYZER)) {
                item.perFieldAnalyzer(TermVectorsRequest.readPerFieldAnalyzer(parser.map()));
            } else if ("_routing".equals(currentFieldName) || "routing".equals(currentFieldName)) {
                item.routing = parser.text();
            } else if ("_version".equals(currentFieldName) || "version".equals(currentFieldName)) {
                item.version = parser.longValue();
            } else if ("_version_type".equals(currentFieldName) || "_versionType".equals(currentFieldName)
                    || "version_type".equals(currentFieldName) || "versionType".equals(currentFieldName)) {
                item.versionType = VersionType.fromString(parser.text());
            } else {
                throw new ElasticsearchParseException(
                        "failed to parse More Like This item. unknown field [{}]", currentFieldName);
            }
        }
    }
    if (item.id != null && item.doc != null) {
        throw new ElasticsearchParseException(
                "failed to parse More Like This item. either [id] or [doc] can be specified, but not both!");
    }
    return item;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:51,代码来源:MoreLikeThisQueryBuilder.java

示例5: parseRequest

import org.elasticsearch.index.VersionType; //导入方法依赖的package包/类
/**
 * populates a request object (pre-populated with defaults) based on a parser.
 */
public static void parseRequest(TermVectorsRequest termVectorsRequest, XContentParser parser) throws IOException {
    XContentParser.Token token;
    String currentFieldName = null;
    List<String> fields = new ArrayList<>();
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (currentFieldName != null) {
            if (currentFieldName.equals("fields")) {
                if (token == XContentParser.Token.START_ARRAY) {
                    while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
                        fields.add(parser.text());
                    }
                } else {
                    throw new ElasticsearchParseException("failed to parse term vectors request. field [fields] must be an array");
                }
            } else if (currentFieldName.equals("offsets")) {
                termVectorsRequest.offsets(parser.booleanValue());
            } else if (currentFieldName.equals("positions")) {
                termVectorsRequest.positions(parser.booleanValue());
            } else if (currentFieldName.equals("payloads")) {
                termVectorsRequest.payloads(parser.booleanValue());
            } else if (currentFieldName.equals("term_statistics") || currentFieldName.equals("termStatistics")) {
                termVectorsRequest.termStatistics(parser.booleanValue());
            } else if (currentFieldName.equals("field_statistics") || currentFieldName.equals("fieldStatistics")) {
                termVectorsRequest.fieldStatistics(parser.booleanValue());
            } else if (currentFieldName.equals("dfs")) {
                termVectorsRequest.dfs(parser.booleanValue());
            } else if (currentFieldName.equals("per_field_analyzer") || currentFieldName.equals("perFieldAnalyzer")) {
                termVectorsRequest.perFieldAnalyzer(readPerFieldAnalyzer(parser.map()));
            } else if (currentFieldName.equals("filter")) {
                termVectorsRequest.filterSettings(readFilterSettings(parser, termVectorsRequest));
            } else if ("_index".equals(currentFieldName)) { // the following is important for multi request parsing.
                termVectorsRequest.index = parser.text();
            } else if ("_type".equals(currentFieldName)) {
                termVectorsRequest.type = parser.text();
            } else if ("_id".equals(currentFieldName)) {
                if (termVectorsRequest.doc != null) {
                    throw new ElasticsearchParseException("failed to parse term vectors request. either [id] or [doc] can be specified, but not both!");
                }
                termVectorsRequest.id = parser.text();
            } else if ("doc".equals(currentFieldName)) {
                if (termVectorsRequest.id != null) {
                    throw new ElasticsearchParseException("failed to parse term vectors request. either [id] or [doc] can be specified, but not both!");
                }
                termVectorsRequest.doc(jsonBuilder().copyCurrentStructure(parser));
            } else if ("_routing".equals(currentFieldName) || "routing".equals(currentFieldName)) {
                termVectorsRequest.routing = parser.text();
            } else if ("_version".equals(currentFieldName) || "version".equals(currentFieldName)) {
                termVectorsRequest.version = parser.longValue();
            } else if ("_version_type".equals(currentFieldName) || "_versionType".equals(currentFieldName) || "version_type".equals(currentFieldName) || "versionType".equals(currentFieldName)) {
                termVectorsRequest.versionType = VersionType.fromString(parser.text());
            } else {
                throw new ElasticsearchParseException("failed to parse term vectors request. unknown field [{}]", currentFieldName);
            }
        }
    }
    if (fields.size() > 0) {
        String[] fieldsAsArray = new String[fields.size()];
        termVectorsRequest.selectedFields(fields.toArray(fieldsAsArray));
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:66,代码来源:TermVectorsRequest.java


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