Produces ElasticSearch queries from UniQL ASTs.
  • JavaScript 100%
Find a file
2015-02-27 16:41:46 -08:00
src Support booleans and primitives. 2015-02-27 16:41:46 -08:00
.gitignore Initial commit. 2015-01-07 18:14:45 -08:00
.jsbeautifyrc Initial commit. 2015-01-07 18:14:45 -08:00
.jshintrc Initial commit. 2015-01-07 18:14:45 -08:00
LICENSE Initial commit. 2015-01-07 18:14:45 -08:00
package.json Support booleans and primitives. 2015-02-27 16:41:46 -08:00
README.md Remove debug and update README. 2015-01-07 18:19:37 -08:00

UniQL-ES

This generates ElasticSearch queries based on UniQL ASTs.

Example

var parse = require( 'uniql' );
var esCompile = require( 'uniql-es' );

var ast = parse( '( height <= 20 or ( favorites.color == "green" and height != 25 ) ) and firstname ~= "o.+"' );
var esQuery = esCompile( ast );
console.log( util.inspect( esQuery, { depth: null } ) );

Resulting query:

{ query: 
   { filtered: 
      { filter: 
         [ { bool: 
              { must: 
                 [ { bool: 
                      { should: 
                         [ { range: { height: { lte: 20 } } },
                           { bool: 
                              { must: 
                                 [ { term: { 'favorites.color': 'green' } },
                                   { bool: { must_not: { term: { height: 25 } } } } ] } } ] } },
                   { bool: { must: { regexp: { firstname: 'o.+' } } } } ] } } ] } } }

License

MIT