# JSONP and Facet queries

**URL:** <https://discuss.elastic.co/t/jsonp-and-facet-queries/3420>\
**Category:** Elasticsearch\
**Created:** [October 7, 2010, 4:12pm UTC](https://discuss.elastic.co/t/jsonp-and-facet-queries/3420 "2010-10-07T16:12:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mooky](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@mooky](https://discuss.elastic.co/u/mooky)\
**Post date:** [October 7, 2010, 4:12pm UTC](https://discuss.elastic.co/t/jsonp-and-facet-queries/3420/1 "2010-10-07T16:12:47Z")

</div>

Does anyone have an example of what the uri/querystring looks like for  
a facet query?

Trying to do a JSONP query with facets. Cant find anything in the  
documentation though.  
Any pointers?

Cheers,  
Nick

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 7, 2010, 4:55pm UTC](https://discuss.elastic.co/t/jsonp-and-facet-queries/3420/2 "2010-10-07T16:55:23Z")

</div>

jsonp and facets are two different things. jsonp applies to any HTTP REST  
API, simply add a callback with your name of the function as a parameter,  
and the response will be wrapped in jsonp.

Regarding facets, they are part of the search request (like query, from, to,  
sort, ...), and documented here:  
[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/facets/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/facets/).

-shay.banon

On Thu, Oct 7, 2010 at 6:12 PM, the claw [nick.minutello@gmail.com](mailto:nick.minutello@gmail.com) wrote:

> Does anyone have an example of what the uri/querystring looks like for  
> a facet query?
> 
> Trying to do a JSONP query with facets. Cant find anything in the  
> documentation though.  
> Any pointers?
> 
> Cheers,  
> Nick

---

<div class="post-metadata">

**Author:** ![mooky](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@mooky](https://discuss.elastic.co/u/mooky)\
**Post date:** [October 7, 2010, 5:53pm UTC](https://discuss.elastic.co/t/jsonp-and-facet-queries/3420/3 "2010-10-07T17:53:21Z")

</div>

Maybe Im misunderstanding something....  
The only examples I see for facet queries involved sending a json  
body. Can you send body data with jsonp??

I was looking for some mention of support for facets here:  
[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/uri\_request/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/uri_request/)

-Nick

On Oct 7, 5:55 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> jsonp and facets are two different things. jsonp applies to any HTTP REST  
> API, simply add a callback with your name of the function as a parameter,  
> and the response will be wrapped in jsonp.
> 
> Regarding facets, they are part of the search request (like query, from, to,  
> sort, ...), and documented here:[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/facets/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/facets/).
> 
> -shay.banon
> 
> On Thu, Oct 7, 2010 at 6:12 PM, the claw [nick.minute...@gmail.com](mailto:nick.minute...@gmail.com) wrote:
> 
> > Does anyone have an example of what the uri/querystring looks like for  
> > a facet query?
> 
> > Trying to do a JSONP query with facets. Cant find anything in the  
> > documentation though.  
> > Any pointers?
> 
> > Cheers,  
> > Nick

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 7, 2010, 6:12pm UTC](https://discuss.elastic.co/t/jsonp-and-facet-queries/3420/4 "2010-10-07T18:12:40Z")

</div>

In terms of pure HTTP, you can use JSONP with GET and POST. Regarding actual  
implementations of it, I know that GET on some implementations does not  
accept a body, thats why the search endpoint also supports POST (yuck!).

You can't define facets in the URI based request (its senseless to try and  
expose all the facets options there), so you can use facets when searching  
with a search request body.

-shay.banon

On Thu, Oct 7, 2010 at 7:53 PM, Mooky [nick.minutello@gmail.com](mailto:nick.minutello@gmail.com) wrote:

> Maybe Im misunderstanding something....  
> The only examples I see for facet queries involved sending a json  
> body. Can you send body data with jsonp??
> 
> I was looking for some mention of support for facets here:
> 
> [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/uri\_request/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/uri_request/)
> 
> -Nick
> 
> On Oct 7, 5:55 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > jsonp and facets are two different things. jsonp applies to any HTTP REST  
> > API, simply add a callback with your name of the function as a parameter,  
> > and the response will be wrapped in jsonp.
> > 
> > Regarding facets, they are part of the search request (like query, from,  
> > to,  
> > sort, ...), and documented here:  
> > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/facets/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/facets/).
> > 
> > -shay.banon
> > 
> > On Thu, Oct 7, 2010 at 6:12 PM, the claw [nick.minute...@gmail.com](mailto:nick.minute...@gmail.com)  
> > wrote:
> > 
> > > Does anyone have an example of what the uri/querystring looks like for  
> > > a facet query?
> > 
> > > Trying to do a JSONP query with facets. Cant find anything in the  
> > > documentation though.  
> > > Any pointers?
> > 
> > > Cheers,  
> > > Nick

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 7, 2010, 6:14pm UTC](https://discuss.elastic.co/t/jsonp-and-facet-queries/3420/5 "2010-10-07T18:14:39Z")

</div>

Note also that elasticsearch HTTP endpoint  
supports Access-Control-Allow-Origin (  
[https://developer.mozilla.org/en/HTTP\_access\_control](https://developer.mozilla.org/en/HTTP_access_control)), so you might not even  
need jsonp.

-shay.banon

On Thu, Oct 7, 2010 at 8:12 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> In terms of pure HTTP, you can use JSONP with GET and POST. Regarding  
> actual implementations of it, I know that GET on some implementations does  
> not accept a body, thats why the search endpoint also supports POST  
> (yuck!).
> 
> You can't define facets in the URI based request (its senseless to try and  
> expose all the facets options there), so you can use facets when searching  
> with a search request body.
> 
> -shay.banon
> 
> On Thu, Oct 7, 2010 at 7:53 PM, Mooky [nick.minutello@gmail.com](mailto:nick.minutello@gmail.com) wrote:
> 
> > Maybe Im misunderstanding something....  
> > The only examples I see for facet queries involved sending a json  
> > body. Can you send body data with jsonp??
> > 
> > I was looking for some mention of support for facets here:
> > 
> > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/uri\_request/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/uri_request/)
> > 
> > -Nick
> > 
> > On Oct 7, 5:55 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > jsonp and facets are two different things. jsonp applies to any HTTP  
> > > REST  
> > > API, simply add a callback with your name of the function as a  
> > > parameter,  
> > > and the response will be wrapped in jsonp.
> > > 
> > > Regarding facets, they are part of the search request (like query, from,  
> > > to,  
> > > sort, ...), and documented here:  
> > > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/facets/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/facets/).
> > > 
> > > -shay.banon
> > > 
> > > On Thu, Oct 7, 2010 at 6:12 PM, the claw [nick.minute...@gmail.com](mailto:nick.minute...@gmail.com)  
> > > wrote:
> > > 
> > > > Does anyone have an example of what the uri/querystring looks like for  
> > > > a facet query?
> > > 
> > > > Trying to do a JSONP query with facets. Cant find anything in the  
> > > > documentation though.  
> > > > Any pointers?
> > > 
> > > > Cheers,  
> > > > Nick

---

<div class="post-metadata">

**Author:** ![mooky](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@mooky](https://discuss.elastic.co/u/mooky)\
**Post date:** [October 7, 2010, 6:38pm UTC](https://discuss.elastic.co/t/jsonp-and-facet-queries/3420/6 "2010-10-07T18:38:44Z")

</div>

As far as I understand it, with jsonp, you can only do a uri get ...  
ie whatever you can encode into the uri ... (no post, no  
body)

On Oct 7, 7:12 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> In terms of pure HTTP, you can use JSONP with GET and POST. Regarding actual  
> implementations of it, I know that GET on some implementations does not  
> accept a body, thats why the search endpoint also supports POST (yuck!).
> 
> You can't define facets in the URI based request (its senseless to try and  
> expose all the facets options there), so you can use facets when searching  
> with a search request body.
> 
> -shay.banon
> 
> On Thu, Oct 7, 2010 at 7:53 PM, Mooky [nick.minute...@gmail.com](mailto:nick.minute...@gmail.com) wrote:
> 
> > Maybe Im misunderstanding something....  
> > The only examples I see for facet queries involved sending a json  
> > body. Can you send body data with jsonp??
> 
> > I was looking for some mention of support for facets here:
> 
> > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/uri\_r](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/uri_r)...
> 
> > -Nick
> 
> > On Oct 7, 5:55 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > jsonp and facets are two different things. jsonp applies to any HTTP REST  
> > > API, simply add a callback with your name of the function as a parameter,  
> > > and the response will be wrapped in jsonp.
> 
> > > Regarding facets, they are part of the search request (like query, from,  
> > > to,  
> > > sort, ...), and documented here:  
> > > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/facets/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/facets/).
> 
> > > -shay.banon
> 
> > > On Thu, Oct 7, 2010 at 6:12 PM, the claw [nick.minute...@gmail.com](mailto:nick.minute...@gmail.com)  
> > > wrote:
> > > 
> > > > Does anyone have an example of what the uri/querystring looks like for  
> > > > a facet query?
> 
> > > > Trying to do a JSONP query with facets. Cant find anything in the  
> > > > documentation though.  
> > > > Any pointers?
> 
> > > > Cheers,  
> > > > Nick

---

<div class="post-metadata">

**Author:** ![mooky](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@mooky](https://discuss.elastic.co/u/mooky)\
**Post date:** [October 7, 2010, 6:39pm UTC](https://discuss.elastic.co/t/jsonp-and-facet-queries/3420/7 "2010-10-07T18:39:22Z")

</div>

super-cool

On Oct 7, 7:14 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Note also that elasticsearch HTTP endpoint  
> supports Access-Control-Allow-Origin ([https://developer.mozilla.org/en/HTTP\_access\_control](https://developer.mozilla.org/en/HTTP_access_control)), so you might not even  
> need jsonp.
> 
> -shay.banon
> 
> On Thu, Oct 7, 2010 at 8:12 PM, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com)wrote:
> 
> > In terms of pure HTTP, you can use JSONP with GET and POST. Regarding  
> > actual implementations of it, I know that GET on some implementations does  
> > not accept a body, thats why the search endpoint also supports POST  
> > (yuck!).
> 
> > You can't define facets in the URI based request (its senseless to try and  
> > expose all the facets options there), so you can use facets when searching  
> > with a search request body.
> 
> > -shay.banon
> 
> > On Thu, Oct 7, 2010 at 7:53 PM, Mooky [nick.minute...@gmail.com](mailto:nick.minute...@gmail.com) wrote:
> 
> > > Maybe Im misunderstanding something....  
> > > The only examples I see for facet queries involved sending a json  
> > > body. Can you send body data with jsonp??
> 
> > > I was looking for some mention of support for facets here:
> 
> > > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/uri\_r](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/uri_r)...
> 
> > > -Nick
> 
> > > On Oct 7, 5:55 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > > 
> > > > jsonp and facets are two different things. jsonp applies to any HTTP  
> > > > REST  
> > > > API, simply add a callback with your name of the function as a  
> > > > parameter,  
> > > > and the response will be wrapped in jsonp.
> 
> > > > Regarding facets, they are part of the search request (like query, from,  
> > > > to,  
> > > > sort, ...), and documented here:  
> > > > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/facets/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/facets/).
> 
> > > > -shay.banon
> 
> > > > On Thu, Oct 7, 2010 at 6:12 PM, the claw [nick.minute...@gmail.com](mailto:nick.minute...@gmail.com)  
> > > > wrote:
> > > > 
> > > > > Does anyone have an example of what the uri/querystring looks like for  
> > > > > a facet query?
> 
> > > > > Trying to do a JSONP query with facets. Cant find anything in the  
> > > > > documentation though.  
> > > > > Any pointers?
> 
> > > > > Cheers,  
> > > > > Nick

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 7, 2010, 7:27pm UTC](https://discuss.elastic.co/t/jsonp-and-facet-queries/3420/8 "2010-10-07T19:27:10Z")

</div>

Ahh, wrote something wrong. I meant a body with GET request, which not all  
support, not jsonp. The search Rest API (GET) supports passing the whole  
"body" as a "source" parameter. Hackish, better check the access control  
option first.

-shay.banon

On Thu, Oct 7, 2010 at 8:38 PM, Mooky [nick.minutello@gmail.com](mailto:nick.minutello@gmail.com) wrote:

> As far as I understand it, with jsonp, you can only do a uri get ...  
> ie whatever you can encode into the uri ... (no post, no  
> body)
> 
> On Oct 7, 7:12 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > In terms of pure HTTP, you can use JSONP with GET and POST. Regarding  
> > actual  
> > implementations of it, I know that GET on some implementations does not  
> > accept a body, thats why the search endpoint also supports POST (yuck!).
> > 
> > You can't define facets in the URI based request (its senseless to try  
> > and  
> > expose all the facets options there), so you can use facets when  
> > searching  
> > with a search request body.
> > 
> > -shay.banon
> > 
> > On Thu, Oct 7, 2010 at 7:53 PM, Mooky [nick.minute...@gmail.com](mailto:nick.minute...@gmail.com) wrote:
> > 
> > > Maybe Im misunderstanding something....  
> > > The only examples I see for facet queries involved sending a json  
> > > body. Can you send body data with jsonp??
> > 
> > > I was looking for some mention of support for facets here:
> > 
> > > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/uri\_r](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/uri_r).  
> > > ..
> > 
> > > -Nick
> > 
> > > On Oct 7, 5:55 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > > 
> > > > jsonp and facets are two different things. jsonp applies to any HTTP  
> > > > REST  
> > > > API, simply add a callback with your name of the function as a  
> > > > parameter,  
> > > > and the response will be wrapped in jsonp.
> > 
> > > > Regarding facets, they are part of the search request (like query,  
> > > > from,  
> > > > to,  
> > > > sort, ...), and documented here:  
> > > > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/search/facets/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/search/facets/)  
> > > > .
> > 
> > > > -shay.banon
> > 
> > > > On Thu, Oct 7, 2010 at 6:12 PM, the claw [nick.minute...@gmail.com](mailto:nick.minute...@gmail.com)  
> > > > wrote:
> > > > 
> > > > > Does anyone have an example of what the uri/querystring looks like  
> > > > > for  
> > > > > a facet query?
> > 
> > > > > Trying to do a JSONP query with facets. Cant find anything in the  
> > > > > documentation though.  
> > > > > Any pointers?
> > 
> > > > > Cheers,  
> > > > > 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, 4:18am UTC](https://discuss.elastic.co/t/jsonp-and-facet-queries/3420/9 "2017-07-06T04:18:15Z")

</div>


