apache / apache/lucene

QueryParser throwing null pointer exception if input is invalid [LUCENE-2987]

Open
#4,061 3 comments 0 reactions 0 assignees View on GitHub
affects-version:3.0.2 legacy-jira-label:newdev 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

I was using org.apache.lucene.queryParser.QueryParser for parsing the input.
My input:
Input query string: "category: (4 or 6 or 8)"
Analyzer: StandardAnalyzer
QueryParser's parse() method is resulting in Null Pointer Exception.

If i give input query string as "category: (4 OR 6 OR 8)" which is uppercase 'OR', it works fine and i get the desired results.
I'm seeing the problem only with lower case 'or'

---
Migrated from [LUCENE-2987](https://issues.apache.org/jira/browse/LUCENE-2987) by Ramesh, updated Mar 30 2016
Attachments: [LUCENE-2987.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-2987/LUCENE-2987.patch)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with org.apache.lucene.queryParser.QueryParser.parse() using "category: (4 or 6 or 8)" and StandardAnalyzer, then compare it with the uppercase OR input. Done means the lowercase query no longer throws a NullPointerException and produces the expected results.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.