WebService::Solr(3pm)
π WebService::Solr β the manual, but make it cute π
okay so bestie, you know that Perl module WebService::Solr? This is its page from the 3pm man section, and I'm gonna walk you through every single line of it like we're texting at 2am. no cap, nothing gets skipped. π«Ά
β¨ NAME β¨
WebService::Solr β the module to interface with the Solr (Lucene) webservice. that's it. that's the vibe. π
β¨ SYNOPSIS β¨
here's the whole thing in its natural habitat, written exactly like the original so you can literally copy-paste and slay:
my $solr = WebService::Solr->new;
$solr->add( @docs );
my $response = $solr->search( $query );
for my $doc ( $response->docs ) {
print $doc->value_for( $id );
}
likeβ¦ iconic. make it, fill it, search it, read it. π¦
β¨ DESCRIPTION β¨
So WebService::Solr is a client library for Apache Lucene's Solr β which is, and I quote, an enterprise-grade indexing and searching platform. enterprise grade?? we love a professional queen. π
β¨ ACCESSORS β¨
these are the lil properties you can vibe with:
urlβ the webservice base url πagentβ a user agent objectautocommitβ a boolean value for automaticcommit()after add/update/delete (default: enabled) βdefault_paramsβ a hashref of parameters to send on every requestlast_responseβ stores aWebService::Solr::Responsefor the last request
β¨ HTTP KEEP-ALIVE β¨
turning on HTTP Keep-Alive is literally as easy as passing your custom user-agent to the constructor. that's the whole trick, bestie:
my $solr = WebService::Solr->new( $url,
{ agent => LWP::UserAgent->new( keep_alive => 1 ) }
);
go visit LWP::UserAgent's documentation for more info and all the available options. iykyk π
β¨ METHODS β¨
πΈ new( $url, \%options )
Creates a new WebService::Solr instance. If $url is omitted, then "http://localhost:8983/solr" is used as a default. Available options are listed in the ACCESSORS section above. periodt. π
πΈ BUILDARGS( @args )
A Moo override to allow our custom constructor. that's it, that's the whole job. π§
πΈ add( $doc|\@docs, \%options )
Adds a number of documents to the index. Returns true on success, false otherwise. A document can be a WebService::Solr::Document object or a structure that can be passed to "WebService::Solr::Document->new". Available options as of Solr 1.4 are:
overwrite(default: true) β Replace previously added documents with the sameuniqueKeycommitWithin(in milliseconds) β The document will be added within the specified time β±οΈ
πΈ update( $doc|\@docs, \%options )
Alias for "add()". same energy, different name. β¨
πΈ delete( \%options )
Deletes documents matching the options provided. The delete operation currently accepts "query" and "id" parameters. Multiple values can be specified as array references. watch this:
# delete documents matching "title:bar" or uniqueId 13 or 42
$solr->delete( {
query => 'title:bar',
id => [ 13, 42 ],
} );
πΈ delete_by_id( $id )
Deletes all documents matching the id specified. Returns true on success, false otherwise. ποΈ
πΈ delete_by_query( $query )
Deletes documents matching $query. Returns true on success, false otherwise. π
πΈ search( $query, \%options )
Searches the index given a $query. Returns a WebService::Solr::Response object. All key-value pairs supplied in "\%options" are serialized in the request URL. lowkey magical.
If filter queries are needed, create WebService::Solr::Query objects and pass them into the %options. For example, if you were searching a database of books for a subject of "Perl", but wanted only paperbacks and a copyright year of 2011 or 2012:
my $query = WebService::Solr::Query->new( { subject => 'Perl' } );
my %options = (
fq => [
WebService::Solr::Query->new( { binding => 'Paperback' } ),
WebService::Solr::Query->new( { year => [ 2011, 2012 ] } ),
],
);
my $response = $solr->search( $query, \%options );
The filter queries are typically added when drilling down into search results and selecting a facet to drill into. π
In order to enable facets, the option "facet => "on"" must be passed. Facet options are detailed in the wiki (https://wiki.apache.org/solr/SimpleFacetParameters). π
πΈ auto_suggest( \%options )
Get suggestions from a list of terms for a given field. The Solr wiki has more details about the available options (http://wiki.apache.org/solr/TermsComponent). so helpful fr fr π
πΈ commit( \%options )
Sends a commit command. Returns true on success, false otherwise. You must do a commit after an add, update or delete. By default, autocommit is enabled. You may disable autocommit to allow you to issue commit commands manually:
my $solr = WebService::Solr->new( undef, { autocommit => 0 } );
$solr->add( $doc ); # will not automatically call commit()
$solr->commit;
bestie listen: no commit = your changes are just β¨vibesβ¨ and not on disk. commit your work. π
Options as of Solr 1.4 include:
maxSegments(default: 1) β Optimizes down to at most this number of segmentswaitFlush(default: true) β Block until index changes are flushed to diskwaitSearcher(default: true) β Block until a new searcher is openedexpungeDeletes(default: false) β Merge segments with deletes away
πΈ rollback( )
This method will rollback any additions/deletions since the last commit. undo button energy. π
πΈ optimize( \%options )
Sends an optimize command. Returns true on success, false otherwise.
Options as of Solr 1.4 are the same as "commit()". π₯
πΈ ping( )
Sends a basic ping request. Returns true on success, false otherwise. just checking you're alive, bestie π«Ά
πΈ generic_solr_request( $path, \%query )
Performs a simple "GET" request appending $path to the base URL and using key-value pairs from "\%query" to generate the query string. This should allow you to access parts of the Solr API that don't yet have their own correspondingly named function (e.g. "dataimport"). the secret menu order π
β¨ SEE ALSO β¨
http://lucene.apache.org/solr/Solrβ an alternate library
β¨ AUTHORS β¨
- Andy Lester
"andy@petdance.com" - Brian Cassidy
<bricas@cpan.org> - Kirk Beers
give them their flowers, they built this. ππ
β¨ COPYRIGHT AND LICENSE β¨
Copyright 2008-2014 National Adult Literacy Database Copyright 2015-2020 Andy Lester
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
legal queen behavior, we respect it π
and that's the whole page, bestie β slay, you read every last line. π
this was perl v5.36.0, dated 2022-10-16, for WebService::Solr(3pm). mwah, go build something iconic. β¨π¦π
π¦ where this page comes from
- ubuntu noble: libwebservice-solr-perl 0.44-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libwebservice-solr-perl 0.44-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libwebservice-solr-perl 0.44-2 Β· 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