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 Greenhorn Techie <gr...@gmail.com> on 2018/10/04 13:10:32 UTC

Filtering group query results

Hi,

We have a requirement where we need to perform a group query in Solr where
results are grouped by user-name (which is a field in our indexes) . We
then need to filter the results based on numFound response parameter
present under each group. In essence, we want to return results only where
numFound=1.

Looking into the documentation, I couldn’t figure out any mechanism to
achieve this. So wondering if there is a possibility to achieve this
requirement with the existing building blocks of Solr query mechanism.

Thanks

Re: Filtering group query results

Posted by Shawn Heisey <ap...@elyograg.org>.
On 10/4/2018 7:10 AM, Greenhorn Techie wrote:
> We have a requirement where we need to perform a group query in Solr where
> results are grouped by user-name (which is a field in our indexes) . We
> then need to filter the results based on numFound response parameter
> present under each group. In essence, we want to return results only where
> numFound=1.

I don't think this is possible in Solr.  I'm reasonably sure that the 
document count isn't calculated until after all the querying and 
filtering is done.

It would be easy enough to do on the client side -- just skip over any 
group where the number of results is not what you're looking for.

I've got no idea how difficult it would be to write this kind of 
capability into the server side.  Off hand I would guess that it's 
probably not super difficult for someone who already knows that part of 
the code.  I don't know that code, so I'd be spending a lot of time 
learning it before I could make a change.

Thanks,
Shawn