Skip to content

Commit

Permalink
Add max amount of snippets and restore query->getHighlighting
Browse files Browse the repository at this point in the history
Plugin has return only one snippet per page as default. Restore getHighlighting without assigning it to the variable.
  • Loading branch information
beatrycze-volk committed Mar 15, 2021
1 parent 0dc0d50 commit 9c55eea
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Classes/Plugin/Eid/SearchInDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down

0 comments on commit 9c55eea

Please sign in to comment.