Search...nsport(3pm)

πŸ“¦
version 8.12 Β· 5 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 as GET requests. no notes. πŸ’…
  • POST β€” the method gets changed to POST when a body is present. glow-up moment.
  • source β€” the body gets encoded as JSON and added to the query string as the source parameter. the win here? it's still a GET request, 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 around 4kB. 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 example 404 NOT FOUND:
$result = $e->transport->perform_request(
    method => 'GET',
    path   => '/index/type/id'
    ignore => [404],
);
  • serialize β€” whether the body should be serialized the standard way (as plain JSON) or using the special bulk format. your options are std or bulk. pick your fighter. ⭐

πŸ’œ AUTHOR πŸ’œ

Enrico Zimuel <enrico.zimuel@elastic.co> β€” king behaviour, thank you for your service. πŸ™‡β€β™€οΈ


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