You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Chris Male <ge...@gmail.com> on 2008/10/01 10:28:58 UTC

Using Filters with SolrIndexSearcher

Hello,

I have a lucene CustomScoreQuery which I am wanting to execute with a lucene
Filter.  However the getDocListAndSet API provided by the SolrIndexSearcher
doesn't seem to allow Filters to be used along with Queries.  Instead it
seems that the Filters must be first converted to a DocSet.  Internally, the
SolrIndexSearcher then seems to call Searcher.search(Query, HitCollector),
which results in my CustomScoreQuery being called for every document
resulting from the query (which in my case is every document in the index),
instead of those resulting from the Query and the Filter.  Ideally
SolrIndexSearcher would call something like Searcher.search(Query, Filter,
Sort) (although I understand this particular method returns Hits, which is
deprecated).  Is there anyway to achieve this functionality without
extending the SolrIndexSearcher API? In other words, is it possible to run
the query on top of a filtered view of the index so the CustomScoreQuery
will not be called for every document in the it?

Thanks
Chris

Re: Using Filters with SolrIndexSearcher

Posted by Chris Hostetter <ho...@fucit.org>.
: I have a lucene CustomScoreQuery which I am wanting to execute with a lucene
: Filter.  However the getDocListAndSet API provided by the SolrIndexSearcher
: doesn't seem to allow Filters to be used along with Queries.  Instead it
: seems that the Filters must be first converted to a DocSet.  Internally, the
: SolrIndexSearcher then seems to call Searcher.search(Query, HitCollector),
: which results in my CustomScoreQuery being called for every document
: resulting from the query (which in my case is every document in the index),
: instead of those resulting from the Query and the Filter.  Ideally
: SolrIndexSearcher would call something like Searcher.search(Query, Filter,

this statement confuses me ... independent of anything in SOlr, if you are 
using Lucene directly then a CustomScoreQuery that matches every doc in 
your index should wind up iterating over every document regardless of 
wether a filter is applied.  this hsouldn't work any differently in Solr 
when dealing with DocSets instead of Filters.

If you only care about docs that match a certian filter, couldn't you use 
that Filter to create subQuery for your ConstantScoreQuery?  (instead of a 
MatchAllDocs query which is what it sounds like you're using right now)

If i'm missunderstanding your question, posting some code so we can see 
what you are trying would be helpful.

-Hoss