# Which kind of query style is recommanded to use, JSON style or Query\_string sytel? Performance differes?

**URL:** https://discuss.elastic.co/t/which-kind-of-query-style-is-recommanded-to-use-json-style-or-query-string-sytel-performance-differes/22906
**Category:** Elasticsearch
**Created:** [March 25, 2015, 8:28pm UTC](https://discuss.elastic.co/t/which-kind-of-query-style-is-recommanded-to-use-json-style-or-query-string-sytel-performance-differes/22906 "2015-03-25T20:28:13Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Lincoln\_Xiong](https://avatars.discourse-cdn.com/v4/letter/l/5f9b8f/32.png) [@Lincoln\_Xiong](https://discuss.elastic.co/u/Lincoln_Xiong)
#### Post date: [March 25, 2015, 8:28pm UTC](https://discuss.elastic.co/t/which-kind-of-query-style-is-recommanded-to-use-json-style-or-query-string-sytel-performance-differes/22906/1 "2015-03-25T20:28:13Z")

</div>

I am new to use Elasticsearch + Logstash + Kibana for analyzing some logs.  
I am about to write some scripts to automate something in  
searching/aggregation. Now I only have 10gb data so the performance don't  
vary that much when I do searching or visualization. I spent a lot of time  
learning ES's query DSL but seems still not get the key, wondering  
query\_string will just do the search in Kibana, but I can also use those  
verbose query DSL in my script.

My question is, regard to performance or any, is there difference to use  
whether query\_string, the search box like searching, or use the DSL,  
verbose with curry brackets? Or people are encouraged to use DSL because it  
performs better than query\_string, or something?

For now, I don't see any difference b/w query\_string and query DSL. Maybe  
some one can give me an example that DSL can do something that query\_string  
cannot.

Any comments may help me increase my understanding of ES. Thank you!

--  
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/d475236c-a5ac-4abf-82e3-5990530ed391%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d475236c-a5ac-4abf-82e3-5990530ed391%40googlegroups.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 25, 2015, 10:13pm UTC](https://discuss.elastic.co/t/which-kind-of-query-style-is-recommanded-to-use-json-style-or-query-string-sytel-performance-differes/22906/2 "2015-03-25T22:13:58Z")

</div>

query\_string is a bit of a trap - if you write an invalid query it just  
crashes. So you find yourself working around it with tons of escaping.  
Its also really really powerful and shouldn't be exposed directly to end  
users unless you want them to be sneaky.

For the most part I'd suggest using the JSON DSL and/or some DSL wrapper  
around it.

On Wed, Mar 25, 2015 at 4:28 PM, Lincoln Xiong [xiong.huanglin@gmail.com](mailto:xiong.huanglin@gmail.com)  
wrote:

> I am new to use Elasticsearch + Logstash + Kibana for analyzing some logs.  
> I am about to write some scripts to automate something in  
> searching/aggregation. Now I only have 10gb data so the performance don't  
> vary that much when I do searching or visualization. I spent a lot of time  
> learning ES's query DSL but seems still not get the key, wondering  
> query\_string will just do the search in Kibana, but I can also use those  
> verbose query DSL in my script.
> 
> My question is, regard to performance or any, is there difference to use  
> whether query\_string, the search box like searching, or use the DSL,  
> verbose with curry brackets? Or people are encouraged to use DSL because it  
> performs better than query\_string, or something?
> 
> For now, I don't see any difference b/w query\_string and query DSL. Maybe  
> some one can give me an example that DSL can do something that query\_string  
> cannot.
> 
> Any comments may help me increase my understanding of ES. Thank you!
> 
> --  
> 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/d475236c-a5ac-4abf-82e3-5990530ed391%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d475236c-a5ac-4abf-82e3-5990530ed391%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/d475236c-a5ac-4abf-82e3-5990530ed391%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/d475236c-a5ac-4abf-82e3-5990530ed391%40googlegroups.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/CAPmjWd1L\_Wq%3DnLOUD6k-ec-sN9Q8hOxAZw-txp8KQDnBpexS-A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd1L_Wq%3DnLOUD6k-ec-sN9Q8hOxAZw-txp8KQDnBpexS-A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Lincoln\_Xiong](https://avatars.discourse-cdn.com/v4/letter/l/5f9b8f/32.png) [@Lincoln\_Xiong](https://discuss.elastic.co/u/Lincoln_Xiong)
#### Post date: [March 26, 2015, 3:07pm UTC](https://discuss.elastic.co/t/which-kind-of-query-style-is-recommanded-to-use-json-style-or-query-string-sytel-performance-differes/22906/3 "2015-03-26T15:07:36Z")

</div>

Query\_string is more straight forward, because most of time I use Kibana to  
test my query. But for the DSL, it's kind of hard to fully understand which  
query to use. And to test my query is also difficult because too many  
brackets...  
There is a high level Python API for DSL. I'm learning it.  
Thanks for your advice.

On Wednesday, March 25, 2015 at 6:14:26 PM UTC-4, Nikolas Everett wrote:

> query\_string is a bit of a trap - if you write an invalid query it just  
> crashes. So you find yourself working around it with tons of escaping.  
> Its also really really powerful and shouldn't be exposed directly to end  
> users unless you want them to be sneaky.
> 
> For the most part I'd suggest using the JSON DSL and/or some DSL wrapper  
> around it.
> 
> On Wed, Mar 25, 2015 at 4:28 PM, Lincoln Xiong \<[xiong.h...@gmail.com](mailto:xiong.h...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > I am new to use Elasticsearch + Logstash + Kibana for analyzing some  
> > logs. I am about to write some scripts to automate something in  
> > searching/aggregation. Now I only have 10gb data so the performance don't  
> > vary that much when I do searching or visualization. I spent a lot of time  
> > learning ES's query DSL but seems still not get the key, wondering  
> > query\_string will just do the search in Kibana, but I can also use those  
> > verbose query DSL in my script.
> > 
> > My question is, regard to performance or any, is there difference to use  
> > whether query\_string, the search box like searching, or use the DSL,  
> > verbose with curry brackets? Or people are encouraged to use DSL because it  
> > performs better than query\_string, or something?
> > 
> > For now, I don't see any difference b/w query\_string and query DSL. Maybe  
> > some one can give me an example that DSL can do something that query\_string  
> > cannot.
> > 
> > Any comments may help me increase my understanding of ES. Thank you!
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/d475236c-a5ac-4abf-82e3-5990530ed391%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d475236c-a5ac-4abf-82e3-5990530ed391%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/d475236c-a5ac-4abf-82e3-5990530ed391%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/d475236c-a5ac-4abf-82e3-5990530ed391%40googlegroups.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/af886b1a-cf9b-4023-bb7a-7816ed4b6979%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/af886b1a-cf9b-4023-bb7a-7816ed4b6979%40googlegroups.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, 12:23am UTC](https://discuss.elastic.co/t/which-kind-of-query-style-is-recommanded-to-use-json-style-or-query-string-sytel-performance-differes/22906/4 "2017-07-06T00:23:39Z")

</div>


