Skip to content

Instantly share code, notes, and snippets.

@gsf
Last active December 15, 2015 11:19
Show Gist options
  • Select an option

  • Save gsf/5252533 to your computer and use it in GitHub Desktop.

Select an option

Save gsf/5252533 to your computer and use it in GitHub Desktop.
node-elasticsearch notes

Calling elasticsearch() without an index would mean querying across all indexes, and anything requiring an index would result in an error.

Indexes can be specified at client creation elasticsearch({index: 'test'}) or in the opts of certain calls es.add({index: 'test'},...).

Maybe try putting an _indices array on the client instance to manage the affected indices for any operation (only one for certain operations like add). Then, a call like es.index('hex') would set _indices to ['hex'] and create the "hex" index if it doesn't exist. This also means es.index doesn't need its own constructor -- it's just a method on the client instance with attached sub-methods.

Move es.query() to es.search() -- with deprecation? And passed parameters should be (opts, req, cb).

##Steps

  1. Document current API
  2. Get "elasticsearch" npm namespace
  3. Propose API changes
  • es.query -> es.search
  • es.index, es.cluster, es.mapping, etc. as methods with sub-methods
  1. Convert all code from 4-space to 2-space indent
  2. Update tests with tape because it's maintained and could allow browser testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment