{"id":14008205,"url":"https://github.com/marclop/elasticsearch-cli","last_synced_at":"2025-04-05T10:31:15.152Z","repository":{"id":57486489,"uuid":"82699853","full_name":"marclop/elasticsearch-cli","owner":"marclop","description":"Provides a REPL console-like interface to interact with Elasticsearch","archived":false,"fork":false,"pushed_at":"2019-02-12T13:39:25.000Z","size":5970,"stargazers_count":17,"open_issues_count":1,"forks_count":0,"subscribers_count":56,"default_branch":"master","last_synced_at":"2025-03-21T03:06:12.726Z","etag":null,"topics":["cli","console","elasticsearch","elasticsearch-cli","go","golang","repl"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marclop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-21T16:08:05.000Z","updated_at":"2024-01-24T07:03:15.000Z","dependencies_parsed_at":"2022-09-01T21:02:26.841Z","dependency_job_id":null,"html_url":"https://github.com/marclop/elasticsearch-cli","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marclop%2Felasticsearch-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marclop%2Felasticsearch-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marclop%2Felasticsearch-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marclop%2Felasticsearch-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marclop","download_url":"https://codeload.github.com/marclop/elasticsearch-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247324643,"owners_count":20920690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","console","elasticsearch","elasticsearch-cli","go","golang","repl"],"created_at":"2024-08-10T11:01:24.959Z","updated_at":"2025-04-05T10:31:14.650Z","avatar_url":"https://github.com/marclop.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/marclop/elasticsearch-cli.svg?branch=master)](https://travis-ci.org/marclop/elasticsearch-cli) [![Go Report Card](https://goreportcard.com/badge/github.com/marclop/elasticsearch-cli)](https://goreportcard.com/report/github.com/marclop/elasticsearch-cli) [![codecov](https://codecov.io/gh/marclop/elasticsearch-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/marclop/elasticsearch-cli)\n\n# Elasticsearch-cli\n\n`elasticsearch-cli` provides a Kibana console-like interface to interact with ElasticSearch\n\n## Features\n\n* Cli interface, this is a one-off execution\n* Interactive console-like execution\n* REPL autocompletion\n* Persistent history\n* Authentication support\n\n## Installation\n\nTo install `elasticsearch-cli` you can either grab the latest binaries in the [release page](https://github.com/marclop/elasticsearch-cli/releases)\nor install the latest and most recent commit from the source code\n\n### Latest build\n\n`elasticsearch-cli` will be placed in ${GOPATH}/bin/elasticsearch-cli\n\n```sh\ngit clone https://github.com/marclop/elasticsearch-cli\ncd elasticsearch-cli\nmake install\n```\n\n## Default configuration\n\nThere are a few configuration flags you can pass to `elasticsearch-cli`:\n\n```console\n$ elasticsearch-cli --help\nelasticsearch-cli provides a REPL console-like interface to interact with Elasticsearch\n\nUsage:\n  elasticsearch-cli [flags]\n  elasticsearch-cli [command]\n\nAvailable Commands:\n  delete      Performs a DELETE operation against the remote endpoint\n  get         Performs a GET operation against the remote endpoint\n  head        Performs a HEAD operation against the remote endpoint\n  help        Help about any command\n  post        Performs a POST operation against the remote endpoint\n  put         Performs a PUT operation against the remote endpoint\n  version     prints the version\n\nFlags:\n      --cluster string      config name, used to have multiple clusters configured in $HOME/.elasticsearch-cli/\u003cenv\u003e (default \"default\")\n  -h, --help                help for elasticsearch-cli\n      --host string         default elasticsearch URL (default \"http://localhost\")\n  -p, --pass string         password to use to authenticate (If not specified, will look for ES_PASS environment variable)\n      --poll-interval int   interval on which to poll Elasticsearch to provide index autocompletion (default 10)\n      --port int            default elasticsearch port to use (default 9200)\n  -t, --timeout int         http client timeout to the remote endpoint (default 10)\n  -u, --user string         username to use to authenticate (If not specified look for ES_USER environment variable)\n  -v, --verbose             enable verbose mode\n\nUse \"elasticsearch-cli [command] --help\" for more information about a command.\n```\n\n## Configuration Settings and Precedence\n\nIn order for `elasticsearch-cli` to be able to comunicate with an Elasticsearch cluster, it needs to have a set of configuration parameters set, which could either be defined in a configuration file, using environment variables or at runtime or using the cli's global flags. The hirearchy is as follows listed from higher precedence to lower:\n\n1. Command line flags (`--host`, `--user`, `--pass`, `--verbose`, etc).\n2. Environment variables.\n3. Shared configuration file (`$HOME/.elasticsearch-cli/default.\u003cjson|toml|yaml|hcl\u003e`).\n\n\n## Configuration variables\n\nBefore you can start calling your Elasticsearch from the binary, you will need to configure it. Here's an example `YAML` configuration file (`$HOME/.elasticsearch-cli/default.yaml`) that will effectively point and configure the binary for Elastic Cloud:\n\n```yaml\nhost: https://9a980720ff16d55e3507bfc875551626.us-east-1.aws.found.io:9243\nregion: us-east-1\nuser: marc\npass: mypass\n```\n\nYou could also specify the same settings using environment variables, or to override some settings of the `YAML` file, to do you'll need to prefix the configuration parameter with `ES_` and capitalize the setting, i.e. `ES_HOST` or `ES_USER`.\n\n```sh\nexport ES_CONFIG=mycluster\n```\n\nLast but not least, you can override any of the settings using the CLI flags.\n\n```sh\nelasticsearch-cli --config mycluster \u003cCOMMAND\u003e\n```\n\n## Multple configuration support\n\n`elasticsearch-cli` supports the notion of having multiple cluster configuration files out of the box. It uses those to manage credentials and settings.\nBy default it will use `$HOME/.elasticsearch-cli/default.\u003cjson|toml|yaml|hcl\u003e`, but when the `--config` flag is specified, it will use the `--config` specified value as the file name inside `$HOME/.elasticsearch-cli`:\n\n```console\n# Default behaviour\n$ elasticsearch-cli version\nUsing config file: /Users/marc/.elasticsearch-cli/default.yaml\n[...]\n\n# when an environment is specified, the configuration file used will change\n$ elasticsearch-cli version --config cluster\nUsing config file: /Users/marc/.elasticsearch-cli/cluster.yaml\n[...]\n```\n\n# Usage\n\n`elasticsearch-cli`'s usage is very intuitive, the execution is split between non-interactive and interactive, which is composed by 3 request arguments:\n\n1. Method\n2. URL\n3. Body\n\nNon-interactive example:\n\n```sh\n$ elasticsearch-cli GET /\n{\n  \"name\": \"GNBXbv5\",\n  \"cluster_name\": \"elasticsearch\",\n  \"cluster_uuid\": \"g5swow-2SHaCA6zPVvf1dQ\",\n  \"version\": {\n    \"number\": \"5.2.1\",\n    \"build_hash\": \"db0d481\",\n    \"build_date\": \"2017-02-09T22:05:32.386Z\",\n    \"build_snapshot\": false,\n    \"lucene_version\": \"6.4.1\"\n  },\n  \"tagline\": \"You Know, for Search\"\n}\n$ elasticsearch-cli -verbose GET\nMethod:       GET\nURL:          /\nResponse:     200 OK\nContent-Type: application/json\n\n{\n  \"name\": \"GNBXbv5\",\n  \"cluster_name\": \"elasticsearch\",\n  \"cluster_uuid\": \"g5swow-2SHaCA6zPVvf1dQ\",\n  \"version\": {\n    \"number\": \"5.2.1\",\n    \"build_hash\": \"db0d481\",\n    \"build_date\": \"2017-02-09T22:05:32.386Z\",\n    \"build_snapshot\": false,\n    \"lucene_version\": \"6.4.1\"\n  },\n  \"tagline\": \"You Know, for Search\"\n}\n$ elasticsearch-cli GET _cat\n=^.^=\n/_cat/pending_tasks\n/_cat/repositories\n/_cat/segments\n/_cat/segments/{index}\n/_cat/health\n/_cat/nodes\n/_cat/allocation\n/_cat/indices\n/_cat/indices/{index}\n/_cat/aliases\n/_cat/aliases/{alias}\n/_cat/templates\n/_cat/plugins\n/_cat/count\n/_cat/count/{index}\n/_cat/tasks\n/_cat/nodeattrs\n/_cat/thread_pool\n/_cat/thread_pool/{thread_pools}/_cat/master\n/_cat/fielddata\n/_cat/fielddata/{fields}\n/_cat/snapshots/{repository}\n/_cat/recovery\n/_cat/recovery/{index}\n/_cat/shards\n/_cat/shards/{index}\n```\n\n## Interactive mode\n\n```sh\n$ elasticsearch-cli -verbose\nelasticsearch\u003e GET\nMethod:       GET\nURL:          /\nResponse:     200 OK\nContent-Type: application/json\n\n{\n  \"name\": \"GNBXbv5\",\n  \"cluster_name\": \"elasticsearch\",\n  \"cluster_uuid\": \"g5swow-2SHaCA6zPVvf1dQ\",\n  \"version\": {\n    \"number\": \"5.2.1\",\n    \"build_hash\": \"db0d481\",\n    \"build_date\": \"2017-02-09T22:05:32.386Z\",\n    \"build_snapshot\": false,\n    \"lucene_version\": \"6.4.1\"\n  },\n  \"tagline\": \"You Know, for Search\"\n}\nelasticsearch\u003e exit\n$ elasticsearch-cli\nelasticsearch\u003e GET\nMethod:       GET\nURL:          /\n\n{\n  \"name\": \"GNBXbv5\",\n  \"cluster_name\": \"elasticsearch\",\n  \"cluster_uuid\": \"g5swow-2SHaCA6zPVvf1dQ\",\n  \"version\": {\n    \"number\": \"5.2.1\",\n    \"build_hash\": \"db0d481\",\n    \"build_date\": \"2017-02-09T22:05:32.386Z\",\n    \"build_snapshot\": false,\n    \"lucene_version\": \"6.4.1\"\n  },\n  \"tagline\": \"You Know, for Search\"\n}\nelasticsearch\u003e exit\n```\n\n### Change configuration\n\nWhile in interactive mode you an choose to change the application's configuration at any time:\n\n```sh\n$ elasticsearch-cli\nelasticsearch\u003e get\nMethod:       GET\nURL:          /\n\n{\n  \"name\": \"GNBXbv5\",\n  \"cluster_name\": \"elasticsearch\",\n  \"cluster_uuid\": \"g5swow-2SHaCA6zPVvf1dQ\",\n  \"version\": {\n    \"number\": \"5.2.1\",\n    \"build_hash\": \"db0d481\",\n    \"build_date\": \"2017-02-09T22:05:32.386Z\",\n    \"build_snapshot\": false,\n    \"lucene_version\": \"6.4.1\"\n  },\n  \"tagline\": \"You Know, for Search\"\n}\nelasticsearch\u003e set port 9201\nelasticsearch\u003e get\nMethod:       GET\nURL:          /\n\n{\n  \"name\": \"hIzXUZY\",\n  \"cluster_name\": \"elasticsearch\",\n  \"cluster_uuid\": \"g5swow-2SHaCA6zPVvf1dQ\",\n  \"version\": {\n    \"number\": \"5.2.1\",\n    \"build_hash\": \"db0d481\",\n    \"build_date\": \"2017-02-09T22:05:32.386Z\",\n    \"build_snapshot\": false,\n    \"lucene_version\": \"6.4.1\"\n  },\n  \"tagline\": \"You Know, for Search\"\n}\nelasticsearch\u003e exit\n```\n\n## Usage with jq\n\nOf course if you feel like combining the power of Elasticsearch with `jq` for response filtering you can do so.\n\n```sh\n$ elasticsearch-cli GET | jq '.version.number'\n\"5.2.1\"\n$ elasticsearch-cli GET | jq '.name'\n\"GNBXbv5\"\n$ elasticsearch-cli -port 9201 GET | jq '.name'\n\"hIzXUZY\"\n```\n\n# Contributing\n\n## Setting up the environment\n\nElasticsearch-cli is written in [Go](http://golang.org/), so you'll need the latest version of Golang if you want to contribute.\nYou will also need the latest version of Docker to be able to run the acceptance tests.\n\n## Running all the tests\n\nIssuing `make test` will run the combination of `unit` and `acceptance` tests. If you want a specific test, just use either target.\n\n```sh\n$ make test\n-\u003e Running unit tests for elasticsearch-cli...\nok  \tgithub.com/marclop/elasticsearch-cli/app\t0.010s\tcoverage: 33.3% of statements\nok  \tgithub.com/marclop/elasticsearch-cli/cli\t0.015s\tcoverage: 63.9% of statements\nok  \tgithub.com/marclop/elasticsearch-cli/client\t0.027s\tcoverage: 83.3% of statements\n?   \tgithub.com/marclop/elasticsearch-cli/elasticsearch\t[no test files]\nok  \tgithub.com/marclop/elasticsearch-cli/poller\t0.008s\tcoverage: 81.5% of statements\nok  \tgithub.com/marclop/elasticsearch-cli/utils\t0.006s\tcoverage: 100.0% of statements\n?   \tgithub.com/marclop/elasticsearch-cli\t[no test files]\n-\u003e Installing elasticsearch-cli dependencies...\n[..]\n-\u003e Building elasticsearch-cli...\nNumber of parallel builds: 7\n\n--\u003e    darwin/amd64: github.com/marclop/elasticsearch-cli\n=\u003e Starting Elasticsearch 1.7... Done.\n-\u003e Running acceptance tests for elasticsearch-cli in Elasticsearch 1.7...\nok  \tgithub.com/marclop/elasticsearch-cli\t1.276s\n-\u003e Killing Docker container elasticsearch-cli_es_1.7\n=\u003e Starting Elasticsearch 2.4... Done.\n-\u003e Running acceptance tests for elasticsearch-cli in Elasticsearch 2.4...\nok  \tgithub.com/marclop/elasticsearch-cli\t1.421s\n-\u003e Killing Docker container elasticsearch-cli_es_2.4\n=\u003e Starting Elasticsearch 5.4... Done.\n-\u003e Running acceptance tests for elasticsearch-cli in Elasticsearch 5.4...\nok  \tgithub.com/marclop/elasticsearch-cli\t3.566s\n-\u003e Killing Docker container elasticsearch-cli_es_5.4\n```\n\n### SEE ALSO\n* [elasticsearch-cli docs](./docs/elasticsearch-cli.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarclop%2Felasticsearch-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarclop%2Felasticsearch-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarclop%2Felasticsearch-cli/lists"}