Skip to content

Commit

Permalink
[BUGFIX] Fix params array for searching collections (#1262)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Meyer <[email protected]>
  • Loading branch information
beatrycze-volk and sebastian-meyer committed Jul 5, 2024
1 parent 93f1ff0 commit 1657409
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Classes/Controller/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ public function listAction(): void
$this->logger->error('Apache Solr not available');
return;
}
// We only care about the UID and partOf in the results and want them sorted
$params['fields'] = 'uid,partof';
$params['sort'] = ['uid' => 'asc'];

$collections = [];

// Sort collections according to order in plugin flexform configuration
Expand Down Expand Up @@ -220,22 +218,29 @@ private function processCollections($collections, Solr $solr): array

// Process results.
foreach ($collections as $collection) {
$solr_query = '';
$solrQuery = '';
if ($collection->getIndexSearch() != '') {
$solr_query .= '(' . $collection->getIndexSearch() . ')';
$solrQuery .= '(' . $collection->getIndexSearch() . ')';
} else {
$solr_query .= 'collection:("' . Solr::escapeQuery($collection->getIndexName()) . '")';
$solrQuery .= 'collection:("' . Solr::escapeQuery($collection->getIndexName()) . '")';
}

// We only care about the UID and partOf in the results and want them sorted
$params = [
'fields' => 'uid,partof',
'sort' => [
'uid' => 'asc'
]
];
// virtual collection might yield documents, that are not toplevel true or partof anything
if ($collection->getIndexSearch()) {
$params['query'] = $solr_query;
$params['query'] = $solrQuery;
} else {
$params['query'] = $solr_query . ' AND partof:0 AND toplevel:true';
$params['query'] = $solrQuery . ' AND partof:0 AND toplevel:true';
}
$partOfNothing = $solr->searchRaw($params);

$params['query'] = $solr_query . ' AND NOT partof:0 AND toplevel:true';
$params['query'] = $solrQuery . ' AND NOT partof:0 AND toplevel:true';
$partOfSomething = $solr->searchRaw($params);

$collectionInfo = [];
Expand Down

0 comments on commit 1657409

Please sign in to comment.