Question

I have built our search system user interface with Solarium. I see that, prior to querying, I can easily set up my select query object using ->getFacetSet()->createFacetField('xyz')->setField('xyz')...

But my Solr requestHandler already returns all the facets I need. In my resultset I can't see a way to retrieve the facets that Solr would normally hand back by default.

Is it possible? Or must I explicitly request all facets through Solarium no matter what, essentially duplicating work I've done in the requestHandler?

Was it helpful?

Solution

It's actually relatively simple. I just needed to get the resultset, first:

$resultset = $client->select($query);

And then get the full Data from the $resultset:

$resultData = $resultset->getData();

Then I was able to do something like this to parse them out:

if ($facet_ranges = $resultData['facet_counts']['facet_ranges']) {
  foreach ($facet_fields as $facet_name => $facet) {
     // Do stuff here
  }
}

..The best part is that this can work for any otherwise non-supported element of the Solr response, like Clustering and stuff.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top