Facet+Stats+MinCount: How to use mincount filter when use facet+stats

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Facet+Stats+MinCount: How to use mincount filter when use facet+stats

Jeffery Yuan
This post was updated on .
We store some events data such as accountId, startTime, endTime, timeSpent and some other searchable fields.

We want to get all acountIds that spend more than xhours between startTime and endTime and some other criteria which are not important here.

We can use facet and stats query like below: stats=true&stats.field={!tag=timeSpent sum=true}timeSpent&facet=true&facet.pivot={!stats=timeSpent}accountId

This will return how many hours all acountIds spends between startTime and endTime, then I can do filter in our code.

But this will return a lot of acountIds which are not wanted. I am wondering whether Solr can do the filter for us and only return accountIds that spends more than x hours?

Is it possible that I use facet function to get sum, and then use mincount to do filter? http://yonik.com/solr-facet-functions/
Reply | Threaded
Open this post in threaded view
|

Re: Facet+Stats+MinCount: How to use mincount filter when use facet+stats

Jeffery Yuan
This post was updated on .
We will use Solr facet function - it's very powerful.
The only missing part is that it doesn't minValue and maxValue filter.
http://yonik.com/solr-facet-functions/

http://localhost:8983/solr/events/select?q=*:*&json.facet={
   categories:{
     type : terms,
     field : accountId,
     numBuckets: true,
     facet:{
       sum : "sum(timeSpent)"
       // it would be great if we support minValue, maxValue to do filter here
     }
   }
 }
Reply | Threaded
Open this post in threaded view
|

Re: Facet+Stats+MinCount: How to use mincount filter when use facet+stats

Yonik Seeley
On Tue, Oct 4, 2016 at 8:54 PM, Jeffery Yuan <[hidden email]> wrote:
> We will use Solr facet function - it's very powerful.
> The only missing part is that it doesn't minValue and maxValue filter.

There are min and max functions, but they only work for numerics currently.

-Yonik
Reply | Threaded
Open this post in threaded view
|

Re: Facet+Stats+MinCount: How to use mincount filter when use facet+stats

Jeffery Yuan
Yonik, Thanks very much for your reply.

I think you are talking about min/max functions that are used to create stats facet.
http://yonik.com/solr-facet-functions/

Here we would like to do filter in the (sum) function facet. - so it would only return accountIds whose sum(timeSpent) is between minVale and maxValue.

http://localhost:8983/solr/events/select?q=*:*&json.facet={
   categories:{
     type : terms,
     field : accountId,
     numBuckets: true,
     facet:{
       sum : "sum(timeSpent)"
       // it would be great if we support minValue, maxValue to do filter here
     }
   }
 }
Reply | Threaded
Open this post in threaded view
|

Re: Facet+Stats+MinCount: How to use mincount filter when use facet+stats

Yonik Seeley
On Tue, Oct 4, 2016 at 9:07 PM, Jeffery Yuan <[hidden email]> wrote:
> Yonik, Thanks very much for your reply.
>
> I think you are talking about min/max functions that are used to create
> stats facet.
> http://yonik.com/solr-facet-functions/
>
> Here we would like to do filter in the (sum) function facet. - so it would
> only return accountIds whose sum(timeSpent) is between minVale and maxValue.

Ah, right.
Yeah, we need bucket filters in general (beyond mincount).

-Yonik
Reply | Threaded
Open this post in threaded view
|

Re: Facet+Stats+MinCount: How to use mincount filter when use facet+stats

Jeffery Yuan
Thanks Yonik Seeley.

I created Support Bucket Filters in Facet Functions to track this issue.
Reply | Threaded
Open this post in threaded view
|

Re: Facet+Stats+MinCount: How to use mincount filter when use facet+stats

Yonik Seeley
On Tue, Oct 4, 2016 at 9:27 PM, Jeffery Yuan <[hidden email]> wrote:
> https://issues.apache.org/jira/browse/SOLR-9602

It looks like you beat me by seconds ;-)
https://issues.apache.org/jira/browse/SOLR-9603

-Yonik
Reply | Threaded
Open this post in threaded view
|

Re: Facet+Stats+MinCount: How to use mincount filter when use facet+stats

Jeffery Yuan
Sorry for that, Yonik Seeley.
I have closed it and link it to https://issues.apache.org/jira/browse/SOLR-9603