# ODBC connection to ES

**URL:** https://discuss.elastic.co/t/odbc-connection-to-es/35731
**Category:** Elasticsearch
**Tags:** es-hadoop
**Created:** [November 27, 2015, 9:50am UTC](https://discuss.elastic.co/t/odbc-connection-to-es/35731 "2015-11-27T09:50:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![joris\_renkens](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@joris\_renkens](https://discuss.elastic.co/u/joris_renkens)
#### Post date: [November 27, 2015, 9:50am UTC](https://discuss.elastic.co/t/odbc-connection-to-es/35731/1 "2015-11-27T09:50:26Z")

</div>

Hi,

I'm trying to get an ODBC connection to ES which pushes down as much as possible to ES. I'm trying to use the spark-sql thrift-server and the es-hadoop spark-sql connection but I'm having a hard time getting it to work.

How crazy is this idea?  
Is it possible to get this to work?  
Are there better ways to get an ODBC connection to ES?

Thanks,  
Joris

---

<div class="post-metadata">

### Author: ![costin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/costin/32/44950_2.png) [@costin](https://discuss.elastic.co/u/costin)
#### Post date: [December 8, 2015, 1:50pm UTC](https://discuss.elastic.co/t/odbc-connection-to-es/35731/2 "2015-12-08T13:50:30Z")

</div>

There will be a lot of wrapping and multiple layers that each call to ES will have to go through.

ES doesn't offer any ODBC support per se so using something like Spark, would give you this. Does it work? In theory yes, in practice probably especially since thrift-server is involved.

---

<div class="post-metadata">

### Author: ![1111](https://avatars.discourse-cdn.com/v4/letter/1/71e660/32.png) [@1111](https://discuss.elastic.co/u/1111)
#### Post date: [December 22, 2015, 6:32am UTC](https://discuss.elastic.co/t/odbc-connection-to-es/35731/3 "2015-12-22T06:32:40Z")

</div>

Can you do an ODBC dirver for ES like MongoDB does.

It can me simple one: odbc driver take in query json request, and gives out json -\> table  
where fields of table are json fields with dots if nested

field1 | field2.nested1 | field2.nested2 | field3 etc

if field in document is empty it replaces with null in table

?

---

<div class="post-metadata">

### Author: ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)
#### Post date: [December 29, 2015, 8:22pm UTC](https://discuss.elastic.co/t/odbc-connection-to-es/35731/4 "2015-12-29T20:22:48Z")

</div>

I am using this with Tableau, I had to "flat" my data (remove nested JSON), then with Spark HiveThriftServer2 I can connect from Tableau. It's not crazy and very easy to setup.

But it can be a bit slow, because Spark has to fetch all data from ES via HTTP before processing the SQL query. Be sure that Spark workers are located close to ES nodes, also check "CACHE TABLE" from SparkSQL.

Another way is to export your ES data to a big JSON file, and load this file with Spark. This is the best way to play with, no nested JSON issue, just pleasure 😉

Don't forget to add the elastichsearch-hadoop JAR in the job class path, here how I am running the hive server:

```
/usr/local/spark/bin/spark-submit --class org.apache.spark.sql.hive.thriftserver.HiveThriftServer2 \
				   --driver-class-path /opt/jars/*
			           --master spark://localhost:7077

```

- elasticsearch-hadoop.jar is located in /opt/jars in my install.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 1:26pm UTC](https://discuss.elastic.co/t/odbc-connection-to-es/35731/5 "2017-07-06T13:26:47Z")

</div>


