3

I want to get all the search results from the search API index and then perform a custom sort on it and then display them accordingly.

I used the hook_search_api_results_alter and also the search results event. My view has a pager to display 10 results at a time.

But the problem is, I am only getting 10 results instead of all because of that pager.

Is there any to get all the results and then perform the custom sort on it and then return it to search view to display accordingly? So that all other filters, pagers, and sorting applied after my custom sort?

My custom sorting is working fine on per page basis but that is not what I want.

Is it possible to remove the limit from the query to get all results, perform sort and apply the limit again?

1 Answer 1

0

function hook_views_post_execute would be better here. This is for where the query has been executed, but the pre_render() phase has not yet happened for handlers so you should be able to sort your results by whatever order you need.

1
  • This hook also only returns the current page results. not all
    – Ahmad
    Jun 18, 2021 at 8:42

Your Answer

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

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