Java Code Examples for org.apache.lucene.search.MultiTermQuery#CONSTANT_SCORE_REWRITE
The following examples show how to use
org.apache.lucene.search.MultiTermQuery#CONSTANT_SCORE_REWRITE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryParsers.java From Elasticsearch with Apache License 2.0 | 5 votes |
public static MultiTermQuery.RewriteMethod parseRewriteMethod(ParseFieldMatcher matcher, @Nullable String rewriteMethod, @Nullable MultiTermQuery.RewriteMethod defaultRewriteMethod) { if (rewriteMethod == null) { return defaultRewriteMethod; } if (matcher.match(rewriteMethod, CONSTANT_SCORE)) { return MultiTermQuery.CONSTANT_SCORE_REWRITE; } if (matcher.match(rewriteMethod, SCORING_BOOLEAN)) { return MultiTermQuery.SCORING_BOOLEAN_REWRITE; } if (matcher.match(rewriteMethod, CONSTANT_SCORE_BOOLEAN)) { 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 (matcher.match(rewriteMethodName, TOP_TERMS)) { return new MultiTermQuery.TopTermsScoringBooleanQueryRewrite(size); } if (matcher.match(rewriteMethodName, TOP_TERMS_BOOST)) { return new MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite(size); } if (matcher.match(rewriteMethodName, TOP_TERMS_BLENDED_FREQS)) { return new MultiTermQuery.TopTermsBlendedFreqScoringRewrite(size); } } throw new IllegalArgumentException("Failed to parse rewrite_method [" + rewriteMethod + "]"); }
Example 2
Source File: FieldType.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Expert: Returns the rewrite method for multiterm queries such as wildcards. * @param parser The {@link org.apache.solr.search.QParser} calling the method * @param field The {@link org.apache.solr.schema.SchemaField} of the field to search * @return A suitable rewrite method for rewriting multi-term queries to primitive queries. */ public MultiTermQuery.RewriteMethod getRewriteMethod(QParser parser, SchemaField field) { if (!field.indexed() && field.hasDocValues()) { return new DocValuesRewriteMethod(); } else { return MultiTermQuery.CONSTANT_SCORE_REWRITE; } }
Example 3
Source File: TextFieldMapper.java From crate with Apache License 2.0 | 5 votes |
@Override public Query prefixQuery(String value, MultiTermQuery.RewriteMethod method, QueryShardContext context) { if (prefixFieldType == null || prefixFieldType.accept(value.length()) == false) { return super.prefixQuery(value, method, context); } Query tq = prefixFieldType.termQuery(value, context); if (method == null || method == MultiTermQuery.CONSTANT_SCORE_REWRITE || method == MultiTermQuery.CONSTANT_SCORE_BOOLEAN_REWRITE) { return new ConstantScoreQuery(tq); } return tq; }
Example 4
Source File: QueryParsers.java From crate with Apache License 2.0 | 4 votes |
public static MultiTermQuery.RewriteMethod parseRewriteMethod(@Nullable String rewriteMethod, @Nullable MultiTermQuery.RewriteMethod defaultRewriteMethod, DeprecationHandler deprecationHandler) { if (rewriteMethod == null) { return defaultRewriteMethod; } if (CONSTANT_SCORE.match(rewriteMethod, deprecationHandler)) { return MultiTermQuery.CONSTANT_SCORE_REWRITE; } if (SCORING_BOOLEAN.match(rewriteMethod, deprecationHandler)) { return MultiTermQuery.SCORING_BOOLEAN_REWRITE; } if (CONSTANT_SCORE_BOOLEAN.match(rewriteMethod, deprecationHandler)) { 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, deprecationHandler)) { return new MultiTermQuery.TopTermsScoringBooleanQueryRewrite(size); } if (TOP_TERMS_BOOST.match(rewriteMethodName, deprecationHandler)) { return new MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite(size); } if (TOP_TERMS_BLENDED_FREQS.match(rewriteMethodName, deprecationHandler)) { return new MultiTermQuery.TopTermsBlendedFreqScoringRewrite(size); } } throw new IllegalArgumentException("Failed to parse rewrite_method [" + rewriteMethod + "]"); }