SQL interface for Elasticsearch
github.com
github.com
P.S.: I'm not affiliated with that company.
Its a lot easier to become familiar with a new SQL dialect than a new query language, especially since a lot of basic querying will be the same between different dialects.
This makes code you wrote in two different engines with the same syntax run vastly differently.
Only if you are writing basic queries is the ansi sql promise realized.
Sure, but simple queries, like the poster above provides as an example, have been standardized for like decades, and work the same across pretty much every credible RDBMS.
I've been working with ES for years now. the query language changes about twice per year, things which used to be the only way to do things become deprecated. (see: https://www.elastic.co/guide/en/elasticsearch/reference/curr... )
Even if you do understand 100% of the idiosyncrasies of elasticsearch, you still need to construct horrifically nested JSON to do meaningful queries... making it annoying to do in code, but mind wrenching to debug with curl.
Here's a good example:
https://www.elastic.co/guide/en/elasticsearch/guide/current/...
SQL:
SELECT document FROM products WHERE productID = "KDKE-B-9947-#kL5" OR (productID = "JODL-X-1937-#pV7" AND price=30)
ES Query: {
"query" : {
"filtered" : {
"filter" : {
"bool" : {
"should" : [
{ "term" : {"productID" : "KDKE-B-9947-#kL5"}},
{ "bool" : {
"must" : [
{ "term" : {"productID" : "JODL-X-1937-#pV7"}},
{ "term" : {"price" : 30}}
]
}}
]
}
}
}
}
}I wonder why you wouldn't use PrestoDB to connect to Elastic Search. It provides you with an SQL engine and you just need to write a connector that knows how to get data.
Similar thing has been done in Crate.io.
https://github.com/NLPchina/elasticsearch-sql/blob/5cd6ab639...
Edit: Actually the file you linked to was a test file. Hash join code is here [1], and it uses ES' scrolling feature to incrementally join, though it's not pipelined. Not sure scrolling is entirely appropriate for this; it will potentially hold an unpredictable amount of memory on the server end.
[1] https://github.com/NLPchina/elasticsearch-sql/blob/5cd6ab639...
It works very very well for full-table-scan analytics-type queries. I expect PrestoDB would be similar. But when it comes to queries about smaller and smaller pieces of the full dataset, it becomes less and less likely that these types of connectors perform well. Predicate pushdown is rarely well-implemented in these types of "run SQL against any big data" systems (Hive, Presto, Impala, SparkSQL, etc). A simple "select * where id = 1234" will often do a full scan and filter within the query engine, rather than push the point lookup into ES.