New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

elastic-batch-file

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elastic-batch-file

Create Elasticsearch _bulk files from an array

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Elasticsearch _bulk File

The easiest way to get large amounts of data into an Elasticsearch index is by using the _bulk API.

This script creates _bulk-compatible files from regular JavaScript arrays.

Usage

const batch = require('elastic-batch-file')
const arr = [
  { id: 'hello', name: 'world' },
  { id: 'whats', name: 'up' }
]

batch(arr, 'indexname', 'out')

The file can be sent straight to Elasticsearch:

curl -s -H "Content-Type: application/x-ndjson" -u 'elastic:auth' "https://elastic-db:port/_bulk" --data-binary "@batch_indexname"; echo

Parameters

  • arr: Array of Objects. Each entry requires an "id" field
  • indexname: the name of the index for the bulk operation
  • outfile: which file to write in the current directory. Starts with batch_

Output

{"index":{"_index":"indexname","_type":"_doc","_id":"hello"}}
{"name":"world"}
{"index":{"_index":"indexname","_type":"_doc","_id":"whats"}}
{"name":"up"}

License

MIT © Patrick Heneise

Keywords

elasticsearch

FAQs

Package last updated on 27 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts