Skip to content
This repository was archived by the owner on Jan 6, 2022. It is now read-only.

miku/estab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

estab

Export elasticsearch document fields into tab separated values. estab uses the scan search type and the scroll API, which help

to retrieve large numbers of documents from Elasticsearch efficiently ...

Installation

$ go get github.com/miku/estab/cmd/estab

Or if your system speaks dpkg or rpm, there is a release.

Usage

$ estab -h
Usage of estab:
  -cpuprofile="": write cpu profile to file
  -delimiter="\t": column delimiter
  -f="_id _index": field or fields space separated
  -host="localhost": elasticsearch host
  -indices="": indices to search (or all)
  -limit=0: maximum number of docs to return (return all by default)
  -null="NOT_AVAILABLE": value for empty fields
  -port="9200": elasticsearch port
  -separator="|": separator to use for multiple field values
  -size=10000: scroll batch size
  -timeout="10m": scroll timeout
  -v=false: prints current program version

Example

Assuming an elasticsearch is running on localhost:9200.

$ curl -XPOST localhost:9200/test/default/ -d '{"name": "Tim", "color": "red"}'
$ curl -XPOST localhost:9200/test/default/ -d '{"name": "Alice", "color": "yellow"}'
$ curl -XPOST localhost:9200/test/default/ -d '{"name": "Brian", "color": "green"}'

$ estab -indices "test" -f "name color"
Brian   green
Tim     red
Alice   yellow

Specify multiple indices:

$ curl -XPOST localhost:9200/test2/default/ -d '{"name": "Yang", "color": "white"}'
$ curl -XPOST localhost:9200/test2/default/ -d '{"name": "Ying", "color": "black"}'

$ estab -indices "test test2" -f "name color"
Ying    black
Yang    white
Tim     red
Alice   yellow
Brian   green

Multiple values are packed into a single value:

$ curl -XPOST localhost:9200/test/default/ \
       -d '{"name": "Meltem", "color": ["green", "white"]}'

$ estab -indices "test" -f "name color"
Brian   green
Meltem  green|white
Tim     red
Alice   yellow

Missing values get a special value via -null, which defaults to NOT_AVAILABLE:

$ curl -XPOST localhost:9200/test/default/ -d '{"name": "Jin"}'

$ estab -indices "test" -f "name color"
Brian   green
Meltem  green|white
Tim     red
Alice   yellow
Jin     NOT_AVAILABLE

About

Export elasticsearch as TSV or line delimited JSON.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published