PHP Doku:: Set offset and limit of the result set - sphinxclient.setlimits.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSuchmaschinenerweiterungenSphinx ClientThe SphinxClient classSphinxClient::setLimits

Ein Service von Reinhard Neidl - Webprogrammierung.

The SphinxClient class




(PECL sphinx >= 0.1.0)

SphinxClient::setLimitsSet offset and limit of the result set


public bool SphinxClient::setLimits ( int $offset , int $limit [, int $max_matches = 0 [, int $cutoff = 0 ]] )

Sets offset into server-side result set and amount of matches to return to client starting from that offset (limit). Can additionally control maximum server-side result set size for current query (max_matches) and the threshold amount of matches to stop searching at (cutoff).



Result set offset.


Amount of matches to return.


Controls how much matches searchd will keep in RAM while searching.


Used for advanced performance control. It tells searchd to forcibly stop search query once cutoff matches have been found and processed.


Gibt bei Erfolg TRUE zurück. Im Fehlerfall wird FALSE zurückgegeben.

3 BenutzerBeiträge:
- Beiträge aktualisieren...
xxxbunker dot com
22.03.2010 7:52
the max_matches / cutoff parameters are priceless.

if you ever have a situation where you need a 'count' of the number of matches, but only need to display lets say the 'top 10', these 2 parameters are very handy.

we used to get the occasional 'unable to connect' error with sphinx, after implementing these 2 parameters where applicable, these issues disappeared, load dropped, and the servers were much happier.
shoanm at users dot sourceforge dot net
25.08.2009 12:06
I almost pulled out all my hair trying to figure this one out. After applying limits using


the search kept returning only false. getLastError() and getLastWarning() contained empty strings.

The solution, like Nayana stated, is to add a positive non-zero integer $max to setLimit.
Nayana Hettiarachch nayana at corp-gems dot com
23.01.2009 17:36
If you get an error
per-query max_matches=0 out of bounds (per-server max_matches=1000).

make sure that you also set the $max to a value other than the default 0,

there is an issue published with a patch if you feel like wanting to patch,

the first option works well as a workaround.

PHP Powered Diese Seite bei
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)