Lucy::...rtSpec(3pm)
β¨ Lucy::Search::SortSpec β the vibe-sorting manual β¨
okay bestie, welcome to Lucy::Search::SortSpec from the User Contributed Perl Documentation collection π this is the page that tells you how to make your search results come back in your order instead of the default one. she's giving main character energy for real π
πΈ NAME πΈ
Lucy::Search::SortSpec β Specify a custom sort order for search results. yes literally that's her whole job and she ate π
π¦ SYNOPSIS π¦
my $sort_spec = Lucy::Search::SortSpec->new(
rules => [
Lucy::Search::SortRule->new( field => 'date' ),
Lucy::Search::SortRule->new( type => 'doc_id' ),
],
);
my $hits = $searcher->hits(
query => $query,
sort_spec => $sort_spec,
);
look at her go π build a SortSpec, hand it to hits(), and suddenly your results are sorted however you want. iconic behavior tbh.
π DESCRIPTION π
so by default, searches return results in order of relevance. that's the whole default vibe. but if you want a different order, SortSpec lets you say so β you just pass in an array of SortRules and she'll sort accordingly β¨
heads up bestie: fields you wish to sort against must be "sortable". no sortable field, no sorting, no exceptions π«Ά
and if you want a stable sort β which is super important when you're paging through results, like literally do not skip this β add a sort-by-doc rule as the last SortRule. that's the move. periodt. π
π CONSTRUCTORS π
π new
my $sort_spec = Lucy::Search::SortSpec->new( rules => \@rules );
Create a new SortSpec. slay, that's it, that's the constructor π
rulesβ An array of SortRules. that's the whole thing, just hand her your rules and let her cook π
π INHERITANCE π
Lucy::Search::SortSpec isa Clownfish::Obj. so she's got that Clownfish lineage, iykyk π¦
and that's the whole page bestie, no notes π this lil' manual came to you from Lucy::...rtSpec(3pm), dated 2025-07-25, running on perl v5.42.0 π go forth and sort responsibly, mwah π
π¦ where this page comes from
- fedora 43: perl-Lucy 0.6.2-26.fc43 Β· Apache-2.0 AND MIT AND Unicode-DFS-2015
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms