Lucy::...rtRule(3pm)
π Lucy::Search::SortRule π
okay bestie, welcome to the User Contributed Perl Documentation corner of the internet, where we're talking about Lucy::Search::SortRule β yes that's the 3pm one, the Perl module manpage, you're in the right place π«Ά
β¨ NAME β¨
Lucy::Search::SortRule β literally just an element of a SortSpec. that's the whole job. tiny little building block. icon behavior π
π SYNOPSIS π
my $sort_spec = Lucy::Search::SortSpec->new(
rules => [
Lucy::Search::SortRule->new( field => 'date' ),
Lucy::Search::SortRule->new( type => 'doc_id' ),
],
);
see how cute that is?? you stack your rules up in a list and the SortSpec eats them. slay.
π¦ DESCRIPTION π¦
okay so here's the tea, bestie β
SortRules are the building blocks you use to assemble SortSpecs. every single SortRule defines one level of sorting. that's it. one rule = one layer.
so like, imagine you wanna sort first by "category" and then by score. the way that works is you need a SortSpec that holds two SortRule elements. no cap. first rule handles the category, second rule handles the score, and they tag-team the sort together. obsessed with them fr fr π
π CONSTRUCTORS π
πΈ new
my $by_title = Lucy::Search::SortRule->new( field => 'title' );
my $by_score = Lucy::Search::SortRule->new( type => 'score' );
my $by_doc_id = Lucy::Search::SortRule->new( type => 'doc_id' );
my $reverse_date = Lucy::Search::SortRule->new(
field => 'date',
reverse => 1,
);
make yourself a brand new SortRule. main character energy only π
here are the args you can pass, bestie:
typeβ tells it whether you're sorting by score, field, etc. (the default is to sort by a field, so if you don't say anything it's gonna assume field vibes.)fieldβ the name of a"sortable"field. (note the quotes, that word is doing work.)reverseβ if it's true, you flip the order of the sort for this rule only. just this one. not the others. iykyk.
π METHODS π
π get_field
my $string = $sort_rule->get_field();
accessor for the "field" member. it hands you back the string. that's it, she's simple and we love her.
π get_type
my $int = $sort_rule->get_type();
accessor for the "type" member. gives you back an int. very demure, very mindful.
π get_reverse
my $bool = $sort_rule->get_reverse();
accessor for the "reverse" member. returns a bool. yes or no, bestie, no in-between.
π INHERITANCE π
Lucy::Search::SortRule isa Clownfish::Obj. so yeah, she's got lineage. generational wealth of object-oriented goodness β¨
lowkey reminder: this page is the 3pm flavor β Perl module docs, not a command you run in your shell. don't try to SortRule anything in bash, bestie π
and that's the whole page!! written up as part of the perl v5.42.0 docs, dated 2025-07-25. thanks for reading my little manpage era, ily, go sort something pretty π¦πβ¨
π¦ 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