Search...nsport(3pm)
π Search::Elasticsearch::Transport π
okay bestie, so this is a page from the User Contributed Perl Documentation β it's the 3pm manual for Search::Elasticsearch::Transport, version 8.12. she's the little connector between your client and your cluster and she works. let's get into it π«Ά
β¨ NAME β¨
Search::Elasticsearch::Transport β she provides the interface between the client class and the Elasticsearch cluster. like, the whole bridge situation. π
πΈ VERSION πΈ
version 8.12 β that's the one, that's her. π
π¦ DESCRIPTION π¦
so the Transport class is the one running the whole request cycle. the way it works is: the (user-facing) client class hands her a bunch of already-parsed requests, and she tries to actually execute each one on a node in the cluster. and if it doesn't go through the first time? she retries. she's persistent like that. π₯
this class does Search::Elasticsearch::Role::Transport and Search::Elasticsearch::Role::Is_Sync. iconic behaviour honestly.
π CONFIGURATION π
"send_get_body_as" π
$e = Search::Elasticsearch->new(
send_get_body_as => 'POST'
);
okay so here's the lore: certain endpoints β like search() in Search::Elasticsearch::Client::6_0::Direct β default to using a GET method, even when they include a request body. and some proxy servers are not here for GET requests with a body. rude of them but whatever. so to work around that whole situation, the send_get_body_as parameter accepts the following:
GETβ the default, babes. request bodies get sent asGETrequests. no notes. πPOSTβ the method gets changed toPOSTwhen a body is present. glow-up moment.sourceβ the body gets encoded as JSON and added to the query string as thesourceparameter. the win here? it's still aGETrequest, which slays for anyone out there filtering on request method. the loss? it's restricted in size π. the exact limit depends on the proxies sitting between the client and Elasticsearch, but usually it's around4kB. so likeβ¦ keep it cute and keep it small.
π METHODS π
perform_request() π
you can execute raw requests using the transport class like this:
$result = $e->transport->perform_request(
method => 'POST',
path => '/_search',
qs => { from => 0, size => 10 },
body => {
query => {
match => {
title => "Elasticsearch clients"
}
}
}
);
other than the method, path, qs and body parameters β which are honestly self-explanatory bestie, you got this β she also accepts:
ignoreβ the HTTP error codes that should be ignored instead of throwing an error. for example404 NOT FOUND:
$result = $e->transport->perform_request(
method => 'GET',
path => '/index/type/id'
ignore => [404],
);
serializeβ whether thebodyshould be serialized the standard way (as plain JSON) or using the special bulk format. your options arestdorbulk. pick your fighter. β
π AUTHOR π
Enrico Zimuel <enrico.zimuel@elastic.co> β king behaviour, thank you for your service. πββοΈ
π COPYRIGHT AND LICENSE π
this software is Copyright (c) 2024 by Elasticsearch BV.
and it's free software, licensed under:
The Apache License, Version 2.0, January 2004
okay that's the whole page, no cap. everything's here, nothing skipped, we ate and left no crumbs. π
and for the little sign-off at the very bottom, in true footer fashion: this one's from perl v5.38.2, dated 2024-02-04, and it's the Search::Elasticsearch::Transport page. bye bestie, go perform_request() something iconic πβ¨
π¦ 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