elasql

1.0.4 • Public • Published

{ela}sql

Generic SQL to Elasticsearch DSL query translator. Designed for SENTINL

Status

  • Experimental - Join us hacking this!

Installation

npm install elasql

Usage

const convert = require('elasql').convert
convert('SELECT id,name FROM shop WHERE shop_id BETWEEN 5 AND 10 AND type = "cat"')
Output
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "type": "cat"
          }
        }
      ],
      "must_not": [],
      "filter": [
        {
          "range": {
            "shop_id": {
              "gte": {
                "type": "number",
                "value": 5
              },
              "lte": {
                "type": "number",
                "value": 10
              }
            }
          }
        }
      ]
    }
  },
  "aggregations": {
    "id": {
      "terms": {
        "field": "id"
      },
      "aggregations": {
        "name": {
          "terms": {
            "field": "name"
          }
        }
      }
    }
  }
}

License

(C) QXIP BV 2018, released under the MIT License

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.4
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.4
    0
  • 1.0.3
    24
  • 1.0.2
    0

Package Sidebar

Install

npm i elasql

Weekly Downloads

24

Version

1.0.4

License

MIT

Unpacked Size

7.2 kB

Total Files

5

Last publish

Collaborators

  • lmangani