NPE in Flexible StandardQueryParser on boosting [LUCENE-5491]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
The following exception
```
java.lang.IllegalArgumentException: field name should not be null!
at org.apache.lucene.queryparser.flexible.core.config.FieldConfig.(FieldConfig.java:36)
at org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler.getFieldConfig(QueryConfigHandler.java:59)
at org.apache.lucene.queryparser.flexible.standard.processors.BoostQueryNodeProcessor.postProcessNode(BoostQueryNodeProcessor.java:54)
at org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl.processIteration(QueryNodeProcessorImpl.java:99)
at org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl.processChildren(QueryNodeProcessorImpl.java:125)
at org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl.processIteration(QueryNodeProcessorImpl.java:97)
at org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl.process(QueryNodeProcessorImpl.java:90)
at org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorPipeline.process(QueryNodeProcessorPipeline.java:90)
at org.apache.lucene.queryparser.flexible.core.QueryParserHelper.parse(QueryParserHelper.java:255)
at org.apache.lucene.queryparser.flexible.standard.StandardQueryParser.parse(StandardQueryParser.java:168)
```
is caused by boosting a tokenizable phrase field within a group.
```java
public void testFail() throws Exception {
test("(mimeType:\"text-html\")");
}
public void testOkay() throws Exception {
test("mimeType:\"text-html\"");
}
static void test(String qs) throws Exception {
Analyzer sa = new StandardAnalyzer(Version.LUCENE_46);
StandardQueryParser qp = new StandardQueryParser(sa);
qp.getFieldsBoost().put("mimeType", 1f);
qp.parse(qs, "content");
}
```
---
Migrated from [LUCENE-5491](https://issues.apache.org/jira/browse/LUCENE-5491) by André , updated May 09 2016
Contributor guide
Research direction
Start with BoostQueryNodeProcessor.java and the QueryConfigHandler/FieldConfig stack frames, then run the provided testFail and testOkay cases using StandardQueryParser. The fix is complete when boosting the tokenizable mimeType phrase inside a group no longer throws the null-field exception and the existing ungrouped case still parses.
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