You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "hossman (via GitHub)" <gi...@apache.org> on 2025/12/10 23:10:40 UTC

[I] Singleton for MatchAllDocsQuery & MatchNoDocsQuery [lucene]

hossman opened a new issue, #15497:
URL: https://github.com/apache/lucene/issues/15497

   ### Description
   
   All Instances of `MatchAllDocsQuery` (and `MatchNoDocsQuery`) are (respectively) equivalent, so it seems silly to for Lucene applications to use `new MatchAllDocsQuery()` (and `new MatchNoDocsQuery()`) and create a lot of identical objects instead of just re-using singleton `INSTANCE`.  _(Unless i'm missing something?)_
   
    * [MatchAllDocsQuery.MatchNoDocsQuery.singleton.patch](https://github.com/user-attachments/files/24089412/MatchAllDocsQuery.MatchNoDocsQuery.singleton.patch)
      * really trivial patch adding a static `INSTANCE` to both classes and deprecating the default constructors
    * [MatchAllDocsQuery.MatchNoDocsQuery.singleton.deprecation-cleanup.patch](https://github.com/user-attachments/files/24089411/MatchAllDocsQuery.MatchNoDocsQuery.singleton.deprecation-cleanup.patch)
      * verbose patch cleaning up the deprecated usages through out the code base
   
   NOTE: I left the single arg constructor for `MatchNoDocsQuery(String)` alone, but...
   
   - I went ahead and add a note to it's javadocs that the `reason` argument doesn't impact it's equality
     - which i guess makes sense, but kind of surprised me -- not sure if that's actually intentional or a bug?
   - It's used in many places in Lucene, frequently as part of rewriting other queries, but (AFAICT) always with (effectively) static arguments
     - so It might make sense for those classes to define their own private static instances for each "reason" ?
   
   ----
   
   (I sent a question about this idea to the mailing list a couple of months back but didn't get any response; so i figured i'd go ahead and create an issue and see if that prompted any response since the patch was so easy to trivial)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Singleton for MatchAllDocsQuery & MatchNoDocsQuery [lucene]

Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on issue #15497:
URL: https://github.com/apache/lucene/issues/15497#issuecomment-3640661758

   It makes sense to me, by the way. I can't remember the reason "reason" exists on MatchNoDocs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Singleton for MatchAllDocsQuery & MatchNoDocsQuery [lucene]

Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on issue #15497:
URL: https://github.com/apache/lucene/issues/15497#issuecomment-3643532504

   Applied to main and branch_10x.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Singleton for MatchAllDocsQuery & MatchNoDocsQuery [lucene]

Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on issue #15497:
URL: https://github.com/apache/lucene/issues/15497#issuecomment-3640644102

   I've applied both these patches in #15499


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Singleton for MatchAllDocsQuery & MatchNoDocsQuery [lucene]

Posted by "hossman (via GitHub)" <gi...@apache.org>.
hossman commented on issue #15497:
URL: https://github.com/apache/lucene/issues/15497#issuecomment-3642882610

   > I can't remember the reason "reason" exists on MatchNoDocs.
   
   it's used in the `toString` so IIUC it shows up in the explain output?
   If you look at how it's used in other (non-test) classes, i _think_ the idea was to ensure people could  understand why their original queries had been re-written into nothiness


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Singleton for MatchAllDocsQuery & MatchNoDocsQuery [lucene]

Posted by "hossman (via GitHub)" <gi...@apache.org>.
hossman commented on issue #15497:
URL: https://github.com/apache/lucene/issues/15497#issuecomment-3642897438

   > [dweiss](https://github.com/dweiss) added this to the [11.0.0](https://github.com/apache/lucene/milestone/22) milestone
   
   The first patch should be safe for 10.4; correct?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Singleton for MatchAllDocsQuery & MatchNoDocsQuery [lucene]

Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss closed issue #15497: Singleton for MatchAllDocsQuery & MatchNoDocsQuery
URL: https://github.com/apache/lucene/issues/15497


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Singleton for MatchAllDocsQuery & MatchNoDocsQuery [lucene]

Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on issue #15497:
URL: https://github.com/apache/lucene/issues/15497#issuecomment-3643082196

   > The first patch should be safe for 10.4; correct?
   
   I don't mind if it's applied to both main and 10.4, sure.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org