0

I have views for solr search result and I have highlight processor enabled. There seems to be cache issue effecting search result. Search results are rendered array of entities. For example: If I search 'content'. I see my result highlighting word 'content' correctly but when I search for result 'extraction', in the page with both words 'content' and 'extraction', it highlights 'content'. I used

\Drupal::service('page_cache_kill_switch')->trigger();

in views pre_render but didn't work as expected. Views advanced setting already has caching set to none.

Can anyone help me disabling cache for this particular view?

Thank you.

1

When you go to /admin/config/search/search-api and then click to edit your index, there is a checkbox for "Index items immediately" under the "Index Options" section. That is the only way I've found to get Solr Views to output new content immediately after it's created.

0

Issue was it was entity cache interfering with result. So, I ended up invalidating cache for entities when it is search result using hook_entity_view_alter. This might not be good idea but it fixes the problem. I am considering going with javascript approach to highlight so that I don't need to invalidate cache.

$build['#cache']['max-age'] = 0;
\Drupal::service('page_cache_kill_switch')->trigger();

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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