What is the problem you’re trying to solve?
Relevanssi has a throttle that caps the results at 500 results per search term. You can adjust the throttle, but that’s not a good idea. A lower throttle level means relevant posts may remain unfound.
The problem is simple. I have a site with over 1 million posts and several million indexed terms. Many bots and visitors hit the search button with an empty field and this overloads the server. I would like to limit the search results every time the search key is pressed.
The 500-post limit should be fine; there isn’t a great difference between 100 and 500 posts regarding performance. The throttle is always enabled when there’s no search term in the search.
You can adjust the throttle, but if you lower the value from 500, it will hurt the results in the searches with a search term.
In any case, sounds like the best solution would be to make empty searches return no results.
add_filter( 'relevanssi_search_ok', function( $search_ok, $query ) {
if ( empty( $query->query_vars['s'] ) ) {
$search_ok = false;
}
return $search_ok;
}, 2 );
This will stop Relevanssi from running when there’s no search term, leaving you with the WordPress default search. That’s less taxing for the server, and if you want to, you can then stop that, too.
Ok thank you. I will try this solution.
Edit
All site got error except home page.
-
This reply was modified 3 years, 4 months ago by
scarfatio.