Score:3

How to get all search results of search api index?

kr flag

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?

Score:0
cn flag

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.

kr flag
This hook also only returns the current page results. not all
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.