0

Suppose I have a query like this:

SELECT <somefields>
FROM example
ORDER BY somefield ASC
OPTION ranker=bm25

This seems contradictory. How is it going to sort? By somefield only? Or by BM25 rank only? Or both? If both then which is the most important? Can I use both like somefield ASC, rank DESC or rank DESC, somefield ASC? How can I disable sorting altogether?

Gherman
  • 6,768
  • 10
  • 48
  • 75

1 Answers1

1

Ordering by somefield only. There is an implicit ORDER BY WEIGHT() DESC, but if set any order, it completely overrides the implicit value.

... can choose to use weight in multisort, eg

ORDER BY somefield ASC, WEIGHT() DESC

In your example query, the actual calculated weight would be unused. Its not in sort, its not in the select. In fact sphinx might internally change to the 'none' ranker anyway, but can choose it explicitly

OPTION ranker=none

THere is no 'completely unsorted', can't say ORDER BY NULL or whatever.

barryhunter
  • 20,886
  • 3
  • 30
  • 43
  • Can I use `@rank` instead of `WEIGHT()`? I have old code with such usage. It used to work in older version of Sphinx and now it doesn't. But it was not listed in changes. – Gherman Apr 02 '19 at 10:35
  • I found answer to that. `@rank` was removed in version 3 – Gherman Apr 02 '19 at 11:09