本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}