Browse Source

Update sphinx_min_max_matches in scheduler

Fixes #1
spaghetti 8 years ago
parent
commit
87bec35386

+ 0
- 1
classes/config.template View File

@@ -56,7 +56,6 @@ define('SPHINX_PORT',        9312);
56 56
 define('SPHINXQL_HOST',      '127.0.0.1');
57 57
 define('SPHINXQL_PORT',      9306);
58 58
 define('SPHINXQL_SOCK',      false);
59
-define('SPHINX_MAX_MATCHES', 1000); // Must be <= the server's max_matches variable (default 1000)
60 59
 define('SPHINX_MIN_MAX_MATCHES', 2000); // Exclusively for fixing total number of default search results. Raise as necessary
61 60
 define('SPHINX_INDEX',       'torrents');
62 61
 

+ 2
- 1
classes/torrentsearch.class.php View File

@@ -182,7 +182,8 @@ class TorrentSearch {
182 182
         ->order_by(self::$SortOrders[$OrderBy], $OrderWay);
183 183
     }
184 184
     $Offset = ($this->Page - 1) * $ResultLimit;
185
-    $MaxMatches = max($Offset + $ResultLimit, SPHINX_MIN_MAX_MATCHES);
185
+    $MinMax = G::$Cache->get_value('sphinx_min_max_matches');
186
+    $MaxMatches = max($Offset + $ResultLimit, $MinMax ? $MinMax : 2000);
186 187
     $this->SphQL->from('torrents, delta')
187 188
       ->limit($Offset, $ResultLimit, $MaxMatches);
188 189
   }

+ 11
- 0
sections/schedule/hourly/sphinx_min_max_matches.php View File

@@ -0,0 +1,11 @@
1
+<?
2
+$SphQL = new SphinxqlQuery();
3
+$SphQL->where_match('_all', 'fake', false);
4
+$SphQL->select('id')->from('torrents, delta')->limit(0,0,10000);
5
+$TTorrents = $SphQL->query()->get_meta('total_found');
6
+
7
+$SphQL->select('groupid')->group_by('groupid')$SphQL->from('torrents, delta')->limit(0,0,10000);
8
+$TGroups = $SphQL->query()->get_meta('total_found');
9
+
10
+$Cache->cache_value('sphinx_min_max_matches', 2*($TTorrents-$TGroups));
11
+?>

Loading…
Cancel
Save