Yevgeny Binder
2008-Apr-27 23:34 UTC
[Xapian-discuss] Patch to enable numeric sorting in Omega using scriptindex
Here is a quick patch to perform numeric sorting instead of the default string sort in Omega 1.0.6. This must be decided at index time, and is specified by replacing VALUE= with NUMERIC= in the database spec file (this patch is for scriptindex only). A slightly better approach, other than redesigning Omega (or Xapian?) to allow setting the sort method at search time, would be to use NUMERIC as a flag that modifies the VALUE= action, but I was just looking for an easy hack. I hope to see this patch, or something like it, added to the next release. - Yevgeny Binder 30a31 > #include <sstream> 98c99 < "truncate", "unhtml", "unique", "value", "weight" --- > "numeric", "truncate", "unhtml", "unique", "value", "weight" 109c110 < TRUNCATE, UNHTML, UNIQUE, VALUE, WEIGHT --- > NUMERIC, TRUNCATE, UNHTML, UNIQUE, VALUE, WEIGHT 235a237,243 > case 'n': > if (action == "numeric") { > code = Action::NUMERIC; > arg = YES; > takes_integer_argument = true; > } > break; 593a602,612 > case Action::NUMERIC: > if (!value.empty()) > { > std::istringstream to_double(value); > double value_double; > > to_double >> value_double; > > doc.add_value(i->get_num_arg(), Xapian::sortable_serialise(value_double)); > } > break;
Olly Betts
2008-Apr-28 01:09 UTC
[Xapian-discuss] Patch to enable numeric sorting in Omega using scriptindex
On Sun, Apr 27, 2008 at 06:34:29PM -0500, Yevgeny Binder wrote:> Here is a quick patch to perform numeric sorting instead of the > default string sort in Omega 1.0.6. This must be decided at index > time, and is specified by replacing VALUE= with NUMERIC= in the > database spec file (this patch is for scriptindex only). A slightly > better approach, other than redesigning Omega (or Xapian?) to allow > setting the sort method at search time, would be to use NUMERIC as a > flag that modifies the VALUE= action, but I was just looking for an > easy hack. I hope to see this patch, or something like it, added to > the next release.The 1.0 branch is supposed to now be "bug fixes only", but something like this can certainly go in 1.1.0. Could you regenerate the patch with "diff -u" and attach it to a new ticket in trac? Cheers, Olly
Kevin Duraj
2008-Apr-28 13:23 UTC
[Xapian-discuss] Patch to enable numeric sorting in Omega using scriptindex
How about performance ? Will the numeric sorting be faster then string sorting? -- Kevin Duraj http://myhealthcare.com On Sun, Apr 27, 2008 at 6:09 PM, Olly Betts <olly at survex.com> wrote:> On Sun, Apr 27, 2008 at 06:34:29PM -0500, Yevgeny Binder wrote: > > Here is a quick patch to perform numeric sorting instead of the > > default string sort in Omega 1.0.6. This must be decided at index > > time, and is specified by replacing VALUE= with NUMERIC= in the > > database spec file (this patch is for scriptindex only). A slightly > > better approach, other than redesigning Omega (or Xapian?) to allow > > setting the sort method at search time, would be to use NUMERIC as a > > flag that modifies the VALUE= action, but I was just looking for an > > easy hack. I hope to see this patch, or something like it, added to > > the next release. > > The 1.0 branch is supposed to now be "bug fixes only", but something > like this can certainly go in 1.1.0. > > Could you regenerate the patch with "diff -u" and attach it to a new > ticket in trac? > > Cheers, > Olly > > > _______________________________________________ > Xapian-discuss mailing list > Xapian-discuss at lists.xapian.org > http://lists.xapian.org/mailman/listinfo/xapian-discuss >