From f28e335233e622c974f4b4f70ae2d5e40d5181f2 Mon Sep 17 00:00:00 2001 From: yogev mets Date: Tue, 26 Jul 2022 22:57:25 +0300 Subject: [PATCH] undo change in wildcard queries to preserve pipeline Signed-off-by: yogev mets --- .../index/search/QueryStringQueryParser.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/search/QueryStringQueryParser.java b/server/src/main/java/org/opensearch/index/search/QueryStringQueryParser.java index a72b4c833bf6e..ae789eaef6a6a 100644 --- a/server/src/main/java/org/opensearch/index/search/QueryStringQueryParser.java +++ b/server/src/main/java/org/opensearch/index/search/QueryStringQueryParser.java @@ -719,10 +719,13 @@ private Query getWildcardQuerySingle(String field, String termStr) throws ParseE Analyzer oldAnalyzer = getAnalyzer(); try { MappedFieldType currentFieldType = queryBuilder.context.fieldMapper(field); - if (currentFieldType != null) { - setAnalyzer(getSearchAnalyzer(currentFieldType)); + if (currentFieldType == null) { + return newUnmappedFieldQuery(field); + } + if (forceAnalyzer != null && (analyzeWildcard || currentFieldType.getTextSearchInfo().isTokenized())) { + setAnalyzer(forceAnalyzer); + return super.getWildcardQuery(currentFieldType.name(), termStr); } - if (getAllowLeadingWildcard() == false && (termStr.startsWith("*") || termStr.startsWith("?"))) { throw new ParseException("'*' or '?' not allowed as first character in WildcardQuery"); } @@ -737,6 +740,7 @@ private Query getWildcardQuerySingle(String field, String termStr) throws ParseE } } + private Analyzer getSearchAnalyzer(MappedFieldType currentFieldType) { if (forceAnalyzer == null) { return queryBuilder.context.getSearchAnalyzer(currentFieldType);