createSelect();
$query->setRows(0);
// add stats settings
$stats = $query->getStats();
$stats->addFacet('inStock');
$stats->createField('popularity');
$stats->createField('price')->addFacet('price')->addFacet('popularity');
// this executes the query and returns the result
$resultset = $client->select($query);
$statsResult = $resultset->getStats();
// display the stats results
foreach ($statsResult as $field) {
echo '
' . $field->getName() . '
';
echo 'Min: ' . $field->getMin() . '
';
echo 'Max: ' . $field->getMax() . '
';
echo 'Sum: ' . $field->getSum() . '
';
echo 'Count: ' . $field->getCount() . '
';
echo 'Missing: ' . $field->getMissing() . '
';
echo 'SumOfSquares: ' . $field->getSumOfSquares() . '
';
echo 'Mean: ' . $field->getMean() . '
';
echo 'Stddev: ' . $field->getStddev() . '
';
echo 'Field facets
';
foreach ($field->getFacets() as $field => $facet) {
echo 'Facet ' . $field . '
';
foreach ($facet AS $facetStats) {
echo 'Value: ' . $facetStats->getValue() . '
';
echo 'Min: ' . $facetStats->getMin() . '
';
echo 'Max: ' . $facetStats->getMax() . '
';
echo 'Sum: ' . $facetStats->getSum() . '
';
echo 'Count: ' . $facetStats->getCount() . '
';
echo 'Missing: ' . $facetStats->getMissing() . '
';
echo 'SumOfSquares: ' . $facetStats->getSumOfSquares() . '
';
echo 'Mean: ' . $facetStats->getMean() . '
';
echo 'Stddev: ' . $facetStats->getStddev() . '
';
}
}
echo '
';
}
htmlFooter();