Java Code Examples for org.apache.lucene.search.MultiTermQuery#RewriteMethod
The following examples show how to use
org.apache.lucene.search.MultiTermQuery#RewriteMethod .
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: SpanMultiTermQueryWrapper.java From lucene-solr with Apache License 2.0 | 5 votes |
private static SpanRewriteMethod selectRewriteMethod(MultiTermQuery query) { MultiTermQuery.RewriteMethod method = query.getRewriteMethod(); if (method instanceof TopTermsRewrite) { final int pqsize = ((TopTermsRewrite) method).getSize(); return new TopTermsSpanBooleanQueryRewrite(pqsize); } else { return SCORING_SPAN_QUERY_REWRITE; } }
Example 2
Source File: PrefixWildcardQueryNodeBuilder.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public PrefixQuery build(QueryNode queryNode) throws QueryNodeException { PrefixWildcardQueryNode wildcardNode = (PrefixWildcardQueryNode) queryNode; String text = wildcardNode.getText().subSequence(0, wildcardNode.getText().length() - 1).toString(); PrefixQuery q = new PrefixQuery(new Term(wildcardNode.getFieldAsString(), text)); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodProcessor.TAG_ID); if (method != null) { q.setRewriteMethod(method); } return q; }
Example 3
Source File: WildcardQueryNodeBuilder.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public WildcardQuery build(QueryNode queryNode) throws QueryNodeException { WildcardQueryNode wildcardNode = (WildcardQueryNode) queryNode; WildcardQuery q = new WildcardQuery(new Term(wildcardNode.getFieldAsString(), wildcardNode.getTextAsString())); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.getTag(MultiTermRewriteMethodProcessor.TAG_ID); if (method != null) { q.setRewriteMethod(method); } return q; }
Example 4
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 5
Source File: ArrayFieldType.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public Query regexpQuery(String value, int flags, int maxDeterminizedStates, @Nullable MultiTermQuery.RewriteMethod method, @Nullable QueryParseContext context) { return innerFieldType.regexpQuery(value, flags, maxDeterminizedStates, method, context); }
Example 6
Source File: MappedFieldType.java From crate with Apache License 2.0 | 4 votes |
public Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, QueryShardContext context) { throw new QueryShardException(context, "Can only use prefix queries on keyword and text fields - not on [" + name + "] which is of type [" + typeName() + "]"); }
Example 7
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 + "]"); }
Example 8
Source File: StandardQueryParser.java From lucene-solr with Apache License 2.0 | 4 votes |
/** * @see #setMultiTermRewriteMethod(org.apache.lucene.search.MultiTermQuery.RewriteMethod) */ @Override public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod() { return getQueryConfigHandler().get(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD); }
Example 9
Source File: ReferenceMapper.java From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 | 4 votes |
@Override public Query regexpQuery(String value, int flags, int maxDeterminizedStates, MultiTermQuery.RewriteMethod method, QueryShardContext context) { throw new UnsupportedOperationException(); }
Example 10
Source File: MatchQuery.java From crate with Apache License 2.0 | 4 votes |
public void setFuzzyRewriteMethod(MultiTermQuery.RewriteMethod fuzzyRewriteMethod) { this.fuzzyRewriteMethod = fuzzyRewriteMethod; }
Example 11
Source File: QueryParsers.java From crate with Apache License 2.0 | 4 votes |
public static void setRewriteMethod(MultiTermQuery query, @Nullable MultiTermQuery.RewriteMethod rewriteMethod) { if (rewriteMethod == null) { return; } query.setRewriteMethod(rewriteMethod); }
Example 12
Source File: QueryParsers.java From Elasticsearch with Apache License 2.0 | 4 votes |
public static MultiTermQuery.RewriteMethod parseRewriteMethod(ParseFieldMatcher matcher, @Nullable String rewriteMethod) { return parseRewriteMethod(matcher, rewriteMethod, MultiTermQuery.CONSTANT_SCORE_REWRITE); }
Example 13
Source File: QueryParsers.java From Elasticsearch with Apache License 2.0 | 4 votes |
public static void setRewriteMethod(MultiTermQuery query, @Nullable MultiTermQuery.RewriteMethod rewriteMethod) { if (rewriteMethod == null) { return; } query.setRewriteMethod(rewriteMethod); }
Example 14
Source File: QueryParserSettings.java From Elasticsearch with Apache License 2.0 | 4 votes |
public MultiTermQuery.RewriteMethod rewriteMethod() { return this.rewriteMethod; }
Example 15
Source File: QueryParserSettings.java From Elasticsearch with Apache License 2.0 | 4 votes |
public MultiTermQuery.RewriteMethod fuzzyRewriteMethod() { return fuzzyRewriteMethod; }
Example 16
Source File: IcuCollationKeyFieldMapper.java From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 | 4 votes |
@Override public Query prefixQuery(String value, MultiTermQuery.RewriteMethod method, QueryShardContext context) { throw new UnsupportedOperationException(); }
Example 17
Source File: ArrayFieldType.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public Query prefixQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, @Nullable QueryParseContext context) { return innerFieldType.prefixQuery(value, method, context); }
Example 18
Source File: CommonQueryParserConfiguration.java From lucene-solr with Apache License 2.0 | 2 votes |
/** * By default, it uses * {@link MultiTermQuery#CONSTANT_SCORE_REWRITE} when creating a * prefix, wildcard and range queries. This implementation is generally * preferable because it a) Runs faster b) Does not have the scarcity of terms * unduly influence score c) avoids any {@link TooManyListenersException} * exception. However, if your application really needs to use the * old-fashioned boolean queries expansion rewriting and the above points are * not relevant then use this change the rewrite method. */ public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method);
Example 19
Source File: StandardQueryParser.java From lucene-solr with Apache License 2.0 | 2 votes |
/** * By default, it uses * {@link MultiTermQuery#CONSTANT_SCORE_REWRITE} when creating a * prefix, wildcard and range queries. This implementation is generally * preferable because it a) Runs faster b) Does not have the scarcity of terms * unduly influence score c) avoids any {@link TooManyListenersException} * exception. However, if your application really needs to use the * old-fashioned boolean queries expansion rewriting and the above points are * not relevant then use this change the rewrite method. */ @Override public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method) { getQueryConfigHandler().set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, method); }
Example 20
Source File: SolrQueryParserBase.java From lucene-solr with Apache License 2.0 | 2 votes |
/** * By default QueryParser uses {@link org.apache.lucene.search.MultiTermQuery#CONSTANT_SCORE_REWRITE} * when creating a PrefixQuery, WildcardQuery or RangeQuery. This implementation is generally preferable because it * a) Runs faster b) Does not have the scarcity of terms unduly influence score * c) avoids any "TooManyBooleanClauses" exception. * However, if your application really needs to use the * old-fashioned BooleanQuery expansion rewriting and the above * points are not relevant then use this to change * the rewrite method. */ public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method) { multiTermRewriteMethod = method; }