GithubHelp home page GithubHelp logo

ubleipzig / estab Goto Github PK

View Code? Open in Web Editor NEW

This project forked from miku/estab

0.0 4.0 0.0 4.56 MB

Export elasticsearch documents as TSV or line delimited JSON.

License: Other

Makefile 16.43% Go 70.61% Shell 12.96%

estab's Introduction

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:
  -1=false: one value per line (works only with a single column in -f)
  -cpuprofile="": write cpu profile to file
  -delimiter="\t": column delimiter
  -f="_id _index": field or fields space separated
  -header=false: output header row with field names
  -host="localhost": elasticsearch host
  -indices="": indices to search (or all)
  -limit=-1: maximum number of docs to return (return all by default)
  -null="NOT_AVAILABLE": value for empty fields
  -port="9200": elasticsearch port
  -precision=0: precision for numeric output
  -query="": custom query to run
  -raw=false: stream out the raw json records
  -separator="|": separator to use for multiple field values
  -size=10000: scroll batch size
  -timeout="10m": scroll timeout
  -v=false: prints current program version
  -zero-as-null=false: treat zero length strings as null values

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

In 0.2.0 a -raw flag was added that will stream out the full JSON documents:

$ estab -indices test -raw
{"_index":"test","_type":"default","_id":"...BvA4z","_score":0,"_source":{...}}
{"_index":"test","_type":"default","_id":"...BvA40","_score":0,"_source":{...}}
{"_index":"test","_type":"default","_id":"...BvA41","_score":0,"_source":{...}}

This can be fed into json processors like jq:

$ estab -indices test -raw | jq --raw-output '._source.color'
red
yellow
green

In 0.2.1 a -1 flag was added:

$ estab -indices "test" -f "color" -1
green
green
white
red
yellow
NOT_AVAILABLE

estab's People

Contributors

miku avatar

Watchers

 avatar James Cloos avatar Nico Toerl avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.