{"id":21567485,"url":"https://github.com/szajbus/elastic-cli","last_synced_at":"2025-07-06T18:37:59.872Z","repository":{"id":66275128,"uuid":"332095047","full_name":"szajbus/elastic-cli","owner":"szajbus","description":"The Missing Elasticsearch CLI","archived":false,"fork":false,"pushed_at":"2025-04-17T11:33:23.000Z","size":80,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-05T01:17:04.122Z","etag":null,"topics":["bash","cli","elasticsearch"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szajbus.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-01-23T00:32:19.000Z","updated_at":"2025-04-17T11:24:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"6642deed-3b05-4bfc-8ee7-42a42dbfb986","html_url":"https://github.com/szajbus/elastic-cli","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/szajbus/elastic-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szajbus%2Felastic-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szajbus%2Felastic-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szajbus%2Felastic-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szajbus%2Felastic-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szajbus","download_url":"https://codeload.github.com/szajbus/elastic-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szajbus%2Felastic-cli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263953101,"owners_count":23535041,"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":["bash","cli","elasticsearch"],"created_at":"2024-11-24T10:31:16.359Z","updated_at":"2025-07-06T18:37:59.867Z","avatar_url":"https://github.com/szajbus.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Missing Elasticsearch CLI\n\n![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/szajbus/elastic-cli?label=version\u0026sort=semver) ![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/szajbus/elastic-cli/build.yaml?branch=main)\n\n`elastic` is a command line utility for Elasticsearch.\n\nIt simplifies common operations by wrapping obscure `curl` commands with a friendly API.\n\n## Features\n\n- Index management\n- Alias management\n- Document management\n- Search and arbitrary requests\n- Multi-cluster support\n- Shell completions for commands, subcommands, index names, aliases, etc.\n\n## Installation\n\nMake sure you have [curl](https://curl.se) installed and available in `$PATH`.\n\nClone this repository:\n\n```shell\ngit clone https://github.com/szajbus/elastic-cli.git ~/.elastic-cli\n```\n\nAdd to your shell by adding the following to `~/.bashrc` or `~/.zshrc`:\n\n```shell\n. $HOME/.elastic-cli/elastic.sh\n```\n\nTo enable completions in ZSH add the following to `~/.zshrc`:\n\n```shell\n# append completions to fpath\nfpath=(${ELASTIC_DIR/completions} $fpath)\n# initialize completions\nautoload -Uz compinit\ncompinit\n```\n\nRestart your shell and voilà! 🎉\n\n## Usage\n\nHere are some basic examples, see the bottom of this file for the `elastic --help` printout.\n\nCreate an index:\n\n```shell\nelastic index create my-index '{\"mappings\": {...}, \"settings\": {...}}'\n```\n\nUpdate mapping of an existing index (add new fields):\n\n```shell\nelastic index update_mapping my-index '{\"properties\": {...}}'\n```\n\nRetrieve a document from an index:\n\n```shell\nelastic document get my-index doc-id\n```\n\n### Multi-cluster support\n\nBy default, all the requests are sent to `http://localhost:9200`, but you can specify an alternative cluster URL with `--cluster` option:\n\n```shell\nelastic --cluster https://username:password@my-cluster.eu-west-1.aws.found.io:9243 ...\nelastic --cluster $PROD_ELASTICSEARCH_URL ...\n```\n\nShell completions take the value of this option into account, so index and alias names suggestions will come from the specified cluster.\n\n### Sending data sourced from a file\n\nUnder the hood, `curl` is used, so whenever request body is required, it may be provided inline or sourced from a file.\n\n```shell\nelastic document index my-index '{\"field\": \"value\", ...}'\nelastic document index my-index \"@data.json\"\n```\n\n### Arbitrary requests\n\nFor use cases not directly supported by the tool's API, you can fall back to `elastic curl` command which automatically sets the cluster URL, HTTP method and `Content-Type: application/json` header for your requests.\n\nSee `elastic help curl` for more information.\n\n## The Full API\n\n```\nUsage:\n  elastic [--cluster \u003curl\u003e] [--verbose] [--dry-run] [--version] [--help]\n          \u003ccommand\u003e [\u003csubcommand\u003e] [\u003cargs\u003e]\n\nAvailable commands:\n\nIndex management\n  index list                              Lists all indices\n  index get \u003cindex\u003e                       Returns information about one or more indices\n  index create \u003cindex\u003e [\u003cbody\u003e]           Creates a new index\n  index delete \u003cindex\u003e                    Deletes an existing index\n  index open \u003cindex\u003e                      Opens a closed index\n  index close \u003cindex\u003e                     Closes an index\n\nMapping management\n  index get_mapping [\u003cindex\u003e]             Retrieves mapping definitions for one or more fields\n  index update_mapping \u003cindex\u003e \u003cbody\u003e     Adds new fields to an existing index\n\nIndex settings\n  index get_settings \u003cindex\u003e [\u003csetting\u003e]  Returns setting information for one or more indices\n  index update_settings \u003cindex\u003e \u003cbody\u003e    Changes a dynamic index settings in real time\n\nIndex status management\n  index clear_cache [\u003cindex\u003e]             Clears the caches of one or more indices\n  index refresh [\u003cindex\u003e]                 Refreshes one or more indices\n  index flush [\u003cindex\u003e]                   Flushes one or more indices\n  index forcemerge [\u003cindex\u003e]              Forces a merge on the shards of one or more indices\n\nAlias management\n  alias list                              Lists all index aliases\n  alias get [\u003calias\u003e]                     Returns information about one or more index aliases\n  alias add \u003calias\u003e \u003cindex\u003e [\u003cbody\u003e]      Creates or updates an index alias\n  alias delete \u003calias\u003e \u003cindex\u003e            Deletes an existing index alias\n  alias switch \u003calias\u003e \u003cfrom\u003e \u003cto\u003e        Moves an alias from one index to another\n\nSingle document APIs\n  document get \u003cindex\u003e \u003cid\u003e               Retrieves the specified JSON document from an index\n  document delete \u003cindex\u003e \u003cid\u003e            Removes a JSON document from the specified index\n  document index \u003cindex\u003e \u003cbody\u003e           Creates new document in an index with auto-generated id\n  document insert \u003cindex\u003e \u003cid\u003e \u003cbody\u003e     Creates new document in an index\n  document upsert \u003cindex\u003e \u003cid\u003e \u003cbody\u003e     Creates new or replaces exising document in an index\n  document update \u003cindex\u003e \u003cid\u003e \u003cbody\u003e     Updates existing document in an index\n\nMulti-document APIs\n  document mget \u003cindex\u003e \u003cid\u003e [\u003cids\u003e...]   Retrieves multiple JSON documents by ID\n  document reindex \u003csource\u003e \u003cdest\u003e        Copies documents from a source to a destination in the same cluster\n\nSearch API\n  search \u003cindex\u003e [\u003cbody\u003e]                 Returns search hits that match the query defined in the request\n\nCount API\n  count \u003cindex\u003e [\u003cbody\u003e]                  Counts the documents matching the query defined in the request\n\nCluster info\n  info                                    Show cluster info, equivalent to \\`curl get /\\`\n\nArbitrary HTTP requests\n  curl get \u003cpath\u003e [\u003ccurl args\u003e]           Makes arbitrary GET request\n  curl post \u003cpath\u003e [\u003ccurl args\u003e]          Makes arbitrary POST request\n  curl put \u003cpath\u003e [\u003ccurl args\u003e]           Makes arbitrary PUT request\n  curl delete \u003cpath\u003e [\u003ccurl args\u003e]        Makes arbitrary DELETE request\n\nApplication options:\n  -c, --cluster   Specify Elasticsearch cluster URL, http://localhost:9200 is default\n  -v, --verbose   Prints out all curl commands to stderr\n  -n, --dry-run   Only prints out all curl commands to stderr, without running them\n\nHelp options:\n  -h, --help      Shows this message\n  -V, --version   Shows version number\n\nSee 'elastic help \u003ccommand\u003e' for command usage examples.\n```\n\n## Roadmap\n\nApart from functionality extensions (new APIs), there are some extras that would be nice to have.\n\n- Distribution via Homebrew\n- Installation instructions for other shells (fish, ksh)\n- Shell completions for bash\n- Support for older Elasticsearch versions (\u003c 7)\n- AWS Elasticsearch support\n\n## Development\n\nIn order to run tests locally, install [bats](https://github.com/sstephenson/bats) and [jq](https://stedolan.github.io/jq/) and run:\n\n```shell\nbats test\n```\n\n## Contributing\n\nYou are very welcome to help!\n\n- Report a bug or raise a feature request via [Github Issues](https://github.com/szajbus/elastic-cli/issues)\n- Fork this repository and submit your changes via [Github Pull Requests](https://github.com/szajbus/elastic-cli/pulls)\n\n## License\n\nCopyright (c) 2021 Michał Szajbe\n\nLicensed under [The MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszajbus%2Felastic-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszajbus%2Felastic-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszajbus%2Felastic-cli/lists"}