🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

elasticsearch-sanitize

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elasticsearch-sanitize

Elastic Search String Sanitizer for Node

2.0.0
latest
Version published
Weekly downloads
3.9K
23.29%
Maintainers
1
Weekly downloads
 
Created

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\!

FAQs

Package last updated on 17 Nov 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