[ https://issues.apache.org/jira/browse/LUCENE-8060?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16556268#comment-16556268 ]
Hoss Man commented on LUCENE-8060: ---------------------------------- {quote}I think as long as totalHits is renamed/replaced to force a compilation error and draw attention to the need to use a Collector if you want to control if/how-much the total number of hits is accurately recorded, it's fine to hadcode a default in the IndexSearcher methods that return TopDocs directly ... i would go so far as to suggest that in that in that situation, hardcoding maxTotalHits/minExactTotalHits to "0" (ie: don't bother trying to track exactly at all) would be fine. {quote} To elaborate, my thinking is that having the "simple" IndexSearcher APIs use a default of "nothing" (or "everything", ie: {{maxTotalHitsToTrack=Integer.MAX_VALUE}} ) seems much easier to explain/understand to new users regardless of their index size/usecases then some arbitrary positive number like "10,000") But better still – let's assume: * we deprecate/remove {{TopDocs.totalHits}} ** replace it with a {{TopDocs.getTotalHits()}} * we add an {{int maxTotalHitsToTrack}} option on the collectors (builders) ** document it such that any positive number means "track accurate hit count up to this amount, after that just stop" ** document everything such that if {{maxTotalHitsToTrack}} is set to a negative number then then {{TopDocs.getTotalHits()}} will throw an illegal state exception. ...then i would suggest that the IndexSearcher methods that return TopDocs directly should default to using {{maxTotalHitsToTrack=-1}} .. so any attempt to use the "simple" apis makes it really clear it doesn't support hit tracking. > Require users to tell us whether they need total hit counts > ----------------------------------------------------------- > > Key: LUCENE-8060 > URL: https://issues.apache.org/jira/browse/LUCENE-8060 > Project: Lucene - Core > Issue Type: Improvement > Reporter: Adrien Grand > Priority: Minor > Fix For: master (8.0) > > > We are getting optimizations when hit counts are not required (sorted > indexes, MAXSCORE, short-circuiting of phrase queries) but our users won't > benefit from them unless we disable exact hit counts by default or we require > them to tell us whether hit counts are required. > I think making hit counts approximate by default is going to be a bit trappy, > so I'm rather leaning towards requiring users to tell us explicitly whether > they need total hit counts. I can think of two ways to do that: either by > passing a boolean to the IndexSearcher constructor or by adding a boolean to > all methods that produce TopDocs instances. I like the latter better but I'm > open to discussion or other ideas? -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org