How to select more than 20 rows in SPHINX engine?

All we need is an easy explanation of the problem, so here it is.

I use SphinxSE instead of FULLTEXT. Sphinx settings are for end-users of a search engine. According to the official documentation,

LIMIT clause. Both LIMIT N and LIMIT M,N forms are supported. Unlike
in regular SQL (but like in Sphinx API), an implicit LIMIT 0,20 is
present by default.

Therefore, any query returns only 20 rows

MariaDB [sphinx]> SELECT * FROM t1 WHERE query='test;mode=any';
+------+--------+---------------+
| id   | weight | query         |
+------+--------+---------------+
|  556 |      1 | test;mode=any |
|  864 |      1 | test;mode=any |
| 1329 |      1 | test;mode=any |
| 1781 |      1 | test;mode=any |
| 1832 |      1 | test;mode=any |
| 2157 |      1 | test;mode=any |
| 2388 |      1 | test;mode=any |
| 2889 |      1 | test;mode=any |
| 3118 |      1 | test;mode=any |
| 3155 |      1 | test;mode=any |
| 3255 |      1 | test;mode=any |
| 3485 |      1 | test;mode=any |
| 3495 |      1 | test;mode=any |
| 3623 |      1 | test;mode=any |
| 4034 |      1 | test;mode=any |
| 4525 |      1 | test;mode=any |
| 4563 |      1 | test;mode=any |
| 4659 |      1 | test;mode=any |
| 4736 |      1 | test;mode=any |
| 4807 |      1 | test;mode=any |
+------+--------+---------------+
20 rows in set (0.027 sec)

I experimented with various settings in the sphinx.conf, but am unable to change the setting to return more results in a SQL query.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

In docs you can include limit=40. So:

SELECT * FROM t1 WHERE query='test;mode=any;limit=40';

Not a usual SQL way, but SphinxSE isn’t quite normal.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply