27 Oct 2007 19:46:10 UTC
- Development release
- Distribution: KinoSearch
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (5)
- Testers (21 / 5 / 2)
- KwaliteeBus factor: 0
- License: perl_5
- Activity24 month
- Download (460.82KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionCREAMYG Marvin Humphreyand 1 contributors
- Marvin Humphrey <marvin at rectangular dot com>
- LICENSE, DISCLAIMER, BUGS, etc.
KinoSearch::Search::SortSpec - Specify a custom sort order for search results.
my $sort_spec = KinoSearch::Search::SortSpec->new; $sort_spec->add( field => 'date' ); my $hits = $searcher->search( query => $query, sort_spec => $sort_spec, );
By default, searches return results in order of relevance. SortSpec allows you to indicate an alternate order, using the contents of one or more fields.
Fields you wish to sort against must be indexed but must not be analyzed, as each document needs to be associated with a single value.
Each field that you sort against requires a sort cache, which is a C array of 32-bit integers. For each cache, the memory requirements are 4 bytes for each document in the index, plus loose change for object overhead. Additionally, a cache comprising some fraction of the terms in the index must be loaded. The time it takes to warm these caches on the first sorted search can be noticeable, but if you reuse your Searcher subsequent searches should be faster.
my $sort_spec = KinoSearch::Search::SortSpec->new;
Constructor. Takes no arguments.
$sort_spec->add( field => $field_name, # required reverse => 1, # default: 0 );
Add a field to sort against. Multiple sort criteria are processed in the order they were added (so the first to be added is the most important). Takes labeled parameters.
field - The name of a field which is indexed but not analyzed.
reverse - Reverse the order of the sort for this particular field.
Copyright 2007 Marvin Humphrey
See KinoSearch version 0.20.