Skip to content

Commit 10bc80b

Browse files
committed
Query DSL: query_string analyze wildcard option with prefix to automatically do OR'ed wildcard when its broken down into several tokens, closes elastic#1539.
1 parent 26e8622 commit 10bc80b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modules/elasticsearch/src/main/java/org/apache/lucene/queryParser/MapperQueryParser.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,15 @@ private Query getPossiblyAnalyzedPrefixQuery(String field, String termStr) throw
222222
if (tlist.size() == 1) {
223223
return super.getPrefixQuery(field, tlist.get(0));
224224
} else {
225-
return super.getPrefixQuery(field, termStr);
225+
// build a boolean query with prefix on each one...
226+
List<BooleanClause> clauses = new ArrayList<BooleanClause>();
227+
for (String token : tlist) {
228+
clauses.add(new BooleanClause(super.getPrefixQuery(field, token), BooleanClause.Occur.SHOULD));
229+
}
230+
return getBooleanQuery(clauses, true);
231+
232+
//return super.getPrefixQuery(field, termStr);
233+
226234
/* this means that the analyzer used either added or consumed
227235
* (common for a stemmer) tokens, and we can't build a PrefixQuery */
228236
// throw new ParseException("Cannot build PrefixQuery with analyzer "

0 commit comments

Comments
 (0)