# Lucene query parser to ES Java API

**URL:** <https://discuss.elastic.co/t/lucene-query-parser-to-es-java-api/16305>\
**Category:** Elasticsearch\
**Created:** [March 11, 2014, 11:45pm UTC](https://discuss.elastic.co/t/lucene-query-parser-to-es-java-api/16305 "2014-03-11T23:45:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [March 11, 2014, 11:45pm UTC](https://discuss.elastic.co/t/lucene-query-parser-to-es-java-api/16305/1 "2014-03-11T23:45:57Z")

</div>

Is there a utility that can convert lucene query string format to ES Java  
API format? We are planning to use lucene query parser to validate query  
string entered by user in our application before creating a request to ES.

[http://lucene.apache.org/core/2\_9\_4/queryparsersyntax.html](http://lucene.apache.org/core/2_9_4/queryparsersyntax.html)

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [March 12, 2014, 12:53am UTC](https://discuss.elastic.co/t/lucene-query-parser-to-es-java-api/16305/2 "2014-03-12T00:53:00Z")

</div>

Not sure if much has changed since I asked a similar question a while back:

[https://groups.google.com/forum/#!msg/elasticsearch/f4hE3lHsJeA/u0ovOO91Vr4J](https://groups.google.com/forum/#!msg/elasticsearch/f4hE3lHsJeA/u0ovOO91Vr4J)

Jorg's suggestion at the very end if perhaps the best, although I have  
continued using my own method.

[https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java)

--  
Ivan

On Tue, Mar 11, 2014 at 4:45 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:

> Is there a utility that can convert lucene query string format to ES Java  
> API format? We are planning to use lucene query parser to validate query  
> string entered by user in our application before creating a request to ES.
> 
> [Apache Lucene - Query Parser Syntax](http://lucene.apache.org/core/2_9_4/queryparsersyntax.html)
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 12, 2014, 10:36am UTC](https://discuss.elastic.co/t/lucene-query-parser-to-es-java-api/16305/3 "2014-03-12T10:36:32Z")

</div>

You may want to look at using the simple query string query instead:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

It has the benefit of not throwing syntax errors, but trying to do the  
right thing.

On 12 March 2014 01:53, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:

> Not sure if much has changed since I asked a similar question a while back:
> 
> [Redirecting to Google Groups](https://groups.google.com/forum/#!msg/elasticsearch/f4hE3lHsJeA/u0ovOO91Vr4J)
> 
> Jorg's suggestion at the very end if perhaps the best, although I have  
> continued using my own method.
> 
> [https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java)
> 
> --  
> Ivan
> 
> On Tue, Mar 11, 2014 at 4:45 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:
> 
> > Is there a utility that can convert lucene query string format to ES Java  
> > API format? We are planning to use lucene query parser to validate query  
> > string entered by user in our application before creating a request to ES.
> > 
> > [Apache Lucene - Query Parser Syntax](http://lucene.apache.org/core/2_9_4/queryparsersyntax.html)
> > 
> > --  
> > 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).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [March 12, 2014, 5:25pm UTC](https://discuss.elastic.co/t/lucene-query-parser-to-es-java-api/16305/4 "2014-03-12T17:25:11Z")

</div>

Yeah, don't try to wrap the query\_string in piles of regexes to make sure  
it never throws errors and blocks features you don't want but lets through  
features you do. It isn't fun.

On Wed, Mar 12, 2014 at 6:36 AM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:

> You may want to look at using the simple query string query instead:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html)
> 
> It has the benefit of not throwing syntax errors, but trying to do the  
> right thing.
> 
> On 12 March 2014 01:53, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:
> 
> > Not sure if much has changed since I asked a similar question a while  
> > back:
> > 
> > [Redirecting to Google Groups](https://groups.google.com/forum/#!msg/elasticsearch/f4hE3lHsJeA/u0ovOO91Vr4J)
> > 
> > Jorg's suggestion at the very end if perhaps the best, although I have  
> > continued using my own method.
> > 
> > [https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java)
> > 
> > --  
> > Ivan
> > 
> > On Tue, Mar 11, 2014 at 4:45 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:
> > 
> > > Is there a utility that can convert lucene query string format to ES  
> > > Java API format? We are planning to use lucene query parser to validate  
> > > query string entered by user in our application before creating a request  
> > > to ES.
> > > 
> > > [Apache Lucene - Query Parser Syntax](http://lucene.apache.org/core/2_9_4/queryparsersyntax.html)
> > > 
> > > --  
> > > 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).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > 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).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [March 12, 2014, 8:05pm UTC](https://discuss.elastic.co/t/lucene-query-parser-to-es-java-api/16305/5 "2014-03-12T20:05:42Z")

</div>

So suggestion is to just use java api simple query string object which I  
presume uses same syntax as lucene?

On Wed, Mar 12, 2014 at 10:25 AM, Nikolas Everett [nik9000@gmail.com](mailto:nik9000@gmail.com) wrote:

> Yeah, don't try to wrap the query\_string in piles of regexes to make sure  
> it never throws errors and blocks features you don't want but lets through  
> features you do. It isn't fun.
> 
> On Wed, Mar 12, 2014 at 6:36 AM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:
> 
> > You may want to look at using the simple query string query instead:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html)
> > 
> > It has the benefit of not throwing syntax errors, but trying to do the  
> > right thing.
> > 
> > On 12 March 2014 01:53, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:
> > 
> > > Not sure if much has changed since I asked a similar question a while  
> > > back:
> > > 
> > > [Redirecting to Google Groups](https://groups.google.com/forum/#!msg/elasticsearch/f4hE3lHsJeA/u0ovOO91Vr4J)
> > > 
> > > Jorg's suggestion at the very end if perhaps the best, although I have  
> > > continued using my own method.
> > > 
> > > [https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java)
> > > 
> > > --  
> > > Ivan
> > > 
> > > On Tue, Mar 11, 2014 at 4:45 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:
> > > 
> > > > Is there a utility that can convert lucene query string format to ES  
> > > > Java API format? We are planning to use lucene query parser to validate  
> > > > query string entered by user in our application before creating a request  
> > > > to ES.
> > > > 
> > > > [Apache Lucene - Query Parser Syntax](http://lucene.apache.org/core/2_9_4/queryparsersyntax.html)
> > > > 
> > > > --  
> > > > 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).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > .  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > 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).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > 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).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoyxqaQPSXakSzFxmVDxfsRx8zavj-MizqhcdhmXtg-kA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoyxqaQPSXakSzFxmVDxfsRx8zavj-MizqhcdhmXtg-kA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [March 20, 2014, 12:05am UTC](https://discuss.elastic.co/t/lucene-query-parser-to-es-java-api/16305/6 "2014-03-20T00:05:17Z")

</div>

I am still trying to figure this out on how I can do this using ES java  
API. For eg: if user types the below search in the query string using  
lucene syntax to our app server can I use this with ES Java API?

[http://mypage.com/search?title:"elasticsearch"](http://mypage.com/search?title:%22elasticsearch%22) AND author:"Mohit"

On Wed, Mar 12, 2014 at 1:05 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:

> So suggestion is to just use java api simple query string object which I  
> presume uses same syntax as lucene?
> 
> On Wed, Mar 12, 2014 at 10:25 AM, Nikolas Everett [nik9000@gmail.com](mailto:nik9000@gmail.com)wrote:
> 
> > Yeah, don't try to wrap the query\_string in piles of regexes to make sure  
> > it never throws errors and blocks features you don't want but lets through  
> > features you do. It isn't fun.
> > 
> > On Wed, Mar 12, 2014 at 6:36 AM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:
> > 
> > > You may want to look at using the simple query string query instead:  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html)
> > > 
> > > It has the benefit of not throwing syntax errors, but trying to do the  
> > > right thing.
> > > 
> > > On 12 March 2014 01:53, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:
> > > 
> > > > Not sure if much has changed since I asked a similar question a while  
> > > > back:
> > > > 
> > > > [Redirecting to Google Groups](https://groups.google.com/forum/#!msg/elasticsearch/f4hE3lHsJeA/u0ovOO91Vr4J)
> > > > 
> > > > Jorg's suggestion at the very end if perhaps the best, although I have  
> > > > continued using my own method.
> > > > 
> > > > [https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java)
> > > > 
> > > > --  
> > > > Ivan
> > > > 
> > > > On Tue, Mar 11, 2014 at 4:45 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:
> > > > 
> > > > > Is there a utility that can convert lucene query string format to ES  
> > > > > Java API format? We are planning to use lucene query parser to validate  
> > > > > query string entered by user in our application before creating a request  
> > > > > to ES.
> > > > > 
> > > > > [Apache Lucene - Query Parser Syntax](http://lucene.apache.org/core/2_9_4/queryparsersyntax.html)
> > > > > 
> > > > > --  
> > > > > 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).  
> > > > > To view this discussion on the web visit  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > > .  
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > 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).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > 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).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > 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).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAOT3TWrVngeK2YJ0ANzfnr\_h\_y9RPiRt8%3DxRg3z2RHE-PwE4\_w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWrVngeK2YJ0ANzfnr_h_y9RPiRt8%3DxRg3z2RHE-PwE4_w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [March 20, 2014, 12:15am UTC](https://discuss.elastic.co/t/lucene-query-parser-to-es-java-api/16305/7 "2014-03-20T00:15:57Z")

</div>

It looks like I can use it this way:

QueryBuilders.queryString("_title:"elasticsearch_" AND author:"Mohit"");

On Wed, Mar 19, 2014 at 5:05 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:

> I am still trying to figure this out on how I can do this using ES java  
> API. For eg: if user types the below search in the query string using  
> lucene syntax to our app server can I use this with ES Java API?
> 
> [http://mypage.com/search?title:"elasticsearch"](http://mypage.com/search?title:%22elasticsearch%22) AND author:"Mohit"
> 
> On Wed, Mar 12, 2014 at 1:05 PM, Mohit Anchlia [mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)wrote:
> 
> > So suggestion is to just use java api simple query string object which I  
> > presume uses same syntax as lucene?
> > 
> > On Wed, Mar 12, 2014 at 10:25 AM, Nikolas Everett [nik9000@gmail.com](mailto:nik9000@gmail.com)wrote:
> > 
> > > Yeah, don't try to wrap the query\_string in piles of regexes to make  
> > > sure it never throws errors and blocks features you don't want but lets  
> > > through features you do. It isn't fun.
> > > 
> > > On Wed, Mar 12, 2014 at 6:36 AM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:
> > > 
> > > > You may want to look at using the simple query string query instead:  
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html)
> > > > 
> > > > It has the benefit of not throwing syntax errors, but trying to do the  
> > > > right thing.
> > > > 
> > > > On 12 March 2014 01:53, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:
> > > > 
> > > > > Not sure if much has changed since I asked a similar question a while  
> > > > > back:
> > > > > 
> > > > > [Redirecting to Google Groups](https://groups.google.com/forum/#!msg/elasticsearch/f4hE3lHsJeA/u0ovOO91Vr4J)
> > > > > 
> > > > > Jorg's suggestion at the very end if perhaps the best, although I have  
> > > > > continued using my own method.
> > > > > 
> > > > > [https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java)
> > > > > 
> > > > > --  
> > > > > Ivan
> > > > > 
> > > > > On Tue, Mar 11, 2014 at 4:45 PM, Mohit Anchlia \<[mohitanchlia@gmail.com](mailto:mohitanchlia@gmail.com)
> > > > > 
> > > > > > wrote:
> > > > > 
> > > > > > Is there a utility that can convert lucene query string format to ES  
> > > > > > Java API format? We are planning to use lucene query parser to validate  
> > > > > > query string entered by user in our application before creating a request  
> > > > > > to ES.
> > > > > > 
> > > > > > [Apache Lucene - Query Parser Syntax](http://lucene.apache.org/core/2_9_4/queryparsersyntax.html)
> > > > > > 
> > > > > > --  
> > > > > > 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).  
> > > > > > To view this discussion on the web visit  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU\_d4%3DWKg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWr5FphvtUDyHLy0%2BUzPUPQTPwkdP2oiCPZ75UU_d4%3DWKg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > > > .  
> > > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > > 
> > > > > --  
> > > > > 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).  
> > > > > To view this discussion on the web visit  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCv5sbLQNb34nrHtgtONCEgf1JsywBcydAcibEu4ony0Q%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > > .
> > > > > 
> > > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > > 
> > > > --  
> > > > 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).  
> > > > To view this discussion on the web visit  
> > > > [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQaiTydX2VK6qjSop6Ho4U0q%2BOiqbLyTAQ8emJpuG%2BW4A%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > 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).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2cwOW9usqk%2B7CWX5LLzheM7qB0NZrconyo12TMzgQNuw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoWJq-ZnYeJu1f5-ZKXXMMbEHdf5-R7n1V27-ZukVrTqg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAOT3TWoWJq-ZnYeJu1f5-ZKXXMMbEHdf5-R7n1V27-ZukVrTqg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:42am UTC](https://discuss.elastic.co/t/lucene-query-parser-to-es-java-api/16305/8 "2017-07-06T01:42:02Z")

</div>


