-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query parts ending with a colon are handled badly [LUCENE-373] #1451
Comments
Shai Erera (@shaie) (migrated from JIRA) This is still a problem with QP. I think we should make the behavior consistent. If "xyz field:" throws ParseException, so should "field: xyz". In fact, I think the latter is a bug - the query will search 'xyz' under "field", even if the user didn't intend to do so. QP already takes Version, so we can fix this bug safely. |
Jan Fruehwacht (migrated from JIRA) Do I understand it correct, that you say that it is bug when because there is also a space before the xyz ? So it should be searched for ' xyz' under field ? Am I right ? Or how do you expect that to work. |
Erick Erickson (@ErickErickson) (migrated from JIRA) 2013 Old JIRA cleanup |
Harish Kayarohanam (migrated from JIRA) My understanding of the above issue and analyze if it really needs a fix, if so where, or to find if it is an enhancement. section 1:>>> If queryString is "title: search", there's no exception. However, the parsed section 2:>>> If queryString is "title: contents: text", section 3:>>> When queryString is "title: text contents:" the above exception is
Now lets comes to lucene context : section 4:>>> This seems inconsistent. Given that it's pointless searching for an empty "title: search" overrides the default field and searches in title field. this is as per design and this cannot do just "search" on default, which breaks the original design. pls refer fields section in http://lucene.apache.org/core/5_2_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description. section 5:>>> and "title: contents: text" section 6:>>> "title: text contents:" to Note: I am taking other programming language syntax just to see which design has stood the test of time .. so that I can infer that it is mostly expected from people and is less confusing. These programming languages have evolved over time, so we can take these section 7:Further discussion on section 5 : whenever and wherever there are statements like the following
The above in section 5 & 7 is just a proposal. Please give your comments. Feel free to point out mistakes. I referred http://lucene.apache.org/core/5_2_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description for better understanding . |
Harish Kayarohanam (migrated from JIRA) So as far my analysis goes , there is no must fix bug here . But there is decision that is pending whether the proposal above can be brought |
I'm using Lucene 1.4.3, running
Query query = QueryParser.parse(queryString, "contents", new StandardAnalyzer());
If queryString is "search title:" i.e. specifying a field name without a
corresponding value, I get a parsing exception:
Encountered "<EOF>" at line 1, column 8.
Was expecting one of:
"(" ...
<QUOTED> ...
<TERM> ...
<PREFIXTERM> ...
<WILDTERM> ...
"[" ...
"{" ...
<NUMBER> ...
If queryString is "title: search", there's no exception. However, the parsed
query which is returned is "title:search". If queryString is "title: contents:
text", the parsed query is "title:contents" and the "text" part is ignored
completely. When queryString is "title: text contents:" the above exception is
produced again.
This seems inconsistent. Given that it's pointless searching for an empty
string (since it has no tokens), I'd expect both "search title:" & "title:
search" to be parsed as "search" (or, given the default field I specified,
"contents:search"), and "title: contents: text" & "title: text contents:" to
parse as "text" ("contents:text") i.e. parts which have no term are ignored. At
worst I'd expect them all to throw a ParseException rather than just the ones
with the colon at the end of the string.
Migrated from LUCENE-373 by Andrew Stevens, 1 vote, updated Jul 28 2015
Environment:
The text was updated successfully, but these errors were encountered: