Namespaces
editNamespaces
editThe client has a number of "namespaces", which generally expose administrative functionality. The namespaces correspond to the various administrative endpoints in Elasticsearch. This is a complete list of namespaces:
Namespace | Functionality |
---|---|
|
Provide asyncronous search |
|
Autoscaling features |
|
Compact and aligned text (CAT), mainly for terminal |
|
Cross-cluster replication operations |
|
Cluster-centric stats and info |
|
Dangling indices management |
|
Enrich policy management |
|
Event Query Language |
|
Manage features provided by Elasticsearch and plugins |
|
Fleet’s use of Elasticsearch (experimental) |
|
Graph explore for documents and terms |
|
Index lifecycle management (ILM) |
|
Index-centric stats and info |
|
Ingest pipelines and processors |
|
License management |
|
Manage pipelines used by Logstash Central Management |
|
Designed for indirect use by Kibana’s Upgrade Assistant |
|
Machine learning features |
|
Monitoring features |
|
Monitoring features |
|
Node-centric stats and info |
|
Rollup features |
|
Searchable snapshots operations |
|
Security features |
|
Prepare nodes for temporary or permanent shutdown |
|
Snapshot lifecycle management (SLM) |
|
Methods to snapshot/restore your cluster and indices |
|
Run SQL queries on Elasticsearch indices and data streams |
|
SSL certificate management |
|
Task management |
|
Finds the structure of text |
|
Transform features |
|
Watcher create actions based on conditions |
|
Retrieves information about the installed X-Pack features |
Some methods are available in several different namespaces, which give you the
same information but grouped into different contexts. To see how these
namespaces work, let’s look at the _stats
output:
$client = ClientBuilder::create()->build(); // Index Stats // Corresponds to curl -XGET localhost:9200/_stats $response = $client->indices()->stats(); // Node Stats // Corresponds to curl -XGET localhost:9200/_nodes/stats $response = $client->nodes()->stats(); // Cluster Stats // Corresponds to curl -XGET localhost:9200/_cluster/stats $response = $client->cluster()->stats();
As you can see, the same stats()
call is made through three different
namespaces. Sometimes the methods require parameters. These parameters work
just like any other method in the library.
For example, we can requests index stats about a specific index, or multiple indices:
$client = ClientBuilder::create()->build(); // Corresponds to curl -XGET localhost:9200/my_index/_stats $params['index'] = 'my_index'; $response = $client->indices()->stats($params); // Corresponds to curl -XGET localhost:9200/my_index1,my_index2/_stats $params['index'] = ['my_index1', 'my_index2']; $response = $client->indices()->stats($params);
The following example shows how you can add an alias to an existing index:
$params['body'] = [ 'actions' => [ [ 'add' => [ 'index' => 'myindex', 'alias' => 'myalias' ] ] ] ]; $client->indices()->updateAliases($params);
Notice how both the stats
calls and the updateAliases
took a variety of
parameters, each according to what the particular API requires. The stats
API
only requires an index name(s), while the updateAliases
requires a body of
actions.