Lucy::...earcher(3pm)
π Lucy::Search::IndexSearcher β the manual, but make it cute π
Perl documentation, user-contributed edition β yes bestie, this is a 3pm page, we're in the cool section of the manual π
β¨ NAME β¨
Lucy::Search::IndexSearcher β go run searches against one single index. That's the whole job. She's focused. She's got main character energy. π
πΈ SYNOPSIS πΈ
my $searcher = Lucy::Search::IndexSearcher->new(
index => '/path/to/index'
);
my $hits = $searcher->hits(
query => 'foo bar',
offset => 0,
num_wanted => 100,
);
Look at her go. Build the searcher, ask for hits, done. Iconic. β¨
π¦ DESCRIPTION π¦
Okay so here's the tea β β you use the IndexSearcher class to run search queries against an index. That's it, that's the vibe. And if you're tryna search multiple indexes at once? Not her job, bestie β go look at PolySearcher instead. π«Ά
Now, the important part, and I need you to hear me on this one: IndexSearchers operate against a single point-in-time view β a Snapshot β of the index. So if the index gets modified, your searcher does NOT magically see it. You have to open a new IndexSearcher to access the changes. No cap. π¨
π CONSTRUCTORS π
π« new
my $searcher = Lucy::Search::IndexSearcher->new(
index => '/path/to/index'
);
Create a new IndexSearcher. Fresh out the box, ready to serve π
- index β Either a string filepath, a Folder, or an IndexReader. Pick your fighter, any of the three works. π
π METHODS π
π doc_max
my $int = $index_searcher->doc_max();
Returns the maximum number of docs in the collection that the Searcher represents β which is also the highest possible internal doc id. And heads up: documents that have been marked as deleted but not yet purged are still counted in this number. She counts them anyway. Messy but honest π
π doc_freq
my $int = $index_searcher->doc_freq(
field => $field, # required
term => $term, # required
);
Returns the number of documents that contain the term in the given field.
- field β Field name. (required, no skipping π)
- term β The term to look up. (also required, bestie π)
π§Ί collect
$index_searcher->collect(
query => $query, # required
collector => $collector, # required
);
Iterate over hits, feeding them into a Collector. Like a little conveyor belt of results going straight into the collector's hands π
- query β A Query.
- collector β A Collector.
π fetch_doc
my $hit_doc = $index_searcher->fetch_doc($doc_id);
Retrieve a document. And β οΈ β she throws an error if the doc id is out of range. So don't come at her with a bogus id, she will absolutely not be chill about it π
- doc_id β A document id.
π get_reader
my $index_reader = $index_searcher->get_reader();
Accessor for the object's "reader" member. Just hands you the reader, no drama, we love a simple girl π
π INHERITANCE π
Lucy::Search::IndexSearcher isa Lucy::Search::Searcher isa Clownfish::Obj.
Three generations of iconic lineage, we stan a family tree π
Reminder bestie: index changed? new searcher. That's the whole moral of the story, iykyk π§
And that's the page! π«Ά This was perl v5.42.0, dated 2025-07-25, from the one and only Lucy::...earcher(3pm) β User Contributed Perl Documentation. Slay, go search something. πβ¨π
π¦ 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