Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

seneca-elasticsearch

Package Overview
Dependencies
Maintainers
6
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seneca-elasticsearch

elasticsearch plugin for seneca

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
6
Weekly downloads
 
Created
Source

build status

elastic search plugin to seneca

This plugin will automatically index any entities that are being saved. Only entities will have their fields filtered by options.fields, the rest of the api assumes you know what you are doing.

Setup


var seneca = require('seneca')({
  strict: { // needed for seneca 0.6.4+
    add: false
  }
});

// important to use a store definition BEFORE including this module
// to automatically index entities
seneca.use('mem-store',{ map:{ '-/-/foo':'*' }});

seneca.use('seneca-elasticsearch', {
  fetchEntitiesFromDB: true, // only enable if you depend on this for permissions.
  refreshOnSave: true, // never enable this if your code needs to run in production.
  entities: [{
	name: 'foo',
	indexedAttributes: { // define mapping to be imported
	  someField: {
		type: 'string',
		index: 'not_analyzed'
	  }
	}
  }],

  connection: { index : indexName }, // customize index name
  pingTimeout: 1000
});

seneca.ready(function(err) {
    if (err) { return console.log(err); }

    // your code here.
    // It will have created the index for you automatically.

});

index management api

// check for index
seneca.act({role: 'search', cmd: 'create-index', index: 'myIndex'}, callback);

// create an index (checks first)
seneca.act({role: 'search', cmd: 'create-index', index: 'myIndex'}, callback);

// delete an index (checks first)
seneca.act({role: 'search', cmd: 'delete-index', index: 'myIndex'}, callback);

record management api

// index or update a record
seneca.act({
    role: 'search',
    cmd: 'save',
    index: 'myIndex',
    type: 'myType',
    id: 'myId', // requires either this id
    data: {
        _id: 'myId', // or this id
        /*  rest of object here */
    }
}, callback);

// remove a record
seneca.act({
    role: 'search',
    cmd: 'remove',
    index: 'myIndex',
    type: 'myType',
    id: 'myId'
}, callback);


// load a record
seneca.act({
    role: 'search',
    cmd: 'load',
    index: 'myIndex',
    type: 'myType',
    id: 'myId'
}, callback);

search api

// return all records
seneca.act({
    role: 'search',
    cmd: 'search',
    index: 'myIndex',
    type: 'myType'
}, callback);

// match lucene query string
seneca.act({
    role: 'search',
    cmd: 'search',
    index: 'myIndex',
    type: 'myType',
    search: "query string here",
    
}, callback);


// match elasticsearch JSON query

// TODO: 
// See tests/search.js for more about this.
// This is most likely what you will want
// to be using.

Keywords

FAQs

Package last updated on 29 Jul 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc