1.1.2 • Published 7 years ago
elasticsearch-query-to-json v1.1.2
elasticsearch-query-to-json
cli tool to fetch all documents from elasticsearch by query.
usage
$ elasticsearch-query-to-json -h "$ELASTIC_HOST" -i "$ELASTIC_INDEX" -b "$QUERY" -o output.json -f jsonPerRowavailable options
--host(-h) host eg. http://elasticsearch.co:9200--index(-i) index--body(-b) query body - some examples below--output(-o) output file - leave empty to write results to stdout--format(-f) - possible values:'json','jsonPerRow' - json means single array with elements, jsonPerRow means every record is encoded as json as put into separate line--scrollspecify how long a consistent view of the index should be maintained for scrolled search - default1m--size- number of hits to return at once - default1000--contentOnly- write only_source_field value
some examples of --body
- get all documents from yesterday based on
timestampfield'{"query":{"range":{"timestamp":{"gte":"now-1d/d","lt": "now/d"}}}}' get all documents with
ipfield equals "127.0.0.1"{"query":{"bool":{"must":[{"match_phrase":{"ip":{"query":"127.0.0.1"}}}]}}}