Views without a pager are now limited to 10 results, make the default rows parameter configurable

Created on 18 July 2019, almost 6 years ago
Updated 30 June 2023, about 2 years ago

Problem/Motivation

Pagination / Number of items broken for MLT block introduced a bug in our feeds (they don't have a pager and are now limited to 10 items)

In SearchApiQuery 'limit' is set to NULL when there's no pager:

// Views passes sometimes NULL and sometimes the integer 0 for “All” in a
// pager. If set to 0 items, a string “0" is passed. Therefore, we unset
// the limit if an empty value OTHER than a string “0” was passed.
if (!$this->limit && $this->limit !== '0') {
  $this->limit = NULL;
}

Then in SearchApiSolrBackend.php rows is set to 10 if limit is NULL:

// In previous versions we set a high value for rows if no limit was set
// in the options. The intention was to retrieve "all" results instead of
// falling back to Solr's default of 10. But for Solr Cloud it turned out
// that independent from the real number of documents, Solr seems to
// allocate rows*shards memory for sorting the distributed result. That
// could lead to out of memory exceptions.
$solarium_query->setRows($query->getOption('limit', 10) ?? 10);

Proposed resolution

We should set a higher limit (e.g. 1000) but probably not too high to run into memory issues?

See https://github.com/mkalkbrenner/search_api_solr/pull/43

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇧🇪Belgium mpp

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇰Denmark ressa Copenhagen

    I searched for site:site:drupal.org "Display all items" solr 10, found this issue, and can confirm that increasing "Advanced" > "Default result rows" to 100 in the Solr server settings fixes that only 10 nodes were returned from Solr.

  • 🇺🇸United States jennypanighetti

    Came across this issue today for some reason, don't know what changed in my setup. THANK YOU @potassiumchloride!

  • 🇩🇰Denmark ressa Copenhagen

    I just ran into this again today, and I think the maximum should be bumped up ... 10 is too low in my opinion.

    Alternatively, if the "Default result rows" value is 10 (the default after an installation) we could show a message, to alert the user that in 99% of cases, they should set the value to "0", or definitely increase it.

    Many users are wasting time needlessly, looking puzzled at the View only returning ten items, when there are many more indexed. Thanks!

Production build 0.71.5 2024