You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Uwe Schindler (JIRA)" <ji...@apache.org> on 2015/09/02 14:56:46 UTC

[jira] [Comment Edited] (LUCENE-6754) Optimize IndexSearcher.count for simple queries

    [ https://issues.apache.org/jira/browse/LUCENE-6754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14727290#comment-14727290 ] 

Uwe Schindler edited comment on LUCENE-6754 at 9/2/15 12:56 PM:
----------------------------------------------------------------

Hi, thanks for committing this. I am just not really happy about the instanceof checks. It also makes it impossible for custom queries to maybe improve this. How about adding a method to the query class that can be "optionally" implemented to return a count? By default it may throw exception or alternative use the collector approach. Queries like term query may implement this count methods, if they have some optimized way to do this.

An alternative would be to let the Weight have the new method. TermWeight would have its statistics already and could implement TermWeight#count() easily. if there are deletions, weight would call super.count().

Queries like ConstantScoreQuery could delegate to the inner queries.


was (Author: thetaphi):
Hi, thanks for committing this. I am just not really happy about the instanceof checks. It also makes it impossible for custom queries to maybe improve this. How about adding a method to the query class that can be "optionally" implemented to return a count? By default it may throw exception or alternative use the collector approach. Queries like term query may implement this count methods, if they have some optimized way to do this.

An alternative would be to let the Weight have the new method. TermQuery would have its statistics already and could implement TermWeight#count() easily. if there are deletions, weight would call super.count().

Queries like ConstantScoreQuery could delegate to the inner queries.

> Optimize IndexSearcher.count for simple queries
> -----------------------------------------------
>
>                 Key: LUCENE-6754
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6754
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Adrien Grand
>            Assignee: Adrien Grand
>            Priority: Minor
>             Fix For: 5.4
>
>         Attachments: LUCENE-6754.patch
>
>
> IndexSearcher.count currently always create a collector to compute the number of hits, but it could optimize some queries like MatchAllDocsQuery or TermQuery.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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