# URL query parameters limitation

**URL:** <https://discuss.elastic.co/t/url-query-parameters-limitation/9084>\
**Category:** Elasticsearch\
**Created:** [September 20, 2012, 9:37pm UTC](https://discuss.elastic.co/t/url-query-parameters-limitation/9084 "2012-09-20T21:37:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheOutlander\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theoutlander_2/32/2614_2.png) [@TheOutlander\_2](https://discuss.elastic.co/u/TheOutlander_2)\
**Post date:** [September 20, 2012, 9:37pm UTC](https://discuss.elastic.co/t/url-query-parameters-limitation/9084/1 "2012-09-20T21:37:22Z")

</div>

I'm ramping up on Query DSL and have heard that URL parameter queries have  
a limitation compared to JSON queries in the Request body.  
Could someone please elaborate (or point to a doc) on those limitations?

Thanks,  
Nick

--

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 20, 2012, 10:32pm UTC](https://discuss.elastic.co/t/url-query-parameters-limitation/9084/2 "2012-09-20T22:32:19Z")

</div>

In HTTP, it is up to the implementation to limit the request URI length, see

[http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2.1](http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2.1)

ES uses Netty for HTTP implementation, and current Netty HTTP request  
limits are documented here

[http://static.netty.io/3.5/api/org/jboss/netty/handler/codec/http/HttpRequestDecoder.html](http://static.netty.io/3.5/api/org/jboss/netty/handler/codec/http/HttpRequestDecoder.html)

Best regards,

Jörg

On Thursday, September 20, 2012 11:37:22 PM UTC+2, TheOutlander wrote:

> I'm ramping up on Query DSL and have heard that URL parameter queries have  
> a limitation compared to JSON queries in the Request body.  
> Could someone please elaborate (or point to a doc) on those limitations?
> 
> Thanks,  
> Nick

--

---

<div class="post-metadata">

**Author:** ![TheOutlander\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theoutlander_2/32/2614_2.png) [@TheOutlander\_2](https://discuss.elastic.co/u/TheOutlander_2)\
**Post date:** [September 20, 2012, 10:53pm UTC](https://discuss.elastic.co/t/url-query-parameters-limitation/9084/3 "2012-09-20T22:53:06Z")

</div>

Thanks for the quick response! I didn't even think about the URI length as  
the limitation!!  
So does that mean there are no syntactical limitations?

Thanks,  
Nick

On Thursday, September 20, 2012 3:32:19 PM UTC-7, Jörg Prante wrote:

> In HTTP, it is up to the implementation to limit the request URI length,  
> see
> 
> [HTTP/1.1: Protocol Parameters](http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2.1)
> 
> ES uses Netty for HTTP implementation, and current Netty HTTP request  
> limits are documented here
> 
> [http://static.netty.io/3.5/api/org/jboss/netty/handler/codec/http/HttpRequestDecoder.html](http://static.netty.io/3.5/api/org/jboss/netty/handler/codec/http/HttpRequestDecoder.html)
> 
> Best regards,
> 
> Jörg
> 
> On Thursday, September 20, 2012 11:37:22 PM UTC+2, TheOutlander wrote:
> 
> > I'm ramping up on Query DSL and have heard that URL parameter queries  
> > have a limitation compared to JSON queries in the Request body.  
> > Could someone please elaborate (or point to a doc) on those limitations?
> > 
> > Thanks,  
> > Nick

--

---

<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:** [September 21, 2012, 9:08am UTC](https://discuss.elastic.co/t/url-query-parameters-limitation/9084/4 "2012-09-21T09:08:23Z")

</div>

On Thu, 2012-09-20 at 15:53 -0700, TheOutlander wrote:

> Thanks for the quick response! I didn't even think about the URI  
> length as the limitation!!  
> So does that mean there are no syntactical limitations?

That kinda depends 🙂

You can pass the a full query using the query DSL as a parameter in the  
query string (as opposed to the POST body), in which case the only  
limitation is the URI length, but I find that to be quite unreadable.

However, most people, when referring to a query in the query string, are  
referring to: ?q=my+query+phrase

And that is more limiting than using the query DSL. The 'q=' maps to  
the query string query:

> **[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.

But using the query DSL directly gives you access to a much richer query  
language:

> **[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.

clint

--

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 21, 2012, 3:27pm UTC](https://discuss.elastic.co/t/url-query-parameters-limitation/9084/5 "2012-09-21T15:27:52Z")

</div>

Sorry, I misunderstood. I considered "limitation" being just a question  
about a length limit. Not sure what you mean with "syntactical limitation"  
though.

Maybe you assume only a subset of possible queries can be passed via an URL  
parameter in HTTP GET? The answer is no, see the 'source' parameter.

Or you assume the query syntax is limited to JSON? I never saw ES queries  
in YAML or SMILE, but it should be possible to use another syntax beside  
JSON, the code is there in org.elasticearch.common.xcontent

ES has a powerful domain-specific language (DSL) for queries, which is kind  
of agnostic to the protocol the search request is transported with. You can  
pass a search request

- with REST by the following methods:

-- HTTP POST in the request body  
-- HTTP GET in the request body (some think a request body in GET requests  
is not RESTful, but it is not forbidden)  
-- HTTP GET in the 'source' URL parameter

- with the ES Transport Protocol (Java API)

- with other transport protocols (e.g. provided by plugins)

So, by using REST, you can put a query into a HTTP GET URL parameter  
'source' as you would put the query into a HTTP POST body. That should  
work.

See also the java code in  
org.elasticsearch.rest.action.search.RestSearchAction

Clinton pointed out that URL parameters need to be URI-escaped which makes  
them not well readable, and the GET parameter 'q' maps to a 'query\_string'  
query. But that is just for convenience if you do not want to enter JSON  
syntax in favor of pure Lucene syntax. That is a feature, not a limitation.

Best regards,

Jörg

On Friday, September 21, 2012 12:53:06 AM UTC+2, TheOutlander wrote:

> Thanks for the quick response! I didn't even think about the URI length as  
> the limitation!!  
> So does that mean there are no syntactical limitations?
> 
> Thanks,  
> Nick
> 
> On Thursday, September 20, 2012 3:32:19 PM UTC-7, Jörg Prante wrote:
> 
> > In HTTP, it is up to the implementation to limit the request URI length,  
> > see
> > 
> > [HTTP/1.1: Protocol Parameters](http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2.1)
> > 
> > ES uses Netty for HTTP implementation, and current Netty HTTP request  
> > limits are documented here
> > 
> > [http://static.netty.io/3.5/api/org/jboss/netty/handler/codec/http/HttpRequestDecoder.html](http://static.netty.io/3.5/api/org/jboss/netty/handler/codec/http/HttpRequestDecoder.html)
> > 
> > Best regards,
> > 
> > Jörg
> > 
> > On Thursday, September 20, 2012 11:37:22 PM UTC+2, TheOutlander wrote:
> > 
> > > I'm ramping up on Query DSL and have heard that URL parameter queries  
> > > have a limitation compared to JSON queries in the Request body.  
> > > Could someone please elaborate (or point to a doc) on those limitations?
> > > 
> > > Thanks,  
> > > Nick

--

---

<div class="post-metadata">

**Author:** ![TheOutlander\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theoutlander_2/32/2614_2.png) [@TheOutlander\_2](https://discuss.elastic.co/u/TheOutlander_2)\
**Post date:** [September 21, 2012, 6:37pm UTC](https://discuss.elastic.co/t/url-query-parameters-limitation/9084/6 "2012-09-21T18:37:21Z")

</div>

That makes sense. I agree that URL queries can get unreadable and usually  
we're thinking of simpler queries when referring to query strings.

-Nick

On Friday, September 21, 2012 2:08:37 AM UTC-7, Clinton Gormley wrote:

> On Thu, 2012-09-20 at 15:53 -0700, TheOutlander wrote:
> 
> > Thanks for the quick response! I didn't even think about the URI  
> > length as the limitation!!  
> > So does that mean there are no syntactical limitations?
> 
> That kinda depends 🙂
> 
> You can pass the a full query using the query DSL as a parameter in the  
> query string (as opposed to the POST body), in which case the only  
> limitation is the URI length, but I find that to be quite unreadable.
> 
> However, most people, when referring to a query in the query string, are  
> referring to: ?q=my+query+phrase
> 
> And that is more limiting than using the query DSL. The 'q=' maps to  
> the query string query:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query.html)
> 
> But using the query DSL directly gives you access to a much richer query  
> language:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl)
> 
> clint

--

---

<div class="post-metadata">

**Author:** ![TheOutlander\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theoutlander_2/32/2614_2.png) [@TheOutlander\_2](https://discuss.elastic.co/u/TheOutlander_2)\
**Post date:** [September 21, 2012, 6:39pm UTC](https://discuss.elastic.co/t/url-query-parameters-limitation/9084/7 "2012-09-21T18:39:13Z")

</div>

Thanks, that clears it up!  
I asked about a "limitation" specifically because I think I saw it in the  
documentation somewhere, but it never explained what it was.

Thanks,  
Nick

On Friday, September 21, 2012 8:27:52 AM UTC-7, Jörg Prante wrote:

> Sorry, I misunderstood. I considered "limitation" being just a question  
> about a length limit. Not sure what you mean with "syntactical limitation"  
> though.
> 
> Maybe you assume only a subset of possible queries can be passed via an  
> URL parameter in HTTP GET? The answer is no, see the 'source' parameter.
> 
> Or you assume the query syntax is limited to JSON? I never saw ES queries  
> in YAML or SMILE, but it should be possible to use another syntax beside  
> JSON, the code is there in org.elasticearch.common.xcontent
> 
> ES has a powerful domain-specific language (DSL) for queries, which is  
> kind of agnostic to the protocol the search request is transported  
> with. You can pass a search request
> 
> - with REST by the following methods:
> 
> -- HTTP POST in the request body  
> -- HTTP GET in the request body (some think a request body in GET requests  
> is not RESTful, but it is not forbidden)  
> -- HTTP GET in the 'source' URL parameter
> 
> - with the ES Transport Protocol (Java API)
> 
> - with other transport protocols (e.g. provided by plugins)
> 
> So, by using REST, you can put a query into a HTTP GET URL parameter  
> 'source' as you would put the query into a HTTP POST body. That should  
> work.
> 
> See also the java code in  
> org.elasticsearch.rest.action.search.RestSearchAction
> 
> Clinton pointed out that URL parameters need to be URI-escaped which makes  
> them not well readable, and the GET parameter 'q' maps to a 'query\_string'  
> query. But that is just for convenience if you do not want to enter JSON  
> syntax in favor of pure Lucene syntax. That is a feature, not a limitation.
> 
> Best regards,
> 
> Jörg
> 
> On Friday, September 21, 2012 12:53:06 AM UTC+2, TheOutlander wrote:
> 
> > Thanks for the quick response! I didn't even think about the URI length  
> > as the limitation!!  
> > So does that mean there are no syntactical limitations?
> > 
> > Thanks,  
> > Nick
> > 
> > On Thursday, September 20, 2012 3:32:19 PM UTC-7, Jörg Prante wrote:
> > 
> > > In HTTP, it is up to the implementation to limit the request URI length,  
> > > see
> > > 
> > > [HTTP/1.1: Protocol Parameters](http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2.1)
> > > 
> > > ES uses Netty for HTTP implementation, and current Netty HTTP request  
> > > limits are documented here
> > > 
> > > [http://static.netty.io/3.5/api/org/jboss/netty/handler/codec/http/HttpRequestDecoder.html](http://static.netty.io/3.5/api/org/jboss/netty/handler/codec/http/HttpRequestDecoder.html)
> > > 
> > > Best regards,
> > > 
> > > Jörg
> > > 
> > > On Thursday, September 20, 2012 11:37:22 PM UTC+2, TheOutlander wrote:
> > > 
> > > > I'm ramping up on Query DSL and have heard that URL parameter queries  
> > > > have a limitation compared to JSON queries in the Request body.  
> > > > Could someone please elaborate (or point to a doc) on those limitations?
> > > > 
> > > > Thanks,  
> > > > Nick

--

---

<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, 3:11am UTC](https://discuss.elastic.co/t/url-query-parameters-limitation/9084/8 "2017-07-06T03:11:52Z")

</div>


