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 Karthik Ramachandran <kr...@commvault.com> on 2016/09/27 16:20:48 UTC

JSON Facet "allBuckets" behavior

While performing json faceting with "allBuckets" and "mincount", I not sure if I am expecting a wrong result or there is bug?

By "allBucket" definition the response, representing the union of all of the buckets.

Schema:
<field name="id" type="string" indexed="true" required="true" docValues="true" />
<field name="filename" type="string" indexed="true" docValues="true" />
<field name="size" type="long" indexed="true" docValues="true" />

Dataset:
  <doc><field name="id">1</field><field name="filename">filename1</field><field name="size">1</field></doc>
  <doc><field name="id">2</field><field name="filename">filename2</field><field name="size">1</field></doc>
  <doc><field name="id">3</field><field name="filename">filename3</field><field name="size">1</field></doc>
  <doc><field name="id">4</field><field name="filename">filename4</field><field name="size">1</field></doc>
  <doc><field name="id">5</field><field name="filename">filename5</field><field name="size">1</field></doc>
  <doc><field name="id">6</field><field name="filename">filename1</field><field name="size">1</field></doc>
  <doc><field name="id">7</field><field name="filename">filename2</field><field name="size">1</field></doc>
  <doc><field name="id">8</field><field name="filename">filename3</field><field name="size">1</field></doc>
  <doc><field name="id">9</field><field name="filename">filename4</field><field name="size">1</field></doc>
  <doc><field name="id">10</field><field name="filename">filename1</field><field name="size">1</field></doc>
  <doc><field name="id">11</field><field name="filename">filename2</field><field name="size">1</field></doc>
  <doc><field name="id">12</field><field name="filename">filename3</field><field name="size">1</field></doc>
  <doc><field name="id">13</field><field name="filename">filename1</field><field name="size">1</field></doc>
  <doc><field name="id">14</field><field name="filename">filename2</field><field name="size">1</field></doc>
  <doc><field name="id">15</field><field name="filename">filename1</field><field name="size">1</field></doc>

For my dataset, with request
http://localhost:8983/solr/jasonfacettest/select/?q=*:*&rows=0&json.facet= {"sumOfDuplicates":{"type":"terms","field":"filename","mincount":2,"numBuckets":true,"allBuckets":true,"sort":"sum desc","facet":{"sum":"sum(size)"}}}

below is the response,
"response":{"numFound":15,"start":0,"docs":[]},"facets":{"count":15,"sumOfDuplicates":{"numBuckets":4,"allBuckets":{"count":15,"sum":15.0},"buckets":[{"val":"filename1","count":5,"sum":5.0},{"val":"filename2","count":4,"sum":4.0},{"val":"filename3","count":3,"sum":3.0},{"val":"filename4","count":2,"sum":2.0}]}}}

I was wonder, why the result is not this, since I have "mincount:2"
"response":{"numFound":15,"start":0,"docs":[]},"facets":{"count":15,"sumOfDuplicates":{"numBuckets":4,"allBuckets":{"count":14,"sum":14.0},"buckets":[{"val":"filename1","count":5,"sum":5.0},{"val":"filename2","count":4,"sum":4.0},{"val":"filename3","count":3,"sum":3.0},{"val":"filename4","count":2,"sum":2.0}]}}}

Thanks for the help!!

With Thanks & Regards
Karthik Ramachandran
P Please don't print this e-mail unless you really need to


Re: JSON Facet "allBuckets" behavior

Posted by prosens <pr...@gmail.com>.
Yonik,
Here is the requirement:
Get sum of size field for all the documents which has a duplicate in the
index. Duplicate is decided based on a string field. So, we are looking for
something like this.
{
	"Statistics": {
		"type": "terms",
		"field": "filename",
		"mincount": 2,
		"numBuckets": true,		
		*"sumBuckets": true*	
	}
}

Is their an alternate way to achieve this?



--
View this message in context: http://lucene.472066.n3.nabble.com/JSON-Facet-allBuckets-behavior-tp4298289p4299980.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: JSON Facet "allBuckets" behavior

Posted by Karthik Ramachandran <mr...@gmail.com>.
So if i cannot use allBuckets since its not filtering, how can I achieve
this?

On Fri, Sep 30, 2016 at 7:19 PM, Yonik Seeley <ys...@gmail.com> wrote:

> On Tue, Sep 27, 2016 at 12:20 PM, Karthik Ramachandran
> <kr...@commvault.com> wrote:
> > While performing json faceting with "allBuckets" and "mincount", I not
> sure if I am expecting a wrong result or there is bug?
> >
> > By "allBucket" definition the response, representing the union of all of
> the buckets.
> [...]
> > I was wonder, why the result is not this, since I have "mincount:2"
>
> allBuckets means all of the buckets before limiting or filtering (i.e.
> mincount filtering).
>
> -Yonik
>

Re: JSON Facet "allBuckets" behavior

Posted by Yonik Seeley <ys...@gmail.com>.
On Tue, Sep 27, 2016 at 12:20 PM, Karthik Ramachandran
<kr...@commvault.com> wrote:
> While performing json faceting with "allBuckets" and "mincount", I not sure if I am expecting a wrong result or there is bug?
>
> By "allBucket" definition the response, representing the union of all of the buckets.
[...]
> I was wonder, why the result is not this, since I have "mincount:2"

allBuckets means all of the buckets before limiting or filtering (i.e.
mincount filtering).

-Yonik