[ https://issues.apache.org/jira/browse/LUCENE-4673?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13548854#comment-13548854 ]
Robert Muir commented on LUCENE-4673: ------------------------------------- quotes have a particular meaning to the queryparser so adding quotes would change things. In general queries' toString is just to be user-readable, not "re-parsable". They don't escape syntax character and so on. > TermQuery.toString() doesn't play nicely with whitespace > -------------------------------------------------------- > > Key: LUCENE-4673 > URL: https://issues.apache.org/jira/browse/LUCENE-4673 > Project: Lucene - Core > Issue Type: Bug > Components: core/search > Affects Versions: 4.0-BETA, 4.1, 3.6.2 > Reporter: Itamar Syn-Hershko > > A TermQuery where term.text() contains whitespace outputs incorrect string > representation: field:foo bar instead of field:"foo bar". A "correct" > representation is such that could be parsed again to the correct Query object > (using the correct analyzer, yes, but still). > This may not be so critical, but in our system we use Lucene's QP to parse > and then pre-process and optimize user queries. To do that we use > Query.toString on some clauses to rebuild the query string. > This can be easily resolved by always adding quote marks before and after the > term text in TermQuery.toString. Testing to see if they are required or not > is too much work and TermQuery is ignorant of quote marks anyway. > Some other scenarios which could benefit from this change is places where > escaped characters are used, such as URLs. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org