Search...:Direct(3pm)
π NAME π
Search::Elasticsearch::Role::Client::Direct β bestie, it's the request-parsing role for Direct clients β¨
π¦ VERSION π¦
version 8.12 β she's giving current, no cap π
πΈ DESCRIPTION πΈ
okay so listen. This role is a one-trick pony in the best way possible β it hands you exactly one method, parse_request(), and that's literally it.
Who needs it? Any class that has to take an API definition from Search::Elasticsearch::Role::API and glow it up into an actual request that can be passed along to perform_request() in Search::Elasticsearch::Transport. That's the whole vibe. π
β¨ METHODS β¨
π«Ά perform_request()
$request = $client->parse_request(\%defn,\%params);
So the %defn here is a definition that came back from api() in Search::Elasticsearch::Role::API, except it's got one extra key: name π. And that name should be the name of the method that got called on the client. Like, if somebody calls $client->search, then the name is literally search. That's it, that's the rule π
Then parse_request() takes all the params you passed in and turns them into:
- a
pathβ built viapath_init()inSearch::Elasticsearch::Util::API::Pathπ£οΈ - a query-string hash β built via
qs_initinSearch::Elasticsearch::Util::API::QSπ - and it will pass a
bodyvalue straight through, untouched, like it's not even there β¨
β οΈ NOTE, and this one's important bestie: if you specify apathkey inside%params, it gets used directly β no trying to build the path from the path template, she skips all that. Same energy withparams: if aparamskey shows up in%params, that becomes the basis for the query string hash. For instance:
$client->perform_request(
{
method => 'GET',
name => 'new_method'
},
{
path => '/new/method',
params => { foo => 'bar' },
body => \%body
}
);
And that's why this is so iconic β it makes it super easy to add support for custom plugins, or for brand new functionality that the released client doesn't support yet. main character energy for real π₯
π AUTHOR π
Enrico Zimuel <enrico.zimuel@elastic.co> β thank you king π
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2024 by Elasticsearch BV.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
and that's the whole page, bestie!! π this was perl v5.38.2, dated 2024-02-04, and it's the Search::Elasticsearch::Role::Client::Direct manpage from the User Contributed Perl Documentation β slay, go parse some requests, ily πβ¨
π¦ where this page comes from
- debian trixie: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu noble: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu resolute: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu stonking: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms