# SQL to Lucene Query conversion

**URL:** <https://discuss.elastic.co/t/sql-to-lucene-query-conversion/11831>\
**Category:** Elasticsearch\
**Created:** [May 6, 2013, 11:12am UTC](https://discuss.elastic.co/t/sql-to-lucene-query-conversion/11831 "2013-05-06T11:12:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankit\_Jain](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@Ankit\_Jain](https://discuss.elastic.co/u/Ankit_Jain)\
**Post date:** [May 6, 2013, 11:12am UTC](https://discuss.elastic.co/t/sql-to-lucene-query-conversion/11831/1 "2013-05-06T11:12:50Z")

</div>

Hi All,

We are using Elastic Search, we want to expose our search service using SQL  
type inteface.

Is any tool are available, which can convert SQL into lucene?

For example:  
Input : select \* from tableName where id = 1 and pn=2

Output: lucene query

Thanks,  
Ankit Jain

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Jilles\_van\_Gurp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jilles_van_gurp/32/879_2.png) [@Jilles\_van\_Gurp](https://discuss.elastic.co/u/Jilles_van_Gurp)\
**Post date:** [May 6, 2013, 2:33pm UTC](https://discuss.elastic.co/t/sql-to-lucene-query-conversion/11831/2 "2013-05-06T14:33:27Z")

</div>

Not that I know. Probably not the best idea to want to do this to begin  
with. But you can sort of fake it for simple queries. The above query you  
could do with a filter query that filters on a boolean of two term queries.  
Or if you want to use the lucene query language syntax: "id:1 AND pn:2".  
However the way that works is actually kind of the way you set up your  
mappings and analyzers.

Things like joins get a lot more tricky and you probably end up doing  
things you shouldn't be doing if you go down that path (hint, doing many  
subqueries is going to be slow).

Jilles

On Monday, May 6, 2013 1:12:50 PM UTC+2, Ankit Jain wrote:

> Hi All,
> 
> We are using Elastic Search, we want to expose our search service using  
> SQL type inteface.
> 
> Is any tool are available, which can convert SQL into lucene?
> 
> For example:  
> Input : select \* from tableName where id = 1 and pn=2
> 
> Output: lucene query
> 
> Thanks,  
> Ankit Jain

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![martinspratt](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@martinspratt](https://discuss.elastic.co/u/martinspratt)\
**Post date:** [October 3, 2014, 1:45am UTC](https://discuss.elastic.co/t/sql-to-lucene-query-conversion/11831/3 "2014-10-03T01:45:13Z")

</div>

I have the same challenge, take a look at Apache Drill - [http://incubator.apache.org/drill/](http://incubator.apache.org/drill/) it appears to be able to query JSON docs natively, just need to invoke API to Elasticsearch.... happy to collaborate with you to get this working, it's sure to be popular.

---

<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, 12:58am UTC](https://discuss.elastic.co/t/sql-to-lucene-query-conversion/11831/4 "2017-07-06T00:58:30Z")

</div>


