Low level query completion for Elasticsearch
This was built as part of an internal tool to autocomplete queries for Elasticsearch.
Getting Started
Install the module with: npm install elasticsearch-completion
// Create a completion classvar ElasticsearchCompletion = ;var esCompletion = 'name' 'location'; // Supply some queries to complete againstesCompletion; // ['name:', 'location:', '_exists_:', '_missing_:']esCompletion; // ['name:']esCompletion; // []esCompletion; // ['_exists_:name', '_exists_:location']
Documentation
elasticsearch-completion
exposes ElasticsearchCompletion
via its module.exports
.
new ElasticsearchCompletion(fields)
Constructor for a new completion class
- fields
Array
- Names of fields to match against (e.g.name
,location
)- For example,
['foo', 'bar']
would supply matches agains the fieldsfoo
andbar
- For example,
esCompletion.match(query)
Find matching completions for an Elasticsearch query
- query
String
- Query being used in Elasticsearch
Returns:
- matches
Array
- Collection of matching completions for the query- For example,
na
might complete to['name:']
and_ex
might complete to['_exists_:']
- For example,
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via npm run lint
and test via npm test
.
License
Copyright (c) 2015 Underdog.io
Licensed under the MIT license.