| name | elasticsearch-file-ingest |
| description | Ingest and transform data files (CSV/JSON/Parquet/Arrow IPC) into Elasticsearch with stream processing and custom transforms. Use when loading files or batch importing data.
|
| metadata | {"author":"elastic","version":"0.2.0","source":"elastic/agent-skills//skills/elasticsearch/elasticsearch-file-ingest"} |
Elasticsearch File Ingest
Stream-based ingestion and transformation of large data files (NDJSON, CSV, Parquet, Arrow IPC) into Elasticsearch.
Setup
Install dependencies and configure environment:
npm install
export ELASTICSEARCH_URL="https://elasticsearch:9200"
export ELASTICSEARCH_API_KEY="<your-api-key>"
Test connection:
node scripts/ingest.js test
Usage
Ingest a JSON file
node scripts/ingest.js ingest --file /path/to/data.json --target my-index
Ingest CSV
node scripts/ingest.js ingest --file /path/to/users.csv --source-format csv --target users
Ingest Parquet
node scripts/ingest.js ingest --file /path/to/users.parquet --source-format parquet --target users
Ingest with transformation
node scripts/ingest.js ingest --file /path/to/data.json --target my-index --transform transform.js
Infer mappings from CSV
node scripts/ingest.js ingest --file /path/to/users.csv --infer-mappings --target users
Command Reference
Required Options
--target <index>
Source Options (choose one)
--file <path>
--stdin
Index Configuration
--mappings <file.json>
--infer-mappings
--delete-index
--pipeline <name>
Processing
--transform <file.js>
--source-format <fmt>
--csv-options <file>
Transform Functions
export default function transform(doc) {
return {
...doc,
full_name: `${doc.first_name} ${doc.last_name}`,
timestamp: new Date().toISOString(),
};
}
Return null to skip a document. Return an array to split into multiple documents.
Guidelines
- Test first: Always run
node scripts/ingest.js test before ingesting.
- Never combine
--infer-mappings with --source-format.
- Use
--source-format csv with --mappings for known field types.
- Never echo, print, or log credential environment variables.