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


Java QueryParsers类代码示例

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


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

示例1: doToQuery

import org.elasticsearch.index.query.support.QueryParsers; //导入依赖的package包/类
@Override
protected Query doToQuery(QueryShardContext context) throws IOException {
    // validate context specific fields
    if (analyzer != null && context.getIndexAnalyzers().get(analyzer) == null) {
        throw new QueryShardException(context, "[" + NAME + "] analyzer [" + analyzer + "] not found");
    }

    MatchQuery matchQuery = new MatchQuery(context);
    matchQuery.setOccur(operator.toBooleanClauseOccur());
    matchQuery.setAnalyzer(analyzer);
    matchQuery.setPhraseSlop(slop);
    matchQuery.setFuzziness(fuzziness);
    matchQuery.setFuzzyPrefixLength(prefixLength);
    matchQuery.setMaxExpansions(maxExpansions);
    matchQuery.setTranspositions(fuzzyTranspositions);
    matchQuery.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(fuzzyRewrite, null));
    matchQuery.setLenient(lenient);
    matchQuery.setCommonTermsCutoff(cutoffFrequency);
    matchQuery.setZeroTermsQuery(zeroTermsQuery);

    Query query = matchQuery.parse(type, fieldName, value);
    return Queries.maybeApplyMinimumShouldMatch(query, minimumShouldMatch);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:MatchQueryBuilder.java

示例2: getRandomRewriteMethod

import org.elasticsearch.index.query.support.QueryParsers; //导入依赖的package包/类
/**
 * Helper method to return a random rewrite method
 */
protected static String getRandomRewriteMethod() {
    String rewrite;
    if (randomBoolean()) {
        rewrite = randomFrom(QueryParsers.CONSTANT_SCORE,
                QueryParsers.SCORING_BOOLEAN,
                QueryParsers.CONSTANT_SCORE_BOOLEAN).getPreferredName();
    } else {
        rewrite = randomFrom(QueryParsers.TOP_TERMS,
                QueryParsers.TOP_TERMS_BOOST,
                QueryParsers.TOP_TERMS_BLENDED_FREQS).getPreferredName() + "1";
    }
    return rewrite;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:AbstractQueryTestCase.java

示例3: newFuzzyQuery

import org.elasticsearch.index.query.support.QueryParsers; //导入依赖的package包/类
@Override
protected Query newFuzzyQuery(Term term, float minimumSimilarity, int prefixLength) {
    String text = term.text();
    int numEdits = FuzzyQuery.floatToEdits(minimumSimilarity, text.codePointCount(0, text.length()));
    FuzzyQuery query = new FuzzyQuery(term, numEdits, prefixLength,
        settings.fuzzyMaxExpansions(), FuzzyQuery.defaultTranspositions);
    QueryParsers.setRewriteMethod(query, settings.fuzzyRewriteMethod());
    return query;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:MapperQueryParser.java

示例4: newFuzzyQuery

import org.elasticsearch.index.query.support.QueryParsers; //导入依赖的package包/类
@Override
protected Query newFuzzyQuery(Term term, float minimumSimilarity, int prefixLength) {
    String text = term.text();
    int numEdits = FuzzyQuery.floatToEdits(minimumSimilarity, text.codePointCount(0, text.length()));
    FuzzyQuery query = new FuzzyQuery(term, numEdits, prefixLength, settings.fuzzyMaxExpansions(), FuzzyQuery.defaultTranspositions);
    QueryParsers.setRewriteMethod(query, settings.fuzzyRewriteMethod());
    return query;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:MapperQueryParser.java

示例5: doToQuery

import org.elasticsearch.index.query.support.QueryParsers; //导入依赖的package包/类
@Override
protected Query doToQuery(QueryShardContext context) throws IOException {
    MultiMatchQuery multiMatchQuery = new MultiMatchQuery(context);
    if (analyzer != null) {
        if (context.getIndexAnalyzers().get(analyzer) == null) {
            throw new QueryShardException(context, "[" + NAME + "] analyzer [" + analyzer + "] not found");
        }
        multiMatchQuery.setAnalyzer(analyzer);
    }
    multiMatchQuery.setPhraseSlop(slop);
    if (fuzziness != null) {
        multiMatchQuery.setFuzziness(fuzziness);
    }
    multiMatchQuery.setFuzzyPrefixLength(prefixLength);
    multiMatchQuery.setMaxExpansions(maxExpansions);
    multiMatchQuery.setOccur(operator.toBooleanClauseOccur());
    if (fuzzyRewrite != null) {
        multiMatchQuery.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(fuzzyRewrite, null));
    }
    if (tieBreaker != null) {
        multiMatchQuery.setTieBreaker(tieBreaker);
    }
    if (cutoffFrequency != null) {
        multiMatchQuery.setCommonTermsCutoff(cutoffFrequency);
    }
    multiMatchQuery.setLenient(lenient);
    multiMatchQuery.setZeroTermsQuery(zeroTermsQuery);

    if (useDisMax != null) { // backwards foobar
        boolean typeUsesDismax = type.tieBreaker() != 1.0f;
        if (typeUsesDismax != useDisMax) {
            if (useDisMax && tieBreaker == null) {
                multiMatchQuery.setTieBreaker(0.0f);
            } else {
                multiMatchQuery.setTieBreaker(1.0f);
            }
        }
    }

    Map<String, Float> newFieldsBoosts = handleFieldsMatchPattern(context.getMapperService(), fieldsBoosts);

    return multiMatchQuery.parse(type, newFieldsBoosts, value, minimumShouldMatch);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:44,代码来源:MultiMatchQueryBuilder.java


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