11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using the " bin/solr -e techproducts" example, A query URL like this one will returns the data below,<br />

with the pivot faceting results found in the section "facet_pivot":<br />

http://localhost:8983/solr/techproducts/select?q=*:*&facet.pivot=cat,popularity,i<br />

nStock<br />

&facet.pivot=popularity,cat&facet=true&facet.field=cat&facet.limit=5<br />

&rows=0&wt=json&indent=true&facet.pivot.mincount=2<br />

"facet_counts":{<br />

"facet_queries":{},<br />

"facet_fields":{<br />

"cat":[<br />

"electronics",14,<br />

"currency",4,<br />

"memory",3,<br />

"connector",2,<br />

"graphics card",2]},<br />

"facet_dates":{},<br />

"facet_ranges":{},<br />

"facet_pivot":{<br />

"cat,popularity,inStock":[{<br />

"field":"cat",<br />

"value":"electronics",<br />

"count":14,<br />

"pivot":[{<br />

"field":"popularity",<br />

"value":6,<br />

"count":5,<br />

"pivot":[{<br />

"field":"inStock",<br />

"value":true,<br />

"count":5}]},<br />

...<br />

Combining Stats Component With Pivots<br />

In addition to some of the general local parameters supported by other types of faceting, a stats local<br />

parameters can be used with facet.pivot to refer to stats.field instances (by tag) that you would<br />

like to have computed for each Pivot Constraint.<br />

In the example below, two different (overlapping) sets of statistics are computed for each of the facet.pivot<br />

result hierarchies:<br />

stats=true<br />

stats.field={!tag=piv1,piv2 min=true max=true}price<br />

stats.field={!tag=piv2 mean=true}popularity<br />

facet=true<br />

facet.pivot={!stats=piv1}cat,inStock<br />

facet.pivot={!stats=piv2}manu,inStock<br />

Results:<br />

"facet_pivot":{<br />

"cat,inStock":[{<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

303

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!