sluijs
sluijs

Reputation: 4237

Order of sphinx results is always ascending

Somehow, whatever the query is, Sphinx always returns results in ascending order (ordered by the primary ID). Say I'm searching for "foo" in these 5 documents:

  1. foo bar
  2. foo foo foo foo
  3. ja la la
  4. foo foo foo foo foo
  5. foo foo foo

This would return matches: 1, 2, 4, 5 with 1 being the most relevant. At least, this is what var_dump shows me in PHP. However, I want the real order to be: 4, 2, 5, 1. How am I supposed to fix this? I'm using the following settings:

$sphinx->SetMatchMode(SPH_MATCH_ALL);
$sphinx->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
$sphinx->SetSortMode(SPH_SORT_RELEVANCE);

The following source is being searched:

source pages
{
      type = mysql
      sql_query = SELECT text_id, book_id, content, page_number FROM text
      sql_attr_uint = page_number
      sql_attr_uint = book_id
      sql_query_pre = SET SESSION group_concat_max_len = 4294967295
}

Upvotes: 1

Views: 293

Answers (1)

Miro
Miro

Reputation: 456

Try using SPH_MATCH_EXTENDED2 match mode with SPH_RANK_WORDCOUNT

Upvotes: 3

Related Questions