From 7c83c648804217be401094179a52e038b0ed0aab Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Mon, 15 Feb 2021 11:31:45 +0100 Subject: [PATCH] Add max amount of snippets and restore query->getHighlighting Plugin has return only one snippet per page as default. Restore getHighlighting without assigning it to the variable. --- Classes/Plugin/Eid/SearchInDocument.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Classes/Plugin/Eid/SearchInDocument.php b/Classes/Plugin/Eid/SearchInDocument.php index 9716ef1337..aaccb1b024 100644 --- a/Classes/Plugin/Eid/SearchInDocument.php +++ b/Classes/Plugin/Eid/SearchInDocument.php @@ -61,6 +61,7 @@ public function main(ServerRequestInterface $request) $query->setFields([$fields['id'], $fields['uid'], $fields['page']]); $query->setQuery($this->getQuery($fields, $parameters)); $query->setStart($count)->setRows(20); + $query->getHighlighting(); $solrRequest = $solr->service->createRequest($query); // it is necessary to add the custom parameters to the request @@ -71,6 +72,9 @@ public function main(ServerRequestInterface $request) $solrRequest->addParam('hl.ocr.fl', $fields['fulltext']); // return the coordinates of highlighted search as absolute coordinates $solrRequest->addParam('hl.ocr.absoluteHighlights', 'on'); + // max amount of snippets for a single page + $solrRequest->addParam('hl.snippets', 20); + $response = $solr->service->executeRequest($solrRequest); $result = $solr->service->createResult($query, $response); $output['numFound'] = $result->getNumFound();