[Xapian-discuss] Bug: scriptindex - xapian-omega 0.9.99_svn8484
Olly Betts
olly at survex.com
Sat May 12 02:56:46 BST 2007
On Fri, May 11, 2007 at 03:23:42PM -0700, Kevin Duraj wrote:
> This is my result when I sort by value and relevance.
> Xapian treating the result as string and sorting it accordingly ....
That's the documented behaviour - "Sorting is with a string compare"
as it says in the API documentation for the sort_key parameter of
set_sort_by_value_then_relevance() (and set_sort_by_value() and
set_sort_by_relevance_then_value()):
void Xapian::Enquire::set_sort_by_value_then_relevance(
Xapian::valueno sort_key,
bool ascending = true
)
Set the sorting to be by value, then by relevance for documents with
the same value.
Parameters:
sort_key value number to reorder on. Sorting is with a
string compare. If ascending is true (the default)
higher is better; if ascending is false, lower is better.
ascending If true, documents values which sort higher by
string compare are better. If false, the sort order is
reversed. (default true)
See http://www.xapian.org/docs/apidoc/html/classXapian_1_1Enquire.html
> Value:9.48910782703839
> Value:9.48903215258983
> Value:9.48888078651068
> Value:9.48880509487835
> Value:44.7864142310669
> Value:42.1408884722407
> Value:41.0120506955037
If you want numbers to sort numerically, you'll either need to zero (or
space) pad them, or prefix the length of the integer part (say prefix
A for 1 up to Z for 26). For example:
Value Zero Pad Length Prefix
0 00000000 A0
9.48910782703839 00000009.48910782703839 A9.48910782703839
12 00000012 B12
44.7864142310669 00000044.7864142310669 B44.7864142310669
997.4 00000997.4 C997.4
1000000 01000000 G1000000
Cheers,
Olly
More information about the Xapian-discuss
mailing list