sqltoes
v0.1.4
Published
Convert SQL queries to Elasticsearch aggregations
Downloads
23
Readme
sqltoes (sql to ES)
Writing elasticsearch commands is hard, writing SQL queries is...less hard
Motivation: Elasticsearch commands are confusing to write at a certain point. See the Elasticsearch reference for more help.
Installation
npm install sqltoes
Use
sqlToES({select: ['sum(value)'], where: ['commodity = rice'], groupBy: ['description','year']})
How it works (and what works so far)
Looks for three properties: select
, where
, and groupBy
(currently requires them all)
- Anything in the
select
clause is ignored unless it is wrapped insum, min, max, or avg
all of which become a final aggregation - The
where
clause supports two types of queries:[field] = [value]
will be treated as a term filter.[field] in ([value1],value[2])
will be treated as a terms filter.
- Anything in the
groupBy
clause is treated like the second example shown here.