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

Classic, flexible, and Solr's standard/"lucene" query parsers: range queries should require " TO ", and accept TO as range endpoints

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.0, 6.6, 6.7
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      A post on the solr-user mailing list drew my attention to the fact that this is apparently a valid range query under the QueryParser.jj grammer (both for the classic parser and the solr variant – i didn't check flexible)...

      [x z]       // parsed the same as [x TO z]
      

      it's parsed as a valid range query even though there is no {{ TO }} – even though there is nothing in the docs to suggest that the {{ TO }} is intended to be optional.

      Furthermore, in my experimenting i realized that how the grammer looks for the {{ TO }} keyword seems to be a bit sloppy, making some range queries that should be easy to validate (because they are unambiguous) fail to parse...

      [TO TO z]     // fails
      [a TO TO]     // fails
      [a TO "TO"]   // works, but why should quoting be neccessary here?
      

      If the "sloppy" parsing behavior is intentional, then the docs should reflect that the {{ TO }} is optional – but it seems like in general we should make these other unambiguous cases parse cleanly.

      1. LUCENE-7821.patch
        30 kB
        Steve Rowe
      2. LUCENE-7821.patch
        2 kB
        Hoss Man

        Activity

        Hide
        hossman Hoss Man added a comment -

        patch with simple test demonstrating problems

        Show
        hossman Hoss Man added a comment - patch with simple test demonstrating problems
        Hide
        steve_rowe Steve Rowe added a comment -

        Patch with beefed up tests and fixes for classic query parser, flexible query parser, and Solr's standard/"lucene" query parser.

        I think it's ready to go.

        Show
        steve_rowe Steve Rowe added a comment - Patch with beefed up tests and fixes for classic query parser, flexible query parser, and Solr's standard/"lucene" query parser. I think it's ready to go.
        Hide
        yseeley@gmail.com Yonik Seeley added a comment -

        nice catch! +1 to the syntax of

        [<something> TO <something>]
        

        I don't see any changes to the grammar files in the patch?

        Show
        yseeley@gmail.com Yonik Seeley added a comment - nice catch! +1 to the syntax of [<something> TO <something>] I don't see any changes to the grammar files in the patch?
        Hide
        steve_rowe Steve Rowe added a comment -

        I don't see any changes to the grammar files in the patch?

        Hoss'ss patch is test-only. Mine includes grammar file changes.

        Show
        steve_rowe Steve Rowe added a comment - I don't see any changes to the grammar files in the patch? Hoss'ss patch is test-only. Mine includes grammar file changes.
        Hide
        yseeley@gmail.com Yonik Seeley added a comment -

        Right you are... I previously searched visually and then for ".jj", but I must have had a typo.

        Show
        yseeley@gmail.com Yonik Seeley added a comment - Right you are... I previously searched visually and then for ".jj", but I must have had a typo.
        Hide
        steve_rowe Steve Rowe added a comment -

        If there are no objections, I'll commit this tomorrow, including to 6.6.

        Show
        steve_rowe Steve Rowe added a comment - If there are no objections, I'll commit this tomorrow, including to 6.6.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit b172ceb143955bf34a6b16ab3557bf98844ac427 in lucene-solr's branch refs/heads/branch_6_6 from Steve Rowe
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=b172ceb ]

        LUCENE-7821: The classic and flexible query parsers, as well as Solr's 'lucene'/standard query parser, should require ' TO ' in range queries, and accept 'TO' as endpoints in range queries.

        Conflicts:
        solr/CHANGES.txt

        Show
        jira-bot ASF subversion and git services added a comment - Commit b172ceb143955bf34a6b16ab3557bf98844ac427 in lucene-solr's branch refs/heads/branch_6_6 from Steve Rowe [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=b172ceb ] LUCENE-7821 : The classic and flexible query parsers, as well as Solr's 'lucene'/standard query parser, should require ' TO ' in range queries, and accept 'TO' as endpoints in range queries. Conflicts: solr/CHANGES.txt
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 8633f49dcd1c0237fe0d6e65ea8cacd193950038 in lucene-solr's branch refs/heads/branch_6x from Steve Rowe
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=8633f49 ]

        LUCENE-7821: The classic and flexible query parsers, as well as Solr's 'lucene'/standard query parser, should require ' TO ' in range queries, and accept 'TO' as endpoints in range queries.

        Conflicts:
        solr/CHANGES.txt

        Show
        jira-bot ASF subversion and git services added a comment - Commit 8633f49dcd1c0237fe0d6e65ea8cacd193950038 in lucene-solr's branch refs/heads/branch_6x from Steve Rowe [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=8633f49 ] LUCENE-7821 : The classic and flexible query parsers, as well as Solr's 'lucene'/standard query parser, should require ' TO ' in range queries, and accept 'TO' as endpoints in range queries. Conflicts: solr/CHANGES.txt
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit e11bc030987b33faadf42f0b2fb21d521077f361 in lucene-solr's branch refs/heads/master from Steve Rowe
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=e11bc03 ]

        LUCENE-7821: The classic and flexible query parsers, as well as Solr's 'lucene'/standard query parser, should require ' TO ' in range queries, and accept 'TO' as endpoints in range queries.

        Show
        jira-bot ASF subversion and git services added a comment - Commit e11bc030987b33faadf42f0b2fb21d521077f361 in lucene-solr's branch refs/heads/master from Steve Rowe [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=e11bc03 ] LUCENE-7821 : The classic and flexible query parsers, as well as Solr's 'lucene'/standard query parser, should require ' TO ' in range queries, and accept 'TO' as endpoints in range queries.

          People

          • Assignee:
            steve_rowe Steve Rowe
            Reporter:
            hossman Hoss Man
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development