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

MatchAllDocsQuery to return all documents

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core/search
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Bugzilla Id:
      34946

      Description

      It would be nice to have a type of query just return all documents from an index.

        Activity

        Hide
        lucenebugs@danielnaber.de Daniel Naber added a comment -

        Thanks, I just committed this class plus a test case. I also added Tony's
        suggested fix, removed the underscores from the variable names and removed the
        call the super().

        Show
        lucenebugs@danielnaber.de Daniel Naber added a comment - Thanks, I just committed this class plus a test case. I also added Tony's suggested fix, removed the underscores from the variable names and removed the call the super().
        Hide
        tsgrieco@yahoo.com Tony Smith-Grieco added a comment -

        I think there is a bug in the skipTo() method of the Scorer. Shouldn't the
        first line be:

        _count = target - 1;

        Because next() will automatically increment _count.

        As it stands, skipTo() will actually skip over target, which is wrong.

        Show
        tsgrieco@yahoo.com Tony Smith-Grieco added a comment - I think there is a bug in the skipTo() method of the Scorer. Shouldn't the first line be: _count = target - 1; Because next() will automatically increment _count. As it stands, skipTo() will actually skip over target, which is wrong.
        Hide
        john.wang@gmail.com John Wang added a comment -

        Created an attachment (id=15092)
        made changes as specified by previous suggestions.

        Excellent points!
        Both 1) and 2) are fixed as specified.

        I am not sure I understand #3.

        Show
        john.wang@gmail.com John Wang added a comment - Created an attachment (id=15092) made changes as specified by previous suggestions. Excellent points! Both 1) and 2) are fixed as specified. I am not sure I understand #3.
        Hide
        paul.elschot@xs4all.nl Paul Elschot added a comment -

        A query returning all docs can indeed be useful on occasion, it was the subject
        of some recent messages on the java-user list.

        Some remarks:

        • MatchAllDocsQuery might be a better name, NullQuery could also to suggest
          not matching any docs at all (which can also be useful on occasion btw.)
        • The scorer uses an int[] for all the non deleted docs which can be
          a rather high burden on memory and initialisation. This could be avoided
          by using the information on deleted docs from the reader directly
          in the scorer.
        • The score value is a constant, and queries with this property are
          currently under discussion on java-dev. This might become a special
          case of the filters discussed there.

        Regards,
        Paul Elschot

        Show
        paul.elschot@xs4all.nl Paul Elschot added a comment - A query returning all docs can indeed be useful on occasion, it was the subject of some recent messages on the java-user list. Some remarks: MatchAllDocsQuery might be a better name, NullQuery could also to suggest not matching any docs at all (which can also be useful on occasion btw.) The scorer uses an int[] for all the non deleted docs which can be a rather high burden on memory and initialisation. This could be avoided by using the information on deleted docs from the reader directly in the scorer. The score value is a constant, and queries with this property are currently under discussion on java-dev. This might become a special case of the filters discussed there. Regards, Paul Elschot
        Hide
        john.wang@gmail.com John Wang added a comment -

        Created an attachment (id=15074)
        NulQuery, which just returns all documents in the index, each with initial
        score of 1,0f

        Forgot the same before attaching

        Show
        john.wang@gmail.com John Wang added a comment - Created an attachment (id=15074) NulQuery, which just returns all documents in the index, each with initial score of 1,0f Forgot the same before attaching
        Hide
        john.wang@gmail.com John Wang added a comment -

        Created an attachment (id=15064)
        NullQuery, which just returns all documents in the index each with initial
        score of 1.0f

        An implementation of a "NUllQuery" that returns all documents in the index each
        with initial score of 1.0f.

        Show
        john.wang@gmail.com John Wang added a comment - Created an attachment (id=15064) NullQuery, which just returns all documents in the index each with initial score of 1.0f An implementation of a "NUllQuery" that returns all documents in the index each with initial score of 1.0f.

          People

          • Assignee:
            java-dev@lucene.apache.org Lucene Developers
            Reporter:
            john.wang@gmail.com John Wang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development