Hi James,
Half right, I think. That is the file to change, but the two arrays you are looking at are not facets, so widening them will not get you what you want.
In informationobjectsBrowseAction.class.php, place_access_points and creators are built inside the foreach over the result set, one entry per hit, from that record's own $doc['places'] and $doc['creators']. They are per-record field values, not counts. They are scoped to the page because they describe the ten records on the page, and there is nothing there to widen.
The reason you see no facet counts is simpler: the action never asks for any. It runs the search and returns ['total' => $resultSet->getTotalHits(), 'results' => $results], and that is the whole payload. Worth saying too that the two booleans in getQuery(false, true) are $allowEmpty and $filterDrafts, so that is not a facet switch you can flip.
You are right that the engine supports what you want. Aggregations are computed over the entire matching set and are unaffected by from/size, so you can have counts for all 1000 hits while still returning 10 records.
The site browse does it in DefaultBrowseAction, apps/qubit/modules/default/actions/browseAction.class.php. It checks for an AGGS property, calls $this->search->addAggs($this::$AGGS) and $this->search->addAggFilters($this::$AGGS, $this->getParameters) before searching, then reads $resultSet->getAggregations() afterwards. The AGGS definition itself sits at the top of apps/qubit/modules/informationobject/actions/browseAction.class.php, and it is just an array of field/type/size entries you can lift straight across.
So the change in the REST action is to add the aggs to the query before the search call and read getAggregations() into the JSON. Three things that will bite otherwise:
Aggregations come back keyed on term ids, not names. places.id, creators.id, repository.id and so on. The site resolves those separately when it populates the facet labels, so without the same lookup your interface will show numbers.
Each AGGS entry has size => 10, so you get ten buckets per facet and no more. Raise it for your use, and keep in mind terms aggregations are approximate once cardinality gets high.
addAggFilters is what makes the counts respect the filters already applied, which is normally what people expect from facets. Skip it and the counts describe the unfiltered query.
One last thing, since this is going to a public interface: keep filterDrafts on. Aggregations respect the query they are attached to, so if drafts are not filtered out your counts will quietly include unpublished records even though the results do not.
Regards
--
You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ica-atom-users/53674CD1-2212-46A5-9236-374EB1604B8C%40orangeleaf.com.
To view this discussion visit https://groups.google.com/d/msgid/ica-atom-users/CAA4s_cB9LVkU2Bg8cZjqf%2BxMwz5XCmfrCMPp96sLs1zwEX_HkQ%40mail.gmail.com.