List of usage examples for org.apache.lucene.search MultiTermQuery SCORING_BOOLEAN_REWRITE
RewriteMethod SCORING_BOOLEAN_REWRITE
To view the source code for org.apache.lucene.search MultiTermQuery SCORING_BOOLEAN_REWRITE.
Click Source Link
From source file:org.codelibs.elasticsearch.index.query.support.QueryParsers.java
License:Apache License
public static MultiTermQuery.RewriteMethod parseRewriteMethod(@Nullable String rewriteMethod, @Nullable MultiTermQuery.RewriteMethod defaultRewriteMethod) { if (rewriteMethod == null) { return defaultRewriteMethod; }/*from w ww . j av a 2s.com*/ if (CONSTANT_SCORE.match(rewriteMethod)) { return MultiTermQuery.CONSTANT_SCORE_REWRITE; } if (SCORING_BOOLEAN.match(rewriteMethod)) { return MultiTermQuery.SCORING_BOOLEAN_REWRITE; } if (CONSTANT_SCORE_BOOLEAN.match(rewriteMethod)) { return MultiTermQuery.CONSTANT_SCORE_BOOLEAN_REWRITE; } int firstDigit = -1; for (int i = 0; i < rewriteMethod.length(); ++i) { if (Character.isDigit(rewriteMethod.charAt(i))) { firstDigit = i; break; } } if (firstDigit >= 0) { final int size = Integer.parseInt(rewriteMethod.substring(firstDigit)); String rewriteMethodName = rewriteMethod.substring(0, firstDigit); if (TOP_TERMS.match(rewriteMethodName)) { return new MultiTermQuery.TopTermsScoringBooleanQueryRewrite(size); } if (TOP_TERMS_BOOST.match(rewriteMethodName)) { return new MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite(size); } if (TOP_TERMS_BLENDED_FREQS.match(rewriteMethodName)) { return new MultiTermQuery.TopTermsBlendedFreqScoringRewrite(size); } } throw new IllegalArgumentException("Failed to parse rewrite_method [" + rewriteMethod + "]"); }