0.2.7 • Published 8 years ago

es-dsl v0.2.7

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

UniQL-ES

This generates ElasticSearch queries based on UniQL ASTs.

支持query_string, 用like and not_like 标识

支持多个词查询,比如 color 在 red, green, 使用 color == "red,green", 其实正常应该用in来标示

Example

var parse     = require( '../src/index' ).parse;
var esCompile = require( '../src/index').compile;

var ast = parse( '( height <= 20 or ( favorites.color == "green" and height != 25 and text like "google" ) ) and (firstname ~= "o.+" or text like "baidu") and distr_pan nested "distr_pan.k == \'奔驰\' and distr_pan.v >= 0"' );
var esQuery = esCompile( ast );
console.log( util.inspect( esQuery, { depth: null } ) );

Resulting query:

{ query:
  { filtered:
    { filter:
      [ { bool:
        { must:
          [ { bool:
            { must:
              [ { bool:
                { should:
                  [ { range: { height: { lte: 20 } } },
                    { bool:
                      { must:
                        [ { bool:
                          { must:
                            [ { terms: { 'favorites.color': [ 'green' ] } },
                            { bool: { must_not: { terms: { height: [ 25 ] } } } } ] } },
                        { fquery:
                          { _cache: true,
query: { bool: { should: [ { query_string: { fields: [ 'text' ], query: '("google")' } } ] } } } } ] } } ] } },
                { bool:
                  { should:
                    [ { bool: { must: { regexp: { firstname: 'o.+' } } } },
                    { fquery:
                      { _cache: true,
query: { bool: { should: [ { query_string: { fields: [ 'text' ], query: '("baidu")' } } ] } } } } ] } } ] } },
            { nested:
              { path: 'distr_pan',
query:
                { bool:
                  { must:
                    [ { terms: { 'distr_pan.k': [ '奔驰' ] } },
                    { range: { 'distr_pan.v': { gte: 0 } } } ] } } } } ] } } ] } } }

License

MIT

0.2.7

8 years ago

0.2.7-beta

9 years ago

0.2.6-beta

9 years ago

0.2.6

9 years ago

0.2.5-beta

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago