T
T
titronium2015-03-20 09:46:25
MySQL
titronium, 2015-03-20 09:46:25

How to do a simple sort by id in Sphinx?

The essence of the question is simple. There is a big table in mysql for 10 million records. The table is constantly growing.
On the main page, you need to display the latest posts with pagelinks from 0 to 10000.
Doing it through mysql through limits (limit 0.50) is long and stupid. Therefore, I think sphinx should help with this.
I create an index (address) based on a simple table of 2 fields: id and address
The table is filled with keywords from addresses.
Address example: 702 St Bentonville, United States
In general, I need an index for both pagelinks and for searching by the address field.
The code:

include('sphinxapi.php');
$cl = new SphinxClient();

$cl->SetServer( "localhost", 9312 );
$cl->SetMatchMode(SPH_MATCH_ANY);
$cl->SetSortMode(SPH_SORT_EXTENDED, '@id desc');
$cl->SetLimits(0, 50);

// ?

Search by field to make it clear - $cl->Query("New York", "address");
But just the output of the last pages with pagelinks, sorted simply by the id (desc) field?
I ask for advice.
--
UPD:
So far I've done this:
include('sphinxapi.php');
$cl = new SphinxClient();

$cl->SetServer( "localhost", 9312 );
$cl->SetMatchMode(SPH_MATCH_EXTENDED2);
$cl->SetSortMode(SPH_SORT_EXTENDED, '@id desc');
$cl->SetLimits(0, 50);

$cl->Query("", "address");  // пустое поле, т.к. просто постраничный вывод

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question