Skip to content

Commit

Permalink
Fixed searching full text with scalar results.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Berthereau authored and Daniel Berthereau committed Sep 2, 2024
1 parent 24e726e commit 1e3c04c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions application/src/Api/Adapter/AbstractEntityAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,19 @@ public function search(Request $request)
} else {
$qb->select(['omeka_root.id', 'omeka_root.' . $scalarField]);
}

// Manage exception "only_full_group_by" when searching full text
// via scalar.
// See \Omeka\Module::searchFulltext().
$matchOrder = 'MATCH(omeka_fulltext_search.title, omeka_fulltext_search.text) AGAINST (:omeka_fulltext_search)';
$dqlOrder = $qb->getDQLPart('orderBy');
$hasFullTextSearchOrder = isset($dqlOrder[0]) && $matchOrder === (string) $dqlOrder[0];
if ($hasFullTextSearchOrder) {
$qb
->addSelect($matchOrder . ' AS HIDDEN orderMatch')
->addGroupBy('orderMatch');
}

$content = array_column($qb->getQuery()->getScalarResult(), $scalarField, 'id');
$response = new Response($content);
$response->setTotalResults($countPaginator->count());
Expand Down

0 comments on commit 1e3c04c

Please sign in to comment.