0

I'm using the search_api extension (V 8.x-1.14) with the Database search (no solr, etc.)

I use the search block which is created by the search view (/search path)

I want to show the highlighted excerpts which are setup in the Manage processors for search index (/admin/config/search/search-api/<x>/content/processors)

In the view I select Rendered Entity as show format and chose search result hightlighing input in the settings.

Everything works fine now, but ...

Consifer I have a page About us with this sentence written somewhere on the page.

'We will deliver your quality product on time and safely at the location of your choice.'

When the user searches for time, this page will be hit and the correct highlight will be shown

We will deliver your quality product on time and safely at the location of your choice.

Now this excerpt is cached and when I search for quality the excerpt stays the same with the wrong word highlighted.

We will deliver your quality product on time and safely at the location of your choice.

I deactivated the cache of the view, but it didn't change anything

3

1 Answer 1

0

Thanks to berramou!

I ended up using this in my theme:

/**
 * Implements hook_preprocess_HOOK().
 */
function MYTHEME_preprocess_node(array &$variables) {
  if ($variables['view_mode'] == 'search_result') {
    $variables['#cache']['max-age'] = 0;
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.