public static MultiTermQuery.RewriteMethod parseRewriteMethod(@Nullable String rewriteMethod, DeprecationHandler deprecationHandler) { return parseRewriteMethod(rewriteMethod, MultiTermQuery.CONSTANT_SCORE_REWRITE, deprecationHandler); }
@Override protected Query doToQuery(QueryShardContext context) throws IOException { MappedFieldType fieldType = context.fieldMapper(fieldName); if (fieldType == null) { return new MatchNoDocsQuery("unknown field [" + fieldName + "]"); } MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod( rewrite, null, LoggingDeprecationHandler.INSTANCE); return fieldType.wildcardQuery(value, method, context); }
@Override protected Query doToQuery(QueryShardContext context) throws IOException { MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null, LoggingDeprecationHandler.INSTANCE); Query query = null; MappedFieldType fieldType = context.fieldMapper(fieldName); if (fieldType != null) { query = fieldType.prefixQuery(value, method, context); } if (query == null) { PrefixQuery prefixQuery = new PrefixQuery(new Term(fieldName, BytesRefs.toBytesRef(value))); if (method != null) { prefixQuery.setRewriteMethod(method); } query = prefixQuery; } return query; }
@Override protected Query doToQuery(QueryShardContext context) throws QueryShardException, IOException { final int maxAllowedRegexLength = context.getIndexSettings().getMaxRegexLength(); if (value.length() > maxAllowedRegexLength) { throw new IllegalArgumentException( "The length of regex [" + value.length() + "] used in the Regexp Query request has exceeded " + "the allowed maximum of [" + maxAllowedRegexLength + "]. " + "This maximum can be set by changing the [" + IndexSettings.MAX_REGEX_LENGTH_SETTING.getKey() + "] index level setting."); } MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null, LoggingDeprecationHandler.INSTANCE); Query query = null; MappedFieldType fieldType = context.fieldMapper(fieldName); if (fieldType != null) { query = fieldType.regexpQuery(value, flagsValue, maxDeterminizedStates, method, context); } if (query == null) { RegexpQuery regexpQuery = new RegexpQuery(new Term(fieldName, BytesRefs.toBytesRef(value)), flagsValue, maxDeterminizedStates); if (method != null) { regexpQuery.setRewriteMethod(method); } query = regexpQuery; } return query; }
@Override protected Query doToQuery(QueryShardContext context) throws IOException { Query query = null; String rewrite = this.rewrite; if (rewrite == null && context.isFilter()) { rewrite = QueryParsers.CONSTANT_SCORE.getPreferredName(); } MappedFieldType fieldType = context.fieldMapper(fieldName); if (fieldType != null) { query = fieldType.fuzzyQuery(value, fuzziness, prefixLength, maxExpansions, transpositions); } if (query == null) { int maxEdits = fuzziness.asDistance(BytesRefs.toString(value)); query = new FuzzyQuery(new Term(fieldName, BytesRefs.toBytesRef(value)), maxEdits, prefixLength, maxExpansions, transpositions); } if (query instanceof MultiTermQuery) { MultiTermQuery.RewriteMethod rewriteMethod = QueryParsers.parseRewriteMethod(rewrite, null, LoggingDeprecationHandler.INSTANCE); QueryParsers.setRewriteMethod((MultiTermQuery) query, rewriteMethod); } return query; }
if (prefixBuilder.rewrite() != null) { MultiTermQuery.RewriteMethod rewriteMethod = QueryParsers.parseRewriteMethod(prefixBuilder.rewrite(), null, LoggingDeprecationHandler.INSTANCE); prefixQuery.setRewriteMethod(rewriteMethod);
queryParser.setFuzzyPrefixLength(fuzzyPrefixLength); queryParser.setFuzzyMaxExpansions(fuzzyMaxExpansions); queryParser.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(this.fuzzyRewrite, LoggingDeprecationHandler.INSTANCE)); queryParser.setMultiTermRewriteMethod(QueryParsers.parseRewriteMethod(this.rewrite, LoggingDeprecationHandler.INSTANCE)); queryParser.setTimeZone(timeZone); queryParser.setMaxDeterminizedStates(maxDeterminizedStates);
multiMatchQuery.setOccur(operator.toBooleanClauseOccur()); if (fuzzyRewrite != null) { multiMatchQuery.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(fuzzyRewrite, null, LoggingDeprecationHandler.INSTANCE));
public static MultiTermQuery.RewriteMethod parseRewriteMethod(@Nullable String rewriteMethod, DeprecationHandler deprecationHandler) { return parseRewriteMethod(rewriteMethod, MultiTermQuery.CONSTANT_SCORE_REWRITE, deprecationHandler); }
public static MultiTermQuery.RewriteMethod parseRewriteMethod(@Nullable String rewriteMethod) { return parseRewriteMethod(rewriteMethod, MultiTermQuery.CONSTANT_SCORE_REWRITE); }
public static MultiTermQuery.RewriteMethod parseRewriteMethod(@Nullable String rewriteMethod, DeprecationHandler deprecationHandler) { return parseRewriteMethod(rewriteMethod, MultiTermQuery.CONSTANT_SCORE_REWRITE, deprecationHandler); }
public static MultiTermQuery.RewriteMethod parseRewriteMethod(ParseFieldMatcher matcher, @Nullable String rewriteMethod) { return parseRewriteMethod(matcher, rewriteMethod, MultiTermQuery.CONSTANT_SCORE_REWRITE); }
@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()); if (analyzer != null) { matchQuery.setAnalyzer(analyzer); } matchQuery.setFuzziness(fuzziness); matchQuery.setFuzzyPrefixLength(prefixLength); matchQuery.setMaxExpansions(maxExpansions); matchQuery.setTranspositions(fuzzyTranspositions); matchQuery.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(fuzzyRewrite, null, LoggingDeprecationHandler.INSTANCE)); matchQuery.setLenient(lenient); matchQuery.setCommonTermsCutoff(cutoffFrequency); matchQuery.setZeroTermsQuery(zeroTermsQuery); matchQuery.setAutoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery); Query query = matchQuery.parse(MatchQuery.Type.BOOLEAN, fieldName, value); return Queries.maybeApplyMinimumShouldMatch(query, minimumShouldMatch); }
public static void setRewriteMethod(MultiTermQuery query, ParseFieldMatcher matcher, @Nullable String rewriteMethod) { if (rewriteMethod == null) { return; } query.setRewriteMethod(parseRewriteMethod(matcher, rewriteMethod)); }
@Override protected Query doToQuery(QueryShardContext context) throws IOException { MappedFieldType fieldType = context.fieldMapper(fieldName); if (fieldType == null) { return new MatchNoDocsQuery("unknown field [" + fieldName + "]"); } MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod( rewrite, null, LoggingDeprecationHandler.INSTANCE); return fieldType.wildcardQuery(value, method, context); }
@Override protected Query doToQuery(QueryShardContext context) throws QueryShardException, IOException { MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null); Query query = null; MappedFieldType fieldType = context.fieldMapper(fieldName); if (fieldType != null) { query = fieldType.regexpQuery(value, flagsValue, maxDeterminizedStates, method, context); } if (query == null) { RegexpQuery regexpQuery = new RegexpQuery(new Term(fieldName, BytesRefs.toBytesRef(value)), flagsValue, maxDeterminizedStates); if (method != null) { regexpQuery.setRewriteMethod(method); } query = regexpQuery; } return query; }
@Override protected Query doToQuery(QueryShardContext context) throws IOException { MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null, LoggingDeprecationHandler.INSTANCE); Query query = null; MappedFieldType fieldType = context.fieldMapper(fieldName); if (fieldType != null) { query = fieldType.prefixQuery(value, method, context); } if (query == null) { PrefixQuery prefixQuery = new PrefixQuery(new Term(fieldName, BytesRefs.toBytesRef(value))); if (method != null) { prefixQuery.setRewriteMethod(method); } query = prefixQuery; } return query; }
@Override protected Query doToQuery(QueryShardContext context) throws IOException { MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null); Query query = null; MappedFieldType fieldType = context.fieldMapper(fieldName); if (fieldType != null) { query = fieldType.prefixQuery(value, method, context); } if (query == null) { PrefixQuery prefixQuery = new PrefixQuery(new Term(fieldName, BytesRefs.toBytesRef(value))); if (method != null) { prefixQuery.setRewriteMethod(method); } query = prefixQuery; } return query; }
@Override protected Query doToQuery(QueryShardContext context) throws IOException { MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null, LoggingDeprecationHandler.INSTANCE); Query query = null; MappedFieldType fieldType = context.fieldMapper(fieldName); if (fieldType != null) { query = fieldType.prefixQuery(value, method, context); } if (query == null) { PrefixQuery prefixQuery = new PrefixQuery(new Term(fieldName, BytesRefs.toBytesRef(value))); if (method != null) { prefixQuery.setRewriteMethod(method); } query = prefixQuery; } return query; }
@Override protected Query doToQuery(QueryShardContext context) throws IOException { MappedFieldType fieldType = context.fieldMapper(fieldName); Term term; if (fieldType == null) { term = new Term(fieldName, BytesRefs.toBytesRef(value)); } else { Query termQuery = fieldType.termQuery(value, context); term = MappedFieldType.extractTerm(termQuery); } WildcardQuery query = new WildcardQuery(term); MultiTermQuery.RewriteMethod rewriteMethod = QueryParsers.parseRewriteMethod(rewrite, null); QueryParsers.setRewriteMethod(query, rewriteMethod); return query; }