Pivot faceting is similar to pivot tables in the latest spreadsheets. Pivot faceting provides a facility to generate an aggregate summary from fetched faceting results on multiple fields:
Parameter |
Behavior |
Default value |
facet.pivot |
Specify the field on which you want to apply pivoting |
|
facet.pivot.mincount |
Specify the minimum number of documents that need to match in order for the facet to be included in the results |
1 |
Example: In our techproducts, we need the stock availability based on the popularity of a category
URL: http://localhost:8983/solr/techproducts/select?q=*:*&facet.pivot=cat,popularity,inStock&facet.pivot=popularity,cat&facet=true&facet.field=cat&facet.limit=5&rows=0&facet.pivot.mincount=2
Response:
{
"facet_counts":{
"facet_queries":{},
"facet_fields":{
"cat":[
"electronics",14,
"currency",4,
"memory",3,
"connector",2,
"graphics card",2]},
"facet_dates":{},
"facet_ranges":{},
"facet_pivot":{
"cat,popularity,inStock":[{
"field":"cat",
"value":"electronics",
"count":14,
"pivot":[{
"field":"popularity",
"value":6,
"count":5,
"pivot":[{
"field":"inStock",
"value":true,
"count":5}]}]
}]}}}