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 Jamie Johnson <je...@gmail.com> on 2011/07/23 07:39:03 UTC
Error with custom search component which adds filter
I have a custom search component which does the following in process
SolrQueryRequest req = rb.req;
SolrParams params = req.getParams();
QueryWrapperFilter qwf = new QueryWrapperFilter(rb.getQuery());
Filter filter = new TestFilter(qwf);
ConstantScoreQuery fq = new ConstantScoreQuery(filter);
rb.setQuery(fq);
this essentially filters the result set using TestFilter which does
this in getDocIdSet
return new FilteredDocSet(startingFilter.getDocIdSet(readerCtx));
where FilteredDocSet always returns true from match. When a query is
executed that returns 0 results an IllegalArgumentException is thrown
from org.apache.lucene.search.FilteredDocIdSetIterator constructor
to fix this in FilteredDocSet I added the following:
@Override
public DocIdSetIterator iterator() throws IOException {
try {
return super.iterator();
} catch(IllegalArgumentException e){
return null;
}
}
What is the correct way to deal with this? Am I getting this error
because I'm misusing something?