• Hi! Is it possible to limit number of results? Now I read a voice in control panel that limit results to 500. It’s possible to limit to only 100? Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Mikko Saari

    (@msaari)

    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.

    Thread Starter scarfatio

    (@scarfatio)

    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.

    Plugin Author Mikko Saari

    (@msaari)

    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.

    Thread Starter scarfatio

    (@scarfatio)

    Ok thank you. I will try this solution.
    Edit
    All site got error except home page.

    • This reply was modified 2 years, 6 months ago by scarfatio.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Is it possible to limit the number of results?’ is closed to new replies.