All Projects → itemsapi → elasticbulk

itemsapi / elasticbulk

Licence: MIT license
Add data in bulk to elasticsearch. It supports data streaming from PostgreSQL or Filesystem

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to elasticbulk

http-emitter
📡 Emitting psr-7 responses.
Stars: ✭ 31 (+14.81%)
Mutual labels:  stream
grunt-css-import
Grunt task to concat css file by @import.
Stars: ✭ 13 (-51.85%)
Mutual labels:  import
mst-effect
💫 Designed to be used with MobX-State-Tree to create asynchronous actions using RxJS.
Stars: ✭ 19 (-29.63%)
Mutual labels:  stream
connect-backup
A tool to backup and restore AWS Connect, with some useful other utilities too
Stars: ✭ 19 (-29.63%)
Mutual labels:  import
format-imports-vscode
Format imports and exports for JavaScript and TypeScript in VS Code.
Stars: ✭ 60 (+122.22%)
Mutual labels:  import
FSDevTools
Project to support developer experience (DX) with FirstSpirit template development by offering a connection between a VCS like Git and FirstSpirit.
Stars: ✭ 29 (+7.41%)
Mutual labels:  import
blender-terrain
Terrain import is now a part of the blender-osm addon. Get it for free at https://gumroad.com/l/blender-osm
Stars: ✭ 28 (+3.7%)
Mutual labels:  import
sync-magento-2-migration
Release of rough proof of concept from 2018 that allows to import and export millions of products quickly
Stars: ✭ 51 (+88.89%)
Mutual labels:  import
SensorNode
SensorNode-client application for IOTA.
Stars: ✭ 35 (+29.63%)
Mutual labels:  stream
ember-cli-es6-transform
Import ES6 modules from npm, bower or anywhere else in your app.
Stars: ✭ 13 (-51.85%)
Mutual labels:  import
YOLO-Streaming
Push-pull streaming and Web display of YOLO series
Stars: ✭ 56 (+107.41%)
Mutual labels:  stream
lwt-pipe
[beta] A multi-consumer, multi-producers blocking queue and stream for Lwt
Stars: ✭ 30 (+11.11%)
Mutual labels:  stream
android-chat-tutorial
Sample apps for the Stream Chat Android SDK's official tutorial
Stars: ✭ 44 (+62.96%)
Mutual labels:  stream
ngx-stream-request-module
基于ngx-stream-module 实现长连接的处理,把长连接数据按照使用的协议转切分为请求(request),与后端服务器使用短连接通讯,完全兼容后端http协议。后端服务器使用推送协议可以很方便的把数据推送到客户端。
Stars: ✭ 15 (-44.44%)
Mutual labels:  stream
electron-download-manager
Manage downloadItems from Electron's BrowserWindows without user interaction, allowing single file download and bulk downloading
Stars: ✭ 113 (+318.52%)
Mutual labels:  bulk
rtsp-video-recorder
Provides an API to record RTSP video stream to filesystem.
Stars: ✭ 21 (-22.22%)
Mutual labels:  stream
ARF-Converter
Bulk ARF file converter
Stars: ✭ 15 (-44.44%)
Mutual labels:  bulk
tpack
Pack a Go workflow/function as a Unix-style pipeline command
Stars: ✭ 55 (+103.7%)
Mutual labels:  stream
blender-xray
STALKER (aka xray-engine) import/export plugin for Blender 3D
Stars: ✭ 132 (+388.89%)
Mutual labels:  import
justuse
Just use() code from anywhere - a functional import alternative with advanced features like inline version checks, autoreload, module globals injection before import and more.
Stars: ✭ 49 (+81.48%)
Mutual labels:  import

Elastic Bulk

Add data in bulk to ElasticSearch. It supports data streaming from PostgreSQL, MSSQL, MySQL, MariaDB, SQLite3, Filesystem and CSV

Start

npm install elasticbulk --save
const elasticbulk = require('elasticbulk');

Add JSON data to Elasticsearch

const elasticbulk = require('elasticbulk');
// some array data
var data = [];

elasticbulk.import(data, {
  index: 'movies',
  type: 'movies',
  host: 'http://localhost:9200'
})
.then(function(res) {
  console.log(res);
})

Add data to ItemsAPI from JSON file

The movies.json is a comma delimited json file.

const elasticbulk = require('elasticbulk');
const stream = fs.createReadStream('./movies.json')
.pipe(JSONStream.parse())

const config = {
  "sorting_fields": ["year", "rating", "votes", "reviews_count"],
  "aggregations": {
    "year": {
      "size": 10,
      "conjunction": true
    },
    "genres": {
      "size": 10,
      "conjunction": false
    },
    "tags": {
      "size": 10,
      "conjunction": true
    },
    "actors": {
      "size": 10,
      "conjunction": true
    },
    "country": {
      "size": 10,
      "conjunction": true
    }
  }
}

elasticbulk.import(stream, {
  engine: 'itemsapi',
  // api_key: '',
  index_name: 'movies',
  host: 'http://localhost:9200',
}, config)
.then(function(res) {
  console.log(res);
})

Add data to Meilisearch from JSON file

The movies.json is a comma delimited json file.

const elasticbulk = require('elasticbulk');
const stream = fs.createReadStream('./movies.json')
.pipe(JSONStream.parse())

const config = {
  rankingRules: [
    'typo',
  ],
  distinctAttribute: 'id',
  searchableAttributes: [
    'name'
  ],
  attributesForFaceting: [
    'director',
    'genres'
  ],
  displayedAttributes: [
    'name'
  ],
  stopWords: [
  ],
  synonyms: {
  }
}

elasticbulk.import(stream, {
  chunk_size: 1000,
  timeout: 6000,
  // intervalMs for check internal indexing status
  interval: 100,
  primary_key: 'id',
  engine: 'meilisearch',
  api_key: 'API_KEY',
  index_name: 'movies',
  host: 'http://localhost:9200',
}, config)
.then(function(res) {
  console.log(res);
})

Add data to Elasticsearch from JSON file

The movies.json is a comma delimited json file.

const elasticbulk = require('elasticbulk');
const stream = fs.createReadStream('./movies.json')
.pipe(JSONStream.parse())

elasticbulk.import(stream, {
  index: 'movies',
  type: 'movies',
  host: 'http://localhost:9200',
})
.then(function(res) {
  console.log(res);
})

Add data to Elasticsearch from CSV

You can also use ElasticBulk for importing data from CSV. It was tested for millions of records

const fs = require('fs');
const csv = require('fast-csv');
const elasticbulk = require('elasticbulk');

var stream = fs.createReadStream('questions.csv')
.pipe(csv({
  headers: true
}))
.transform(function(data){
  // you can transform your data here
  return data;
})

elasticbulk.import(stream, {
  index: 'questions',
  type: 'questions',
  host: 'http://localhost:9200'
})
.then(function(res) {
  console.log(res);
})

Add data to Elasticsearch from PostgreSQL

const Promise = require('bluebird');
const through2 = require('through2');
const db = require('knex');
const elasticbulk = require('elasticbulk');

var stream = db.select('*').from('movies')
.stream()
.pipe(through2({ objectMode: true, allowHalfOpen: false }, function (chunk, enc, cb) {
  cb(null, chunk)
}))

elasticbulk.import(stream, {
  index: 'movies',
  type: 'movies',
  host: 'localhost:9200',
})
.then(function(res) {
  console.log(res);
})

Add data to Elasticsearch from MongoDB

const elasticbulk = require('.elasticbulk');
const mongoose = require('mongoose');
const Promise = require('bluebird');
mongoose.connect('mongodb://localhost/your_database_name', {
  useMongoClient: true
});

mongoose.Promise = Promise;

var Page = mongoose.model('Page', new mongoose.Schema({
  title: String,
  categories: Array
}), 'your_collection_name');

// stream query 
var stream = Page.find({
}, {title: 1, _id: 0, categories: 1}).limit(1500000).skip(0).batchSize(500).stream();

elasticbulk.import(stream, {
  index: 'my_index_name',
  type: 'my_type_name',
  host: 'localhost:9200',
}, {
  title: {
    type: 'string'
  },
  categories: {
    type: 'string',
    index: 'not_analyzed'
  }
})
.then(function(res) {
  console.log('Importing finished');
})

Configuration

elasticbulk.import(data, {
  index: 'movies',
  // optional
  type: 'movies',
  // batch size 
  chunk_size: 500,
  debug: true,
  host: 'localhost:9200',
}, {
  // mapping
  name: {
    type: 'string'
  }
})
.then(function(res) {
  console.log(res);
})

Tests

# Test ES 1.7
docker run -it -d  -p 9200:9200 -p 9300:9300 -v $HOME/elasticsearch1.7/data:/data -v $HOME/elasticsearch1.7/logs:/logs barnybug/elasticsearch:1.7.2
mocha --exit -t 15000 tests/elasticitemsSpec.js

# Test ES 7.x
docker run -it -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.10.1
mocha --exit -t 15000 tests/elasticitems7xSpec.js
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].