cles

command module
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 17 Imported by: 0

README

cles: CLI client for Elasticsearch

unittest status license

What is cles?

cles is a tool to manage Elasticsearch easily.

You can access Elasticsearch without complicated curl options.

Examples

An example project is available in the example directory

# A setting file is available.
# windows  : $APPDATA\cles\config.toml
# unix-like: $HOME/.config/cles/config.toml
$ cat ${HOME}/.config/cles/config.toml
[[profile]]
name = "default"
address = ["http://localhost:9200"]
username = ""
password = ""
sniff = false
$ cles -p default cat indices
health  status  index   uuid    pri     rep     docs.count      docs.deleted    store.size      pri.store.size
green   open    .geoip_databases        m0EVcoSZSAuGe7Mj5fB9tg  1       0       40      0       37.7mb  37.7mb
green   open    foo     IDKzsLa9Q2KCqN7soMoyLw  1       0       0       0       226b    226b

Installation

go get
go install github.com/t-chov/cles@latest

Commands

NAME:
   cles - Command line client for Elasticsearch

USAGE:
   cles [global options] command [command options] [arguments...]

VERSION:
   0.X.Y

COMMANDS:
   indices, i, index    operate indices
   cat, c               exec cat API
   search-template, st  operate search templates
   bulk, b              operate bulk API
   reindex, ri          execute reindex API
   help, h              Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --profile value, -p value  set profile name (default: "default")
   --debug                    show detail log (default: false)
   --help, -h                 show help (default: false)
   --version, -v              print the version (default: false)

indices (alias: i , index )

NAME:
   cles indices - operate indices

USAGE:
   cles indices command [command options] [arguments...]

COMMANDS:
   alias, a        manage alias
   create, c, new  create index
   delete, rm      delete index
   mapping, m      get mapping
   help, h         Shows a list of commands or help for one command

OPTIONS:
   --help, -h                 show help (default: false)

cat (alias: c)

NAME:
   cles cat - exec cat API

USAGE:
   cles cat command [command options] [arguments...]

COMMANDS:
   aliases, a  cat aliases
   indices, i  cat indices
   help, h     Shows a list of commands or help for one command

OPTIONS:
   --help, -h  show help (default: false)

search-template (alias: st)

NAME:
   cles search-template - operate search templates

USAGE:
   cles search-template command [command options] [arguments...]

COMMANDS:
   list, ls        list search template
   create, c, new  create search template
   delete, rm      delete search template
   render          render search template
   help, h         Shows a list of commands or help for one command

OPTIONS:
   --help, -h                 show help (default: false)

bulk (alias: b)

NAME:
   cles bulk - operate bulk API

USAGE:
   cles bulk command [command options] [arguments...]

COMMANDS:
   index, i  exec bulk index from ndjson
   help, h   Shows a list of commands or help for one command

OPTIONS:
   --help, -h  show help (default: false)
Bulk index

cles bulk index executes Bulk API

The file format of --source is different from the original format. You can use ndjson format, but you don't insert a command line.

wrong

{ "index" : { "_index" : "test", "_id" : "1" } } // don't add 
{ "field1" : "value1" }
{ "index" : { "_index" : "test", "_id" : "2" } } // don't add
{ "field1" : "value2" }

right

{ "field1" : "value1" }
{ "field1" : "value2" }

The example command is below.

$ cles bulk index --source /path/to/source.ndjson <INDEX_NAME>
Reindex

cles reindex executes Reindex API

First argument is source index, seconds argument is dest index.

NAME:
   cles reindex - execute reindex API

USAGE:
   cles reindex [command options] <SOURCE> <DEST>

OPTIONS:
   --help, -h  show help (default: false)

Environment variables

ES_ADDRESS This value is used as the address of Elasticsearch. You can use , as a separator.

ES_USERNAME This value is used as the user name for authentication of Elasticsearch.

ES_PASSWORD This value is used as the password for authentication of Elasticsearch.

ES_SNIFF If you set this value, the client will use sniffing.

FAQ

I have no active conneciton with single-node mode.

If you have this error message with single-node mode, you have to set ES_SNIFF to false.

initClient failure! cles: no active connection found: no Elasticsearch node available

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL