Browse Source

updates to solr results for drupal10

2.x
ppound 2 years ago
parent
commit
f702f1bed2
  1. 10
      modules/solr_site/src/Controller/RoblibSearchSolrsiteController.php
  2. 1
      modules/solr_site/src/Plugin/Block/RoblibSearchSolrsiteGeneral.php

10
modules/solr_site/src/Controller/RoblibSearchSolrsiteController.php

@ -50,7 +50,7 @@ class RoblibSearchSolrsiteController extends ControllerBase {
}
$queryString = urlencode($queryString);
// TODO make the index configurable.
$index = \Drupal\search_api\Entity\Index::load('default_solr_index');
$index = \Drupal\search_api\Entity\Index::load('library');
$query = $index->query();
// Change the parse mode for the search.
@ -81,8 +81,12 @@ class RoblibSearchSolrsiteController extends ControllerBase {
$output['results'] = [];
foreach ($results as $result) {
$id = $result->getId();
$titles = $result->getField('title')->getValues();
$output['results'][$id]['title'] = $titles[0]->getText();
$title = $result->getField('title');
if(empty($title)){
break;
}
$titles = $title->getValues();
$output['results'][$id]['title'] = reset($titles);
$body = $result->getField('body')->getValues();
if (!empty($body)) {
$bodyOutput = strip_tags($body[0]->getText());

1
modules/solr_site/src/Plugin/Block/RoblibSearchSolrsiteGeneral.php

@ -25,6 +25,7 @@ class RoblibSearchSolrsiteGeneral extends BlockBase {
'solr_site_search_url' => $search_url,
'solr_site_base_url' => '/roblib_search/solr_site/general/',
'solr_type' => 'results',
'solr_site_search_url' => $search_url,
];
return [
'#theme' => 'roblib_search_solr_site_results',

Loading…
Cancel
Save