I am using Drupal 8 default search and I don't want to use search api module. Default search is working fine. But I Want to modify it. I want to categorize search result and get count of that category. Also I want to add class of that category so that On click of that category, I can hide other results.

There was hook hook_preprocess_search_results() in 7 but in 8 I think they have removed.

So is there any alternate hook available? Is there any other way around without using search api and facet api?

  • It literally sounds like facets, why don’t you want to use facets?
    – Kevin
    Commented Jan 29, 2018 at 4:36
  • Hook hook_preprocess_search_results works in D8. Please check out this article: fivemilemedia.co.uk/blog/…
    – Vladislav
    Commented Apr 5, 2018 at 10:47
  • You have to alter the route defined by the search module like this
    – Rem
    Commented Jul 12, 2019 at 12:23

2 Answers 2


Perhaps a view with exposed filters may be a quicker solution for this kind of thing.


If you want to add search behavioral and modify the results which it gives you, you can use hook_node_search_result , Else if you want to modify the look and design of your result items you can use search-result.html.twig file to theme the output markup of your result items.

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.