문제

Here is the code of sphinx

    $sphinx_results = clone $this->sphinx;

    //Select Columns
    $sphinx_results->SetSelect($col . ', @count'); //Select cols

    //Group results
if($col=='province')
{
    $sort_str = ($sort_str === FALSE) ? $col.' asc' : $sort_str; //Get sort string
    }
else
$sort_str = ($sort_str === FALSE) ? '@count desc' : $sort_str; //Get sort string
$sphinx_results->SetGroupBy($col, $sphinx_results::SPH_GROUPBY_ATTR, $sort_str);

    //Perform Query
    $results = $sphinx_results->Query( $this->keyword, 'autoandt_www' );

I wanted to select 10 provinces with maximum count and i wanted to this result in alphabetical order of provinces. How to accomplish this in php sphinx. I am using kohana framework.

올바른 솔루션이 없습니다

다른 팁

The easiest way is to just get the top 10 results from sphinx - which it looks like you already have that in your code.

Then in the application resort them into alphabetical order. Pretty trivial in most languages. within PHP the uksort function is nice. But no idea if kohana provides any sort of convenience function.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top