Skip to content

Josiah/gulp-elasticsearch-indexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM Version

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.

About

Gulp plugin which indexes JSON files to elastic search

Resources

License

Stars

Watchers

Forks

Packages

No packages published