Make check of BooleanClause.Occur[] in MultiFieldQueryParser.parse less stubborn [LUCENE-2518]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
Update the check in:
public static Query parse(Version matchVersion, String query, String[] fields,
BooleanClause.Occur[] flags, Analyzer analyzer) throws ParseException {
if (fields.length != flags.length)
throw new IllegalArgumentException("fields.length != flags.length");
To be:
if (fields.length > flags.length)
So the consumer can use one Occur array and apply fields selectively. The only danger here is with hitting a non-existent cell in flags, and this check will provide this just as well without limiting usability for such cases.
---
Migrated from [LUCENE-2518](https://issues.apache.org/jira/browse/LUCENE-2518) by Itamar Syn-Hershko, updated Nov 30 2013
Contributor guide
Research direction
Start at MultiFieldQueryParser.parse(Version, String, String[], BooleanClause.Occur[], Analyzer), where the current fields.length != flags.length check is shown. Verify behavior for an Occur array shorter than the fields array and confirm that an array longer than the fields array remains acceptable; done means shorter arrays no longer fail this length check while missing flag access remains protected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100