Movatterモバイル変換


[0]ホーム

URL:


packageelasticsearch-cli

  1. Overview
  2. Docs

You can search for identifiers within the package.

in-package search v0.2.0

Command-line client for Elasticsearch

Install

Dune Dependency

Authors

Maintainers

Sources

1.2.tar.gz
sha256=eaa0b90b2d06ba8d1e8a6c7fb85b292d924a0d26b71d9396e0b735a5929f1bb0
md5=bd0dd791fc3ba1b6f0ace0fba8161652

Description

Published:02 Oct 2020

README

elasticsearch-cli — Command-line client for Elasticsearch

This project provides a command line tool to query ElasticSearch clusters.

Installation

elasticsearch-cli can be installed withopam:

opam install elasticsearch-cli

Getting help

Show known commands

es --help

or just

es

Show man page for a command

es <command> --help

for example:

es search --help

Configuration file

The tool will look for a configuration file$XDG_HOME_CONFIG/es-cli/config.json when started ($XDG_HOME_CONFIG will be usually~/.config; seeXDG Base Directory Specification for more details).

Cluster aliases

It is possible to use alias names instead of full host names.

{  "clusters": {    "cluster1": {      "host": "http://cluster1.mydomain.com:9200"    },    "cluster2": {      "host": "http://cluster2.mydomain.com:9200",      "nodes": [        "master",        "data{0..9}",        "client{0..4}"      ]    }  }}

show health for cluster1.mydomain.com

es health cluster1

show health for all configured clusters

es health

search in cluster2.mydomain.com

es search cluster2 myindex

find missing nodes in cluster2

es nodes cluster2

Note this command relies on thenodes parameter in the configuration file.

Command aliases

{  "aliases": {    "pause": {      "command": "settings",      "args": [ "-p", "cluster.routing.allocation.enable=none" ]    },    "resume": {      "command": "settings",      "args": [ "-p", "cluster.routing.allocation.enable=all" ]    }  }}

Pause shard allocation

es pause cluster1

Resume shard allocation

es resume cluster1

Search documents

Search the indexmyindex for documents containing"Hello world!" in thetitle field. Return fieldsfield1 andfield2 of the document with the most recent value of theupdated_at field:

es search cluster1.mydomain.com:9200 myindex -i field1,field2 -s updated_at:desc -n 1 -q 'title:"Hello world!"'

Search the indexmyindex for documents containing12345 in thefield1 field. Return 10 documents' sources, omitting theboringfield field.

es search cluster1.mydomain.com:9200 myindex -e boringfield -n 10 -f source '{"query":{"term":{"field1":12345}}}'

Show the number of documents in the indexmyindex with fieldfield1 value greater or equal to 10:

es search cluster1.mydomain.com:9200 myindex -n 0 -c -q 'field1:>=10'

NOTE: ES 7.x and above will not return exact document count by default. Use-c -C true to print the exact value.

Count documents

Count documents containing"Hello world!" in thetitle field in the indexmyindex.

es count cluster1.mydomain.com:9200 myindex -q 'title:"Hello world!"'

Add or remove index alias

Add aliasalias1 tomyindex1 and aliasalias2 tomyindex2:

es alias cluster1.mydomain.com:9200 -a alias1=myindex1 -a alias2=myindex2

Remove aliasalias1 frommyindex1 and aliasalias2 frommyindex2:

es alias cluster1.mydomain.com:9200 -r alias1=myindex1 -r alias2=myindex2

Move index aliascurrent fromindex-3 toindex-4

es alias cluster1.mydomain.com:9200 -r current=index-3 -a current=index-4

Remove aliasalias1 and add aliasalias2 toindex.

es alias cluster1.mydomain.com:9200 index -r alias1 -a alias2

Get document(s) by id

es get cluster1.mydomain.com:9200 myindex docid

Multiget:

es get cluster1.mydomain.com:9200 myindex docid1 docid2 docid3

Put document with or without id

es put cluster1.mydomain.com:9200 myindex docid '{ "first_name": "John", "last_name": "Doe" }'
es put cluster1.mydomain.com:9200 myindex '{ "first_name": "Jane", "last_name": "Doe" }'
echo '{ "first_name": "Johnny", "last_name": "Doe" }' | es put cluster1.mydomain.com:9200 myindex docid2

Delete documents by id

es delete cluster1.mydomain.com:9200 myindex docid1 docid2

Refresh

es refresh cluster1.mydomain.com:9200 myindex1 myindex2

Flush

es flush cluster1.mydomain.com:9200 myindex1 myindex2

Use-f to force flush,-s to issue a synced flush, and-w to wait for an already ongoing flush.

Check health of multiple clusters

es health cluster1.mydomain.com:9200 cluster2.mydomain.com:9200

Check nodes of a cluster

Expect data0...data9, client0...client4 and master nodes to be present):

es nodes cluster1.mydomain.com:9200 -h data{0..9} master client{0..4}

Expect all nodes listed for clustermycluster in the configuration file to be present:

es nodes mycluster

Check shard recovery status

Display shards which are not inDONE stage:

es recovery cluster1.mydomain.com:9200 -e stage done

Get or set cluster setttings

List all persistent and transient settings:

es settings cluster1.mydomain.com:9200

List all settings, including default ones:

es settings cluster1.mydomain.com:9200 -D

Use-p,-t or-d to operate only on persistent, transient or default settings, respectively.

Update a persistent cluster setting:

es settings cluster1.mydomain.com:9200 -p cluster.routing.allocation.enable=none

Dependencies (10)

  1. re2>= "v0.9.0"
  2. lwt_ppx
  3. lwt>= "3.2.0"
  4. extlib>= "1.7.1"
  5. devkit>= "1.0"
  6. cmdliner
  7. atdgen>= "1.6.0" & < "2.3.0"
  8. mybuildbuild
  9. dune>= "1.5"
  10. ocaml>= "4.01.0"

Dev Dependencies

None

Used by

None

Conflicts

None


[8]ページ先頭

©2009-2025 Movatter.jp