From: John Fawcett Date: Wed, 3 Jan 2024 13:48:43 +0000 (+0100) Subject: fts-solr: Limit fetches to SOLR_MAX_MULTI_ROWS X-Git-Tag: 2.4.0~1684 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b47420d3effe1615b6dae93c19e741cf0da1930;p=thirdparty%2Fdovecot%2Fcore.git fts-solr: Limit fetches to SOLR_MAX_MULTI_ROWS Solr place upper bound on number of rows to be returned from solr for single mailbox search When dovecot sends a search to solr it uses the rows parameter. For multiple mailbox search the value used is SOLR_MAX_MULTI_ROWS , hardcoded to 100000. For single mailbox search the value used is uidnext. This patch introduces an upper limit for single mailbox search using the same upper bound as for multiple mailbox searches, SOLR_MAX_MULTI_ROWS, while leaving the existing functionality of sending the uidnext value if it is smaller. This is just to place a more reasonable upper bound since uidnext can get much larger than 100000. The following url points to the Solr documentation for query parameters that describes the rows parameter: https://solr.apache.org/guide/solr/latest/query-guide/common-query-parameters.html --- diff --git a/src/plugins/fts-solr/fts-backend-solr.c b/src/plugins/fts-solr/fts-backend-solr.c index 4ab8b14a91..6174909f2b 100644 --- a/src/plugins/fts-solr/fts-backend-solr.c +++ b/src/plugins/fts-solr/fts-backend-solr.c @@ -845,7 +845,7 @@ fts_backend_solr_lookup(struct fts_backend *_backend, struct mailbox *box, str = t_str_new(256); str_printfa(str, "wt=xml&fl=uid,score&rows=%u&sort=uid+asc&q=%%7b!lucene+q.op%%3dAND%%7d", - status.uidnext); + I_MIN(status.uidnext, SOLR_MAX_MULTI_ROWS)); prefix_len = str_len(str); if (solr_add_definite_query_args(str, args, and_args)) {