gulp-elasticsearch-indexer
v0.0.2
Published
Index json documents in Elastic Search with Gulp
Downloads
9
Readme
gulp-elasticsearch-indexer
Index json documents in Elastic Search with Gulp
Usage
Install
npm install --save-dev gulp-elasticsearch-indexer
Example
var gulp = require('gulp');
var gulpElasticSearchIndexer = require('gulp-elasticsearch-indexer');
gulp.task('fixtures', function () {
return gulp.src('data/**/*.json')
.pipe(gulpElasticSearchIndexer());
});
Connection configuration
Options are passed to the elastic search client so anything which adheres to the official documentation is supported. This includes the defaults specified in the official configuration.
var gulp = require('gulp');
var gulpElasticSearch = require('gulp-elasticsearch-indexer');
gulp.task('fixtures', function () {
return gulp.src('data/**/*.json')
.pipe(gulpElasticSearchIndexer());
});
// is the same as
gulp.task('fixtures', function () {
return gulp.src('data/**/*.json')
.pipe(gulpElasticSearchIndexer({host: 'http://localhost:9200'}));
});
Document indexing
The index, type and id of the document are determined from the file path automatically. The id is determined from the filename of the document (without the extension) then the type is the parent folder name and the index is the grandparent folder name.
**/{index}/{type}/{id}.json
These values can be overwritten by passing setting the index
, type
and id
options of the elastic search indexer.
var gulp = require('gulp');
var gulpElasticSearch = require('gulp-elasticsearch-indexer');
gulp.task('fixtures', function () {
return gulp.src('data/**/*.json')
.pipe(gulpElasticSearchIndexer({index: 'foo', type: 'bar', id: 'baz'}));
});
Additionally all supported options for client.index()
passed into the constructor will be used when indexing the document.