• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java QueryParsingException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.index.query.QueryParsingException的典型用法代码示例。如果您正苦于以下问题:Java QueryParsingException类的具体用法?Java QueryParsingException怎么用?Java QueryParsingException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



QueryParsingException类属于org.elasticsearch.index.query包,在下文中一共展示了QueryParsingException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: parse

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
@Override
public SignificanceHeuristic parse(XContentParser parser, ParseFieldMatcher parseFieldMatcher, SearchContext context)
        throws IOException, QueryParsingException {
    String givenName = parser.currentName();
    boolean includeNegatives = false;
    boolean backgroundIsSuperset = true;
    XContentParser.Token token = parser.nextToken();
    while (!token.equals(XContentParser.Token.END_OBJECT)) {
        if (parseFieldMatcher.match(parser.currentName(), INCLUDE_NEGATIVES_FIELD)) {
            parser.nextToken();
            includeNegatives = parser.booleanValue();
        } else if (parseFieldMatcher.match(parser.currentName(), BACKGROUND_IS_SUPERSET)) {
            parser.nextToken();
            backgroundIsSuperset = parser.booleanValue();
        } else {
            throw new ElasticsearchParseException("failed to parse [{}] significance heuristic. unknown field [{}]", givenName, parser.currentName());
        }
        token = parser.nextToken();
    }
    return newHeuristic(includeNegatives, backgroundIsSuperset);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:NXYSignificanceHeuristic.java


示例2: parse

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
@Override
public SignificanceHeuristic parse(XContentParser parser, ParseFieldMatcher parseFieldMatcher, SearchContext context)
        throws IOException, QueryParsingException {
    String givenName = parser.currentName();
    boolean backgroundIsSuperset = true;
    XContentParser.Token token = parser.nextToken();
    while (!token.equals(XContentParser.Token.END_OBJECT)) {
        if (parseFieldMatcher.match(parser.currentName(), BACKGROUND_IS_SUPERSET)) {
            parser.nextToken();
            backgroundIsSuperset = parser.booleanValue();
        } else {
            throw new ElasticsearchParseException("failed to parse [{}] significance heuristic. unknown field [{}]", givenName, parser.currentName());
        }
        token = parser.nextToken();
    }
    return newHeuristic(true, backgroundIsSuperset);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:GND.java


示例3: parseVariable

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
private AbstractDistanceScoreFunction parseVariable(String fieldName, XContentParser parser, QueryParseContext parseContext, MultiValueMode mode) throws IOException {

        // now, the field must exist, else we cannot read the value for
        // the doc later
        MappedFieldType fieldType = parseContext.fieldMapper(fieldName);
        if (fieldType == null) {
            throw new QueryParsingException(parseContext, "unknown field [{}]", fieldName);
        }

        // dates and time need special handling
        parser.nextToken();
        if (fieldType instanceof DateFieldMapper.DateFieldType) {
            return parseDateVariable(fieldName, parser, parseContext, (DateFieldMapper.DateFieldType) fieldType, mode);
        } else if (fieldType instanceof GeoPointFieldMapper.GeoPointFieldType) {
            return parseGeoVariable(fieldName, parser, parseContext, (GeoPointFieldMapper.GeoPointFieldType) fieldType, mode);
        } else if (fieldType instanceof NumberFieldMapper.NumberFieldType) {
            return parseNumberVariable(fieldName, parser, parseContext, (NumberFieldMapper.NumberFieldType) fieldType, mode);
        } else {
            throw new QueryParsingException(parseContext, "field [{}] is of type [{}], but only numeric types are supported.", fieldName, fieldType);
        }
    }
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:DecayFunctionParser.java


示例4: parseScoreMode

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
private FiltersFunctionScoreQuery.ScoreMode parseScoreMode(QueryParseContext parseContext, XContentParser parser) throws IOException {
    String scoreMode = parser.text();
    if ("avg".equals(scoreMode)) {
        return FiltersFunctionScoreQuery.ScoreMode.Avg;
    } else if ("max".equals(scoreMode)) {
        return FiltersFunctionScoreQuery.ScoreMode.Max;
    } else if ("min".equals(scoreMode)) {
        return FiltersFunctionScoreQuery.ScoreMode.Min;
    } else if ("sum".equals(scoreMode)) {
        return FiltersFunctionScoreQuery.ScoreMode.Sum;
    } else if ("multiply".equals(scoreMode)) {
        return FiltersFunctionScoreQuery.ScoreMode.Multiply;
    } else if ("first".equals(scoreMode)) {
        return FiltersFunctionScoreQuery.ScoreMode.First;
    } else {
        throw new QueryParsingException(parseContext, "failed to parse [{}] query. illegal score_mode [{}]", NAME, scoreMode);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:FunctionScoreQueryParser.java


示例5: parse

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
public InnerHitsSubSearchContext parse(QueryParseContext parserContext) throws IOException, QueryParsingException {
    String fieldName = null;
    XContentParser.Token token;
    String innerHitName = null;
    SubSearchContext subSearchContext = new SubSearchContext(SearchContext.current());
    try {
        XContentParser parser = parserContext.parser();
        while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
            if (token == XContentParser.Token.FIELD_NAME) {
                fieldName = parser.currentName();
            } else if (token.isValue()) {
                if ("name".equals(fieldName)) {
                    innerHitName = parser.textOrNull();
                } else {
                    parseCommonInnerHitOptions(parser, token, fieldName, subSearchContext, sortParseElement, sourceParseElement, highlighterParseElement, scriptFieldsParseElement, fieldDataFieldsParseElement);
                }
            } else {
                parseCommonInnerHitOptions(parser, token, fieldName, subSearchContext, sortParseElement, sourceParseElement, highlighterParseElement, scriptFieldsParseElement, fieldDataFieldsParseElement);
            }
        }
    } catch (Exception e) {
        throw new QueryParsingException(parserContext, "Failed to parse [_inner_hits]", e);
    }
    return new InnerHitsSubSearchContext(innerHitName, subSearchContext);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:InnerHitsQueryParserHelper.java


示例6: getInnerFilter

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
public Query getInnerFilter() throws IOException {
    if (filterParsed) {
        return innerFilter;
    } else {
        if (path == null) {
            throw new QueryParsingException(parseContext, "[nested] requires 'path' field");
        }
        if (!filterFound) {
            throw new QueryParsingException(parseContext, "[nested] requires either 'query' or 'filter' field");
        }

        setPathLevel();
        XContentParser old = parseContext.parser();
        try {
            XContentParser innerParser = XContentHelper.createParser(source);
            parseContext.parser(innerParser);
            innerFilter = parseContext.parseInnerFilter();
            filterParsed = true;
            return innerFilter;
        } finally {
            resetPathLevel();
            parseContext.parser(old);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:NestedInnerQueryParseSupport.java


示例7: parse

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
@Override
    public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException {
        XContentParser parser = parseContext.parser();

        XContentParser.Token token = parser.nextToken();
        if (token != XContentParser.Token.FIELD_NAME) {
            throw new QueryParsingException(parseContext, "[armorWrapper] query malformed");
        }
        String fieldName = parser.currentName();
        if (!fieldName.equals("query")) {
            throw new QueryParsingException(parseContext, "[armorWrapper] query malformed");
        }
        parser.nextToken();

//        String querySource = parser.text();
        Query query = parseContext.parseInnerQuery();
        if (parser.nextToken() != XContentParser.Token.END_OBJECT) {
            throw new QueryParsingException(parseContext, "[armorWrapper] query malformed");
        }
        return query;
    }
 
开发者ID:petalmd,项目名称:armor,代码行数:22,代码来源:ArmorWrapperQueryParser.java


示例8: parseCondArray

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
private List<CondBoostEntry> parseCondArray(QueryParseContext parseContext, XContentParser parser, String currentFieldName) throws IOException {
    XContentParser.Token token;
    List<CondBoostEntry> condArray = new LinkedList<>();
    while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
        if (token != XContentParser.Token.START_OBJECT) {
            throw new QueryParsingException(parseContext, "malformed query, expected a "
                    + XContentParser.Token.START_OBJECT + " while parsing cond boost array, but got a " + token);
        } else {
            CondBoostEntry entry = new CondBoostEntry();
            while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
                if (token == XContentParser.Token.FIELD_NAME) {
                    currentFieldName = parser.currentName();
                } else {
                    if (CondBoostEntry.BOOST.equals(currentFieldName)) {
                        entry.boost = parser.floatValue();
                    } else {
                        entry.fieldName = currentFieldName;
                        entry.fieldValue = parser.text();
                    }
                }
            }
            condArray.add(entry);
        }
    }
    return condArray;
}
 
开发者ID:jprante,项目名称:elasticsearch-functionscore-conditionalboost,代码行数:27,代码来源:CondBoostFactorFunctionParser.java


示例9: parse

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
@Override
public SignificanceHeuristic parse(XContentParser parser, ParseFieldMatcher parseFieldMatcher, SearchContext context)
        throws IOException, QueryParsingException {
    // move to the closing bracket
    if (!parser.nextToken().equals(XContentParser.Token.END_OBJECT)) {
        throw new ElasticsearchParseException("failed to parse [jhl] significance heuristic. expected an empty object, but found [{}] instead", parser.currentToken());
    }
    return new JLHScore();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:JLHScore.java


示例10: parse

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
@Override
public SignificanceHeuristic parse(XContentParser parser, ParseFieldMatcher parseFieldMatcher, SearchContext context)
        throws IOException, QueryParsingException {
    // move to the closing bracket
    if (!parser.nextToken().equals(XContentParser.Token.END_OBJECT)) {
        throw new ElasticsearchParseException("failed to parse [percentage] significance heuristic. expected an empty object, but got [{}] instead", parser.currentToken());
    }
    return new PercentageScore();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:PercentageScore.java


示例11: parse

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
/**
 * Parses bodies of the kind
 *
 * <pre>
 * <code>
 * {
 *      "fieldname1" : {
 *          "origin" = "someValue",
 *          "scale" = "someValue"
 *      }
 *
 * }
 * </code>
 * </pre>
 *
 * */
@Override
public ScoreFunction parse(QueryParseContext parseContext, XContentParser parser) throws IOException, QueryParsingException {
    String currentFieldName;
    XContentParser.Token token;
    AbstractDistanceScoreFunction scoreFunction;
    String multiValueMode = "MIN";
    XContentBuilder variableContent = XContentFactory.jsonBuilder();
    String fieldName = null;
    while ((token = parser.nextToken()) == XContentParser.Token.FIELD_NAME) {
        currentFieldName = parser.currentName();
        token = parser.nextToken();
        if (token == XContentParser.Token.START_OBJECT) {
            variableContent.copyCurrentStructure(parser);
            fieldName = currentFieldName;
        } else if (parseContext.parseFieldMatcher().match(currentFieldName, MULTI_VALUE_MODE)) {
            multiValueMode = parser.text();
        } else {
            throw new ElasticsearchParseException("malformed score function score parameters.");
        }
    }
    if (fieldName == null) {
        throw new ElasticsearchParseException("malformed score function score parameters.");
    }
    XContentParser variableParser = XContentFactory.xContent(variableContent.string()).createParser(variableContent.string());
    scoreFunction = parseVariable(fieldName, variableParser, parseContext, MultiValueMode.fromString(multiValueMode.toUpperCase(Locale.ROOT)));
    return scoreFunction;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:44,代码来源:DecayFunctionParser.java


示例12: parseBoostMode

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
private CombineFunction parseBoostMode(QueryParseContext parseContext, XContentParser parser) throws IOException {
    String boostMode = parser.text();
    CombineFunction cf = combineFunctionsMap.get(boostMode);
    if (cf == null) {
        throw new QueryParsingException(parseContext, "failed to parse [{}] query. illegal boost_mode [{}]", NAME, boostMode);
    }
    return cf;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:FunctionScoreQueryParser.java


示例13: get

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
public ScoreFunctionParser get(QueryParseContext parseContext, String parserName) {
    ScoreFunctionParser functionParser = get(parserName);
    if (functionParser == null) {
        throw new QueryParsingException(parseContext, "No function with the name [" + parserName + "] is registered.", null);
    }
    return functionParser;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:ScoreFunctionParserMapper.java


示例14: getInnerQuery

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
public Query getInnerQuery() throws IOException {
    if (queryParsed) {
        return innerQuery;
    } else {
        if (path == null) {
            throw new QueryParsingException(parseContext, "[nested] requires 'path' field");
        }
        if (!queryFound) {
            throw new QueryParsingException(parseContext, "[nested] requires either 'query' or 'filter' field");
        }

        XContentParser old = parseContext.parser();
        try {
            XContentParser innerParser = XContentHelper.createParser(source);
            parseContext.parser(innerParser);
            setPathLevel();
            try {
                innerQuery = parseContext.parseInnerQuery();
            } finally {
                resetPathLevel();
            }
            queryParsed = true;
            return innerQuery;
        } finally {
            parseContext.parser(old);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:29,代码来源:NestedInnerQueryParseSupport.java


示例15: setPath

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
public void setPath(String path) {
    this.path = path;
    nestedObjectMapper = parseContext.getObjectMapper(path);
    if (nestedObjectMapper == null) {
        throw new QueryParsingException(parseContext, "[nested] failed to find nested object under path [" + path + "]");
    }
    if (!nestedObjectMapper.nested().isNested()) {
        throw new QueryParsingException(parseContext, "[nested] nested object under path [" + path + "] is not of nested type");
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:NestedInnerQueryParseSupport.java


示例16: parseQuery

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
private Query parseQuery(String type, XContentParser parser) {
    String[] previousTypes = null;
    if (type != null) {
        QueryParseContext.setTypesWithPrevious(new String[]{type});
    }
    QueryParseContext context = queryParserService.getParseContext();
    try {
        context.reset(parser);
        // This means that fields in the query need to exist in the mapping prior to registering this query
        // The reason that this is required, is that if a field doesn't exist then the query assumes defaults, which may be undesired.
        //
        // Even worse when fields mentioned in percolator queries do go added to map after the queries have been registered
        // then the percolator queries don't work as expected any more.
        //
        // Query parsing can't introduce new fields in mappings (which happens when registering a percolator query),
        // because field type can't be inferred from queries (like document do) so the best option here is to disallow
        // the usage of unmapped fields in percolator queries to avoid unexpected behaviour
        //
        // if index.percolator.map_unmapped_fields_as_string is set to true, query can contain unmapped fields which will be mapped
        // as an analyzed string.
        context.setAllowUnmappedFields(false);
        context.setMapUnmappedFieldAsString(mapUnmappedFieldsAsString ? true : false);
        return queryParserService.parseInnerQuery(context);
    } catch (IOException e) {
        throw new QueryParsingException(context, "Failed to parse", e);
    } finally {
        if (type != null) {
            QueryParseContext.setTypes(previousTypes);
        }
        context.reset(null);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:33,代码来源:PercolatorQueriesRegistry.java


示例17: prepareDeleteByQuery

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
private static Engine.DeleteByQuery prepareDeleteByQuery(IndexQueryParserService queryParserService, MapperService mapperService, IndexAliasesService indexAliasesService, IndexCache indexCache, BytesReference source, @Nullable String[] filteringAliases, Engine.Operation.Origin origin, String... types) {
    long startTime = System.nanoTime();
    if (types == null) {
        types = Strings.EMPTY_ARRAY;
    }
    Query query;
    try {
        query = queryParserService.parseQuery(source).query();
    } catch (QueryParsingException ex) {
        // for BWC we try to parse directly the query since pre 1.0.0.Beta2 we didn't require a top level query field
        if (queryParserService.getIndexCreatedVersion().onOrBefore(Version.V_1_0_0_Beta2)) {
            try {
                XContentParser parser = XContentHelper.createParser(source);
                ParsedQuery parse = queryParserService.parse(parser);
                query = parse.query();
            } catch (Throwable t) {
                ex.addSuppressed(t);
                throw ex;
            }
        } else {
            throw ex;
        }
    }
    Query searchFilter = mapperService.searchFilter(types);
    if (searchFilter != null) {
        query = Queries.filtered(query, searchFilter);
    }

    Query aliasFilter = indexAliasesService.aliasFilter(filteringAliases);
    BitSetProducer parentFilter = mapperService.hasNested() ? indexCache.bitsetFilterCache().getBitSetProducer(Queries.newNonNestedFilter()) : null;
    return new Engine.DeleteByQuery(query, source, filteringAliases, aliasFilter, parentFilter, origin, startTime, types);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:33,代码来源:TranslogRecoveryPerformer.java


示例18: parse

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
@Override
public ScoreFunction parse(QueryParseContext parseContext, XContentParser parser) throws IOException, QueryParsingException {
    String currentFieldName = null;
    List<CondBoostEntry> condArray = new LinkedList<>();
    float defaultBoost = 1.0f;
    float boostFactor = 1.0f;
    CondBoostFactorFunction.Modifier modifier = CondBoostFactorFunction.Modifier.NONE;
    XContentParser.Token token;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (token == XContentParser.Token.START_ARRAY) {
            condArray = parseCondArray(parseContext, parser, currentFieldName);
        } else if (token.isValue()) {
            if (currentFieldName != null) {
                switch (currentFieldName) {
                    case CondBoostEntry.BOOST:
                        defaultBoost = parser.floatValue();
                        break;
                    case "factor":
                        boostFactor = parser.floatValue();
                        break;
                    case "modifier":
                        modifier = CondBoostFactorFunction.Modifier.valueOf(parser.text().toUpperCase(Locale.ROOT));
                        break;
                    default:
                        throw new QueryParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]");
                }
            }
        }
    }
    return new CondBoostFactorFunction(parseContext, condArray, defaultBoost, boostFactor, modifier);
}
 
开发者ID:jprante,项目名称:elasticsearch-functionscore-conditionalboost,代码行数:34,代码来源:CondBoostFactorFunctionParser.java


示例19: parse

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
SignificanceHeuristic parse(XContentParser parser, ParseFieldMatcher parseFieldMatcher, SearchContext context) throws IOException,
QueryParsingException;
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:3,代码来源:SignificanceHeuristicParser.java


示例20: parse

import org.elasticsearch.index.query.QueryParsingException; //导入依赖的package包/类
@Override
public ScoreFunction parse(QueryParseContext parseContext, XContentParser parser) throws IOException, QueryParsingException {
    float boostFactor = parser.floatValue();
    return new BoostScoreFunction(boostFactor);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:FactorParser.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Injection类代码示例发布时间:2022-05-22
下一篇:
Java Results类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap