From 506da48b59aa21443c396720e2ead6ffa8dfe9de Mon Sep 17 00:00:00 2001 From: Amy Li Date: Mon, 13 Mar 2023 11:48:10 -0400 Subject: [PATCH] If highlighting enabled, make search api query 'keys' field non-empty The search api highlight processor checks if the 'keys' field is non-empty and then creates the excerpt. Since we are getting the highlighting result from Solr instead of creating one using the search api processor, we just need to make this field non-empty --- src/AdvancedSearchQuery.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/AdvancedSearchQuery.php b/src/AdvancedSearchQuery.php index 37e0f28..90acfe5 100644 --- a/src/AdvancedSearchQuery.php +++ b/src/AdvancedSearchQuery.php @@ -266,14 +266,14 @@ class AdvancedSearchQuery { $this->setHighlighting($solarium_query, $search_api_query, $highlighted_fields); - // We need to set the 'keys' field of the Search API Query to the - // advanced search input since the Search API Highlight processor checks - // this field to know which keywords to highlight in the excerpt. - - // logging($q); - // $search_api_query->keys($q); + // The Search API Highlight processor checks if the 'keys' field of + // the Search API Query is non-empty before creating an excerpt. + // Since we are getting the highlighting result from Solr instead + // of using the Search API processor to create one, we just need + // make this field non-empty. + $search_api_query->keys("advanced search"); } - + $solarium_query->setQuery($q); } }