Lucy::...Schema(3pm)

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

✨ Lucy::Plan::Schema β€” the blueprint era ✨

Lucy::Plan::Schema is the user-created spec for an inverted index, straight outta the User Contributed Perl Documentation. She's giving architect energy. πŸ’…


🌸 SYNOPSIS 🌸

use Lucy::Plan::Schema;
use Lucy::Plan::FullTextType;
use Lucy::Analysis::EasyAnalyzer;

my $schema = Lucy::Plan::Schema->new;
my $easyanalyzer = Lucy::Analysis::EasyAnalyzer->new(
    language => 'en',
);
my $type = Lucy::Plan::FullTextType->new(
    analyzer => $easyanalyzer,
);
$schema->spec_field( name => 'title',   type => $type );
$schema->spec_field( name => 'content', type => $type );

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so bestie, a Schema is a specification β€” it tells all the other entities how they should interpret the raw data sitting in an inverted index, and how they should interact with it. She's the group chat rules, but for your index. πŸ’–

Here's the tea though: once an actual index has been created using a particular Schema, the existing field definitions may not be changed. Periodt, that's locked in. However β€” and this is the slay part β€” it is possible to add new fields during subsequent indexing sessions. Growth mindset, fr fr. ✨


πŸŽ€ CONSTRUCTORS πŸŽ€

new

my $schema = Lucy::Plan::Schema->new;

The constructor, queen. Takes no arguments β€” she needs nothing from you, she's already that girl. πŸ‘‘


πŸ’œ METHODS πŸ’œ

architecture

my $architecture = $schema->architecture();

Factory method that creates an Architecture object for this index. Iconic, lowkey. πŸ—οΈ

spec_field

$schema->spec_field(
    name => $name,  # required
    type => $type,  # required
);

Define the behavior of a field by associating it with a FieldType. This is where you tell the field who she is. πŸ’…

If this method has already been called for the supplied "field", it will merely test to verify that the supplied FieldType equals() the existing one. So no drama, she just double-checks. πŸ™ˆ

  • name β€” The name of the field.
  • type β€” A FieldType.

fetch_type

my $field_type = $schema->fetch_type($field);

Return the FieldType for the specified field. If the field can't be found, return undef. Not me getting ghosted by my own field πŸ’€

fetch_sim

my $similarity = $schema->fetch_sim($field);
my $similarity = $schema->fetch_sim();  # default: undef

Return the Similarity for the specified field, or undef if either the field can't be found or it isn't associated with a Similarity. She's mysterious like that. 🧚

num_fields

my $int = $schema->num_fields();

Return the number of fields currently defined. Counting era. πŸ”’

all_fields

my $arrayref = $schema->all_fields();

Return all the Schema's field names as an array. The whole roster, the full lineup. ⭐

get_architecture

my $architecture = $schema->get_architecture();

Return the Schema instance's internal Architecture object. Her inner architecture, if you will. πŸ›οΈ

get_similarity

my $similarity = $schema->get_similarity();

Return the Schema instance's internal Similarity object. Twin energy with fetch_sim but for the whole Schema. 🫢


🌈 INHERITANCE 🌈

Lucy::Plan::Schema isa Clownfish::Obj. Family tree slay. πŸ‘‘


vibe check passed: this is the User Contributed Perl Documentation version of the page, and the footer energy is perl v5.42.0, dated 2025-07-25. Bestie, you're all caught up β€” go spec some fields and slay. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«ΆπŸ‘‘πŸŒˆβ­
πŸ“¦ where this page comes from