Skip to content

honeinc/uniql-es

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Produces ElasticSearch queries from UniQL ASTs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published