11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

facet(collection1,<br />

q="*:*",<br />

buckets="a_s",<br />

bucketSorts="sum(a_i) desc",<br />

bucketSizeLimit=100,<br />

sum(a_i),<br />

sum(a_f),<br />

min(a_i),<br />

min(a_f),<br />

max(a_i),<br />

max(a_f),<br />

avg(a_i),<br />

avg(a_f),<br />

count(*))<br />

The example above shows a facet function with rollups over a single bucket, where the buckets are returned in<br />

descending order by the calculated value of the sum(a_i) metric.<br />

Example 2:<br />

facet(collection1,<br />

q="*:*",<br />

buckets="year_i, month_i, day_i",<br />

bucketSorts="year_i desc, month_i desc, day_i desc",<br />

bucketSizeLimit=100,<br />

sum(a_i),<br />

sum(a_f),<br />

min(a_i),<br />

min(a_f),<br />

max(a_i),<br />

max(a_f),<br />

avg(a_i),<br />

avg(a_f),<br />

count(*))<br />

The example above shows a facet function with rollups over three buckets, where the buckets are returned in<br />

descending order by bucket value.<br />

stats<br />

The stats function gathers simple aggregations for a search result set. The stats function does not support<br />

rollups over buckets, so the stats stream always returns a single Tuple with the rolled up stats. Under the covers<br />

the stats function pushes down the generation of the stats into the search engine using the StatsComponent.<br />

The stats function currently supports the following metrics: count(*) , sum() , avg() , min() , and max() .<br />

Parameters<br />

Syntax<br />

collection: (Mandatory) Collection the stats will be aggregated from.<br />

q: (Mandatory) The query to build the aggregations from.<br />

metrics: (Mandatory) The metrics to include in the result Tuple. Current supported metrics are sum(col<br />

), avg(col) , min(col) , max(col) and count(*)<br />

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

411

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

Saved successfully!

Ooh no, something went wrong!