apache / apache/lucene

QueryParser throws exception for string queries ending with ! (exclamation) [LUCENE-4454]

Open
#5,520 0 comments 0 reactions 0 assignees View on GitHub
affects-version:3.5 affects-version:3.6.1 legacy-jira-priority:Minor type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

Query parser does not handle the ! (exclamation point) in the same way as the - (hyphen).

A string query with the final character being a ! causes a ParseException

"foo-" OK
"foo+" OK
"foo!" ERROR - Parse Exception
"foo! " OK (trailing white space)

I am using version 3.5 (have tried 3.6.1 - same issue) I was hoping 2566 may also have fixed this issue

---
Migrated from [LUCENE-4454](https://issues.apache.org/jira/browse/LUCENE-4454) by Andrew Gibb

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the QueryParser behavior with the issue's four query strings, then trace how a terminal ! is parsed relative to - and +. Done means "foo!" parses without a ParseException while the other listed cases continue to work.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.