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 Gajendra Dadheech <ga...@gmail.com> on 2015/05/05 05:51:51 UTC

Union and intersection methods in solr DocSet

I have a requirement where i need to find matching docsets for different
queries and then do either union or intersection on those docsets. e.g :

DocSet docset1 = Searcher.getDocSet(query1)
DocSet docset2 = Searcher.getDocSet(query2);

Docset finalDocset = docset1.intersection(docset2);

Is this a valid approach ? Give docset could either be a sortedintdocset or
a bitdocset. I am facing ArrayIndexOutOfBoundException when
union/intersected between different kind of docsets.

Thanks and regards,
Gajendra Dadheech

Re: Union and intersection methods in solr DocSet

Posted by Gajendra Dadheech <ga...@gmail.com>.
Hey Chris,

Thanks for reply.

The exception is ArrayIndexOutOfBound. It is coming because searcher may
return bitDocSet for query1 and sortedIntDocSet for query2 [could be
possible]. In that case, sortedIntDocSet doesn't implement intersection and
will cause this exception.


Thanks and regards,
Gajendra Dadheech


On Thu, May 7, 2015 at 6:06 AM, Chris Hostetter <ho...@fucit.org>
wrote:

>
> : DocSet docset1 = Searcher.getDocSet(query1)
> : DocSet docset2 = Searcher.getDocSet(query2);
> :
> : Docset finalDocset = docset1.intersection(docset2);
> :
> : Is this a valid approach ? Give docset could either be a sortedintdocset
> or
> : a bitdocset. I am facing ArrayIndexOutOfBoundException when
> : union/intersected between different kind of docsets.
>
> as far as i know, that should be a totally valid usage -- since you didn't
> provide the details of the stack trace or the code you wrote that
> produced it it's hard to guess why/where it's causing the exception.
>
> FWIW: SolrIndexSearcher has getDocSet methods that take multiple arguments
> which might be more efficient then doing the intersection directly (and
> are cache aware)
>
> if all you care about is the *size* of the intersection, see the
> SolrIndexSearcher.numDocs methods.
>
> -Hoss
> http://www.lucidworks.com/
>

Re: Union and intersection methods in solr DocSet

Posted by Chris Hostetter <ho...@fucit.org>.
: DocSet docset1 = Searcher.getDocSet(query1)
: DocSet docset2 = Searcher.getDocSet(query2);
: 
: Docset finalDocset = docset1.intersection(docset2);
: 
: Is this a valid approach ? Give docset could either be a sortedintdocset or
: a bitdocset. I am facing ArrayIndexOutOfBoundException when
: union/intersected between different kind of docsets.

as far as i know, that should be a totally valid usage -- since you didn't 
provide the details of the stack trace or the code you wrote that 
produced it it's hard to guess why/where it's causing the exception.

FWIW: SolrIndexSearcher has getDocSet methods that take multiple arguments 
which might be more efficient then doing the intersection directly (and 
are cache aware)

if all you care about is the *size* of the intersection, see the 
SolrIndexSearcher.numDocs methods.

-Hoss
http://www.lucidworks.com/