2.0.0 • Published 9 years ago

elasticsearch-sanitize v2.0.0

Weekly downloads
1,258
License
MIT
Repository
github
Last release
9 years ago

node-elasticsearch-sanitize

Circle CI

npm install --save elasticsearch-sanitize

Accepts an arbitrary string as input and escapes the ElasticSearch reserved characters:

+ - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ / AND OR NOT space

Returns a sanitized string which can be safely used in an ElasticSearch query_string query.

Usage

To use pass in a string:

var myString = "AND there! are? (lots of) char*cters 2 ^escape!"
console.log(escapeElastic(myString))

And it will return:

\A\N\D\ there\!\ are\?\ \(lots\ of\)\ char\*cters\ 2\ \^escape\!