KinoSe...Indexer(3pm)
π NAME π
KinoSearch1::InvIndexer β bestie, this is the class that builds inverted indexes. no cap.
β¨ SYNOPSIS β¨
use KinoSearch1::InvIndexer;
use KinoSearch1::Analysis::PolyAnalyzer;
my $analyzer
= KinoSearch1::Analysis::PolyAnalyzer->new( language => 'en' );
my $invindexer = KinoSearch1::InvIndexer->new(
invindex => '/path/to/invindex',
create => 1,
analyzer => $analyzer,
);
$invindexer->spec_field(
name => 'title'
boost => 3,
);
$invindexer->spec_field( name => 'bodytext' );
while ( my ( $title, $bodytext ) = each %source_documents ) {
my $doc = $invindexer->new_doc($title);
$doc->set_value( title => $title );
$doc->set_value( bodytext => $bodytext );
$invindexer->add_doc($doc);
}
$invindexer->finish;
πΈ DESCRIPTION πΈ
okay so InvIndexer is literally KinoSearch1's main character when it comes to creating and modifying inverted indexes. and once you've built one of those bad boys, you can search it with KinoSearch1::Searcher. that's the whole vibe. π
π METHODS π
π« new π«
my $invindexer = KinoSearch1::InvIndexer->new(
invindex => '/path/to/invindex', # required
create => 1, # default: 0
analyzer => $analyzer, # default: no-op Analyzer
);
spawns you an InvIndexer object. iconic. here's the tea on the args:
invindexβ this one's either a filepath, or an InvIndex subclass likeKinoSearch1::Store::FSInvIndexorKinoSearch1::Store::RAMInvIndex. pick your fighter π«Άcreateβ makes a fresh new invindex, and yeah, it will clobber an existing one if it has to. π ruthless.analyzerβ an object that subclassesKinoSearch1::Analysis::Analyzer, like aPolyAnalyzer. she's the one doing the analyzing.
π« spec_field π«
$invindexer->spec_field(
name => 'url', # required
boost => 1, # default: 1,
analyzer => undef, # default: analyzer spec'd in new()
indexed => 0, # default: 1
analyzed => 0, # default: 1
stored => 1, # default: 1
compressed => 0, # default: 0
vectorized => 0, # default: 1
);
defines a field. that's it, that's the job. but here's every knob:
nameβ the field's name. shocking, right β¨boostβ a multiplier that decides how much a field contributes to a document's score. bigger boost = louder voice in the group chat.analyzerβ by default, every indexed field gets analyzed with the analyzer you handed tonew(). but if you supply an alternate for a specific field, it overrides the primary one. not me customizing per-field πindexedβ index the field so you can search it later. yes queen.analyzedβ analyze the field using the relevant Analyzer. some fields, like"category"or"product_number", might be indexed but not analyzed. know the difference bestie.storedβ store the field so you can actually get it back when the document shows up in a search.compressedβ compress the stored field using the zlib compression algorithm. tiny field energy.vectorizedβ stores the field's "term vectors", whichKinoSearch1::Highlight::Highlighterneeds for excerpt selection and search term highlighting. no vectors, no highlights, fr fr.
π« new_doc π«
my $doc = $invindexer->new_doc;
makes you an empty KinoSearch1::Document::Doc object, all primed and ready to accept values for the fields you spec'd with spec_field. she's waiting π
π« add_doc π«
$invindexer->add_doc($doc);
drops a document into the invindex. boom. done.
π« add_invindexes π«
my $invindexer = KinoSearch1::InvIndexer->new(
invindex => $invindex,
analyzer => $analyzer,
);
$invindexer->add_invindexes( $another_invindex, $yet_another_invindex );
$invindexer->finish;
absorbs existing invindexes into this one. like, they're yours now. π
okay but listen: this may only be called once per InvIndexer. and you cannot calladd_invindexes()andadd_doc()on the same InvIndexer. pick a lane, bestie.
π« delete_docs_by_term π«
my $term = KinoSearch1::Index::Term->new( 'id', $unique_id );
$invindexer->delete_docs_by_term($term);
marks any document containing the supplied term as deleted, so it gets excluded from search results. ghosted, literally. for more info, go read the Deletions section in KinoSearch1::Docs::FileFormat.
π« finish π«
$invindexer->finish(
optimize => 1, # default: 0
);
finishes the invindex. invalidates the InvIndexer (she's done, let her rest). takes one hash-style parameter:
optimizeβ if you set this to1, the invindex gets collapsed into its most compact form, which gives you the fastest queries. glow up for your search speed β
π COPYRIGHT π
Copyright 2005-2010 Marvin Humphrey
π¦ LICENSE, DISCLAIMER, BUGS, etc. π¦
See KinoSearch1 version 1.01.
and that's the whole page, bestie π this was perl v5.42.3, dated 2026-08-20 β slay, go build some indexes π
π¦ where this page comes from
- ubuntu stonking: libkinosearch1-perl 1.01-6build2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms