A Clojure library designed to convert SQL statements into Elasticsearch requests
Add to project.clj:
[org.clojars.punit-naik/sqles "0.1.0"]
(require '[org.clojars.punit-naik.sqles.parse-sql :as sql])
(sql/parse-query "select * from my-index")
;; => {:url "http://localhost:9200/my-index/_search"
;; :body {:query {:match_all {}}}
;; :method :post}
(sql/parse-query "select name, age from users where age >= 21 order by age desc limit 10")
The Elasticsearch server settings are read from:
:confSupported settings:
ES_PROTOCOL (default: http)ES_HOSTNAME (required)ES_PORT (required)ES_USERNAME (optional)ES_PASSWORD (optional)If the server is not reachable, parse-query will throw.
SELECT fields or *FROMWHERE with operators: =, !=, <>, <, <=, >, >=, IN, BETWEENLIMITORDER BY with asc or descCOUNT(*)WHERE precedence does not follow SQL operator precedencelein test
You can run the parser and query runner via -main:
lein run "select * from my-index limit 5"
Copyright © 2021 Punit Naik
This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |