Why do you think a bitset would help? Bitsets have
a bit set on for every document that matches
based on the _internal_ Lucene document ID, it
has nothing to do with the <uniqueKey> you have
defined. Nor does it have anything to do with the
foreign key relationship.

So either I don't understand the problem at all or
pursuing bitsets is a red herring.

You might be substantially faster by sorting the
results and then doing a skip-list sort of thing.

FWIW,
Erick


On Mon, Oct 14, 2013 at 1:47 PM, Michael Tyler
<michaeltyler1...@gmail.com>wrote:

> Hi Shawn,
>
>   This is time consuming operation. I already have this in my application .
> I was pondering whether I can get bit set from both the solr indexes ,
> bitset.and  then retrieve only those matched? I don't know how do I
> retrieve bitset. - wanted to try this and test the performance.
>
>
> Regards
> Michael
>
>
> On Sun, Oct 13, 2013 at 8:54 PM, Shawn Heisey <s...@elyograg.org> wrote:
>
> > On 10/13/2013 8:34 AM, Michael Tyler wrote:
> > > Hello,
> > >
> > >     I have 2 different solr indexes returning 2 different sets of
> > > SolrDocumentList. Doc Id is the foreign key relation.
> > >
> > > After obtaining them, I want to perform "AND" operation between them
> and
> > > then return results to user. Can you tell me how do I get this? I am
> > using
> > > solr 4.3
> > >
> > >  SolrDocumentList results1 = responseA.getResults();
> > >  SolrDocumentList results2 = responseB.getResults();
> > >
> > > results1  : d1, d2, d3
> > > results2  :  d1,d2, d4
> >
> > The SolrDocumentList class extends ArrayList<SolrDocument>, which means
> > that it inherits all ArrayList functionality.  Unfortunately, there's no
> > built-in way of eliminating duplicates with a java List.  It's very easy
> > to combine the two results into another object, but that object will
> > contain both of the d1 and both of the d2 SolrDocument objects.
> >
> > The following code is a reasonably fast way to handle this.  It assumes
> > that results1 is the list that should win when there are duplicates, so
> > it gets added first.  It assumes that the uniqueKey field is named "id"
> > and that it contains a String value.  If these are incorrect
> > assumptions, you can adjust the code accordingly.
> >
> > SolrDocumentList results1 = responseA.getResults();
> > SolrDocumentList results2 = responseB.getResults();
> > List<SolrDocumentList> tmpList = new ArrayList<SolrDocumentList>();
> > tmpList.add(results1);
> > tmpList.add(results2);
> >
> > Set<String> tmpSet = new HashSet<String>();
> > SolrDocumentList newList = new SolrDocumentList();
> > for (SolrDocumentList l : tmpList)
> > {
> >         for (SolrDocument d : l)
> >         {
> >                 String id = (String) d.get("id");
> >                 if (tmpSet.contains(id)) {
> >                         continue;
> >                 }
> >                 tmpSet.add(id);
> >                 newList.add(d);
> >         }
> > }
> >
> > Thanks,
> > Shawn
> >
> >
>

Reply via email to