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

CommentFileSizeAuthor
#8 3068714_8.patch4.41 KBmkalkbrenner
#6 3068714_6.patch3.28 KBmpp
#2 3068714_2.patch2.12 KBmpp
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mpp created an issue. See original summary.

mpp’s picture

Assigned: mpp » Unassigned
Status: Active » Needs review
FileSize
2.12 KB
mpp’s picture

Issue summary: View changes
mkalkbrenner’s picture

I see your point. But I‘m not yet sure about the best solution.

If you use Solr Cloud and run ten shards, the queried node reserves the memory for 10x1000 results for sorting.

So what is the limit that makes most sense?

That’s why I decided to set the Solr default limit when mo limit is set. Solr itself would react like this if we don’t pass a limit at all.

mpp’s picture

That’s why I decided to set the Solr default limit when mo limit is set. Solr itself would react like this if we don’t pass a limit at all

From a solr perspective it makes sense to set it to 10.

The problem is that we also set it to 10 when the "Display all items" pager is configured in views so we break views behaviour.

Imo we have two options:

A) Either we need to set a "high enough" limit (guess, 100 or 1000). It is up to people using solr cloud to fix memory performance issues by forcing them to set a limit (in code or views). I guess this could be an advanced option.

B) or we extend/swap the default views pager (Drupal\views\Plugin\views\pager\None) with a configurable default limit of 10 so it is clear from the UI that a limit applies.

Imo leaving the default "Display all items" pager is not an option.

mpp’s picture

Issue summary: View changes
FileSize
3.28 KB
mkalkbrenner’s picture

Status: Needs review » Needs work

I think we should introduce a config option per server to set the default limit.
I prefer an option per server rather than per index because an index could be moved between servers and it’s the server connector which technically influences the max limit.

mkalkbrenner’s picture

Status: Needs work » Needs review
FileSize
4.41 KB
mpp’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thanks!

limit, max_rows, default_limit, I was in doubt which oké to use.

limit is correct from drupal/views perspective but we're actually setting the maximum rows in the solr query.

I'll let you decide.

mkalkbrenner’s picture

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

You're right. 'rows' is the better name.

  • mkalkbrenner committed c0e20c4 on 8.x-3.x
    Issue #3068714 by mpp, mkalkbrenner: Views without a pager are now...
  • mkalkbrenner committed c359014 on 8.x-3.x
    Issue #3068714 by mpp, mkalkbrenner: Views without a pager are now...
  • mkalkbrenner committed f3ee645 on 8.x-3.x
    Issue #3068714 by mpp, mkalkbrenner: Views without a pager are now...
mkalkbrenner’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

potassiumchloride’s picture

For other users who are finding this thread because of a search like "Drupal views display shows ten results instead of all items when the pager is set to 'Display All Items' " -

Here are steps to make the change to your Solr server configuration:

  1. Go to the Edit tab for your Solr server, such as at /admin/config/search/search-api/server/default_solr_server/edit or /admin/config/search/search-api/server/[yourservername]/edit
  2. Open the "Configure...Back End" accordion.
  3. Open the "Advanced" accordion and look for "Default result rows."
  4. Change the "Default result rows" to a value larger than you would need for a "Display All Items" to work on your site.
  5. Save.
guaneagler’s picture

@potassiumchloride

Thanks for your information. It helps me a lot.

ressa’s picture

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.