Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-4673

TermQuery.toString() doesn't play nicely with whitespace

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.0-BETA, 4.1, 3.6.2
    • None
    • core/search
    • None
    • New

    Description

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            itamar Itamar Syn-Hershko
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: