Lucy::...rtRule(3pm)

πŸ“¦
version 0.6.2 Β· 2 versions
, in fedora 43

πŸ’– 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