2017 © Pedro Peláez
 

library es-query-sanitizer

Simple helper class to sanitize ElasticSearch reserved characters from query strings

image

sspat/es-query-sanitizer

Simple helper class to sanitize ElasticSearch reserved characters from query strings

  • Monday, January 22, 2018
  • by sspat
  • Repository
  • 1 Watchers
  • 0 Stars
  • 57 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 185 % Grown

The README.md

Simple helper class to sanitize ElasticSearch reserved characters from query strings

Inspired by node-elasticsearch-sanitize, (*1)

Author GitHub tag license, (*2)

Features

Accepts an arbitrary string as input and escapes the ElasticSearch reserved characters:, (*3)

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

Returns a sanitized string which can be safely used in an ElasticSearch query_string query., (*5)

Installation

The preferred way to install this extension is through composer., (*6)

Either run, (*7)

composer require sspat/es-query-sanitizer

or add, (*8)

"sspat/es-query-sanitizer": "~1.0"

to the require section of your composer.json file., (*9)

Usage

To use pass in a string:, (*10)

$unescapedQueryString = 'AND there! are? (lots of) char*cters 2 ^escape!'
$escapedQueryString = \sspat\ESQuerySanitizer\Sanitizer::escape($unescapedQueryString);

echo $escapedQueryString; // \A\N\D\ there\!\ are\?\ \(lots\ of\)\ char\*cters\ 2\ \^escape\!

You can also pass an array as the second argument, if you want to prevent some characters from being escaped:, (*11)

$unescapedQueryString = 'AND there! are? (lots of) char*cters 2 ^escape!'
$excludeCharacters = ['!', '^'];
$escapedQueryString = \sspat\ESQuerySanitizer\Sanitizer::escape($unescapedQueryString, $excludeCharacters);

echo $escapedQueryString; // \A\N\D\ there!\ are\?\ \(lots\ of\)\ char\*cters\ 2\ ^escape!

The Versions

22/01 2018

dev-master

9999999-dev

Simple helper class to sanitize ElasticSearch reserved characters from query strings

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Patrik Foldes

elasticsearch query sanitize escape

22/01 2018

1.0.2

1.0.2.0

Simple helper class to sanitize ElasticSearch reserved characters from query strings

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Patrik Foldes

elasticsearch query sanitize escape

22/01 2018

dev-develop

dev-develop

Simple helper class to sanitize ElasticSearch reserved characters from query strings

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Patrik Foldes

elasticsearch query sanitize escape

18/01 2018

1.0.0

1.0.0.0

Simple helper class to sanitize ElasticSearch reserved characters from query strings

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Patrik Foldes

elasticsearch query sanitize escape