moritz has asked for the wisdom of the Perl Monks concerning the following question:

I'm about to use the excellent KinoSearch module for a few non-standard tasks, for example for searching in IRC logs and SVN commit messages.

Both are "non-standard" in that it doesn't make sense to order the results by match quality, chronologically ordered results are much more useful (at least optionally).

Of course I could retrieve the results normally, sort them all, and re-implement the paging of results manually, but that's rather inefficient and clumsy.

Can I tell KinoSearch somehow to sort the result set by user-defined criteria? I know these criteria at indexing time (and even index creation time, if that helps).

grep'ping for sort seems promising, but so far I couldn't find documentation on how to do it.

Replies are listed 'Best First'.
Re: Sorting KinoSearch results
by jds17 (Pilgrim) on Jun 19, 2008 at 11:51 UTC
    I did not hear about this module before, looks very interesting. I read some of the documentation and came across KinoSearch::Search::SortSpec, which can be used to define altrnative sort orders. Seems like this could help you.
      Thanks, that seem to do the trick. Now I have to convince SVN::Log::Index to actually use it, either by patching or subclassing.

        Please note that SortSpec is available in the 0.20_xx devel branch of KinoSearch but not the stable 0.1x branch. While you should be able to use the devel branch on systems that you control, submitting a patch for SVN::Log::Index would be problematic: unfortunately, adding features such as SortSpec to KS necessitated changing both the file format and the API in ways that are not backwards compatible.

        When the KS devel branch approaches release maturity, I'm willing to work in conjunction with CPAN authors who have distros with KinoSearch as a dependency to update their modules. Patching for the current devel release probably wouldn't make sense though, because the KS file format and API are still unstable. (As for release schedule, I never issue time estimates unless somebody's paying me :) -- but FWIW I am working on KS full time right now.)

        --
        Marvin Humphrey
        Rectangular Research ― http://www.rectangular.com