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


Java XContentParser.objectText方法代码示例

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


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

示例1: fromXContent

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
public static MatchPhrasePrefixQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
    XContentParser parser = parseContext.parser();
    String fieldName = null;
    Object value = null;
    float boost = AbstractQueryBuilder.DEFAULT_BOOST;
    String analyzer = null;
    int slop = MatchQuery.DEFAULT_PHRASE_SLOP;
    int maxExpansion = FuzzyQuery.defaultMaxExpansions;
    String queryName = null;
    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 (parseContext.isDeprecatedSetting(currentFieldName)) {
            // skip
        } else if (token == XContentParser.Token.START_OBJECT) {
            throwParsingExceptionOnMultipleFields(NAME, parser.getTokenLocation(), fieldName, currentFieldName);
            fieldName = currentFieldName;
            while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
                if (token == XContentParser.Token.FIELD_NAME) {
                    currentFieldName = parser.currentName();
                } else if (token.isValue()) {
                    if (MatchQueryBuilder.QUERY_FIELD.match(currentFieldName)) {
                        value = parser.objectText();
                    } else if (MatchQueryBuilder.ANALYZER_FIELD.match(currentFieldName)) {
                        analyzer = parser.text();
                    } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
                        boost = parser.floatValue();
                    } else if (MatchPhraseQueryBuilder.SLOP_FIELD.match(currentFieldName)) {
                        slop = parser.intValue();
                    } else if (MAX_EXPANSIONS_FIELD.match(currentFieldName)) {
                        maxExpansion = parser.intValue();
                    } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
                        queryName = parser.text();
                    } else {
                        throw new ParsingException(parser.getTokenLocation(),
                                "[" + NAME + "] query does not support [" + currentFieldName + "]");
                    }
                } else {
                    throw new ParsingException(parser.getTokenLocation(),
                            "[" + NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]");
                }
            }
        } else {
            throwParsingExceptionOnMultipleFields(NAME, parser.getTokenLocation(), fieldName, parser.currentName());
            fieldName = parser.currentName();
            value = parser.objectText();
        }
    }

    MatchPhrasePrefixQueryBuilder matchQuery = new MatchPhrasePrefixQueryBuilder(fieldName, value);
    matchQuery.analyzer(analyzer);
    matchQuery.slop(slop);
    matchQuery.maxExpansions(maxExpansion);
    matchQuery.queryName(queryName);
    matchQuery.boost(boost);
    return matchQuery;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:60,代码来源:MatchPhrasePrefixQueryBuilder.java

示例2: fromXContent

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
public static MatchPhraseQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
    XContentParser parser = parseContext.parser();
    String fieldName = null;
    Object value = null;
    float boost = AbstractQueryBuilder.DEFAULT_BOOST;
    String analyzer = null;
    int slop = MatchQuery.DEFAULT_PHRASE_SLOP;
    String queryName = null;
    String currentFieldName = null;
    XContentParser.Token token;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (parseContext.isDeprecatedSetting(currentFieldName)) {
            // skip
        } else if (token == XContentParser.Token.START_OBJECT) {
            throwParsingExceptionOnMultipleFields(NAME, parser.getTokenLocation(), fieldName, currentFieldName);
            fieldName = currentFieldName;
            while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
                if (token == XContentParser.Token.FIELD_NAME) {
                    currentFieldName = parser.currentName();
                } else if (token.isValue()) {
                    if (MatchQueryBuilder.QUERY_FIELD.match(currentFieldName)) {
                        value = parser.objectText();
                    } else if (MatchQueryBuilder.ANALYZER_FIELD.match(currentFieldName)) {
                        analyzer = parser.text();
                    } else if (AbstractQueryBuilder.BOOST_FIELD.match(currentFieldName)) {
                        boost = parser.floatValue();
                    } else if (SLOP_FIELD.match(currentFieldName)) {
                        slop = parser.intValue();
                    } else if (AbstractQueryBuilder.NAME_FIELD.match(currentFieldName)) {
                        queryName = parser.text();
                    } else {
                        throw new ParsingException(parser.getTokenLocation(),
                                "[" + NAME + "] query does not support [" + currentFieldName + "]");
                    }
                } else {
                    throw new ParsingException(parser.getTokenLocation(),
                            "[" + NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]");
                }
            }
        } else {
            throwParsingExceptionOnMultipleFields(NAME, parser.getTokenLocation(), fieldName, parser.currentName());
            fieldName = parser.currentName();
            value = parser.objectText();
        }
    }

    MatchPhraseQueryBuilder matchQuery = new MatchPhraseQueryBuilder(fieldName, value);
    matchQuery.analyzer(analyzer);
    matchQuery.slop(slop);
    matchQuery.queryName(queryName);
    matchQuery.boost(boost);
    return matchQuery;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:56,代码来源:MatchPhraseQueryBuilder.java


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