apache / apache/lucene

MultiFieldQueryParser does not honor default operator when there is a special character [LUCENE-7597]

Open
#8,648 1 comment 0 reactions 0 assignees View on GitHub
affects-version:6.3 legacy-jira-priority:Major module:core/queryparser type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

simple code snippet

MultiFieldQueryParser mp = new MultiFieldQueryParser(new String[]{"test"}, new StandardAnalyzer());
mp.setDefaultOperator(Operator.AND);
System.out.println(mp.parse(qstring));

if qstring is just 2 tokens, e.g: "you me", behavior is correct:

+(test:you) +(test:me)

now if qstring contains 2 tokens connected by a special char, e.g.: "you&me", behavior is always OR, e.g.

(test:you) (test:me)

---
Migrated from [LUCENE-7597](https://issues.apache.org/jira/browse/LUCENE-7597) by John Wang

Contributor guide

Open the contributing guide

Research direction

Start with the MultiFieldQueryParser entry point and reproduce the supplied Java snippet using both space-separated and special-character-separated input. Trace how the default Operator.AND is applied during parsing, and confirm the fix by verifying that the special-character case produces AND-connected clauses like the plain-token case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.