Search...le::API(3pm)

πŸ“¦ version 7.715, in ubuntu jammy

πŸ’… NAME πŸ’…

okay bestie, gather round, because this one is literally the blueprint of the whole Elasticsearch API situation: Search::Elasticsearch::Client::7_0::Role::API β€” the class that holds the spec for the Elasticsearch APIs. yes, the whole spec. she's the source of truth, the main character, the one everyone else copies off of. πŸŽ€

(also, for the record, this is User Contributed Perl Documentation, so you know it's giving community love. ✨)


🌸 VERSION 🌸

this is version 7.715. no cap, that's the number, don't come for me. πŸ’–


✨ DESCRIPTION ✨

so, every single Elasticsearch API is defined inside this role. like, all of them. the whole squad lives here. 🫢

here's the example they give you β€” it's the definition for the "index()" in the Search::Elasticsearch::Client::7_0::Direct method:

'index' => {
    body   => { required => 1 },
    doc    => "docs-index_",
    method => "POST",
    parts  => { id => {}, index => {}, type => {} },
    paths  => [
        [   { id => 2, index => 0, type => 1 }, "{index}",
            "{type}",                           "{id}"
        ],
        [ { id    => 2, index => 0 }, "{index}", "_doc", "{id}" ],
        [ { index => 0, type  => 1 }, "{index}", "{type}" ],
        [ { index => 0 }, "{index}", "_doc" ],
    ],
    qs => {
        error_trace            => "boolean",
        filter_path            => "list",
        human                  => "boolean",
        if_primary_term        => "number",
        if_seq_no              => "number",
        op_type                => "enum",
        pipeline               => "string",
        refresh                => "enum",
        require_alias          => "boolean",
        routing                => "string",
        timeout                => "time",
        version                => "number",
        version_type           => "enum",
        wait_for_active_shards => "string",
    },
}

look at her. the paths, the qs, the parts. immaculate. 🧚

and here's the tea: these definitions are meant to be used by different Search::Elasticsearch::Role::Client implementations, so each one can serve up its own distinct user interface. same spec, different fits. πŸ‘‘


πŸ”₯ METHODS πŸ”₯

πŸ’œ "api()"

$defn = $api->api($name);

okay so there's literally only one method in this entire class and it's this one, "api()". you hand it the name of the action, and it hands you back its definition. that's it. that's the whole job. iconic behavior honestly. πŸ’…

one lil thing though β€” actions that live in the "indices" or "cluster" namespace use the namespace as a prefix, like:

$defn = $e->api('indices.create');
$defn = $e->api('cluster.node_stats');

see? namespace first, dot, then the action. iykyk. 🌈


πŸ¦‹ SEE ALSO πŸ¦‹

  • Search::Elasticsearch::Role::API
  • Search::Elasticsearch::Client::7_0::Direct

go read those too, bestie, they're in the same friend group. πŸ“


πŸ‘‘ AUTHOR πŸ‘‘

Enrico Zimuel <enrico.zimuel@elastic.co>

shoutout to Enrico, we love a legend. ⭐


This software is Copyright (c) 2021 by Elasticsearch BV.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004

free software!! the Apache License, Version 2.0, January 2004 β€” periodt. πŸ’–


and that's the whole page, bestie. this one was written up against perl v5.32.1 on 2021-10-23, and yeah, it's filed under Search...le::API(3pm) in the User Contributed Perl Documentation corner of the world. mwah. πŸ’‹βœ¨

πŸ“¦ where this page comes from