# Why is the Java api query slower than the rest call?

**URL:** <https://discuss.elastic.co/t/why-is-the-java-api-query-slower-than-the-rest-call/17599>\
**Category:** Elasticsearch\
**Created:** [May 19, 2014, 5:28pm UTC](https://discuss.elastic.co/t/why-is-the-java-api-query-slower-than-the-rest-call/17599 "2014-05-19T17:28:58Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![savioteles](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/savioteles/32/851_2.png) [@savioteles](https://discuss.elastic.co/u/savioteles)\
**Post date:** [May 19, 2014, 5:28pm UTC](https://discuss.elastic.co/t/why-is-the-java-api-query-slower-than-the-rest-call/17599/1 "2014-05-19T17:28:58Z")

</div>

When I run the following query, it takes much more time using the JAVA api  
than using the REST call (for example using the HEAD ES plugin). Why is  
this happening? Can anyone help me?

Thanks!!!

_Time:_

JAVA api time: 118 ms  
REST call: 30 ms

_Query:_

{  
"from": 0,  
"size": 0,  
"query": {  
"query\_string": {  
"default\_operator": "AND",  
"query": "new"  
}  
},  
"facets": {  
"f": {  
"terms": {  
"field": "city",  
"size": 10  
},  
"facet\_filter": {  
"term": {  
"state": "NY"  
}  
}  
}  
}  
}

--  
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/bcef4922-e35f-424b-9765-562bb7d837f2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bcef4922-e35f-424b-9765-562bb7d837f2%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![savioteles](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/savioteles/32/851_2.png) [@savioteles](https://discuss.elastic.co/u/savioteles)\
**Post date:** [May 19, 2014, 5:29pm UTC](https://discuss.elastic.co/t/why-is-the-java-api-query-slower-than-the-rest-call/17599/2 "2014-05-19T17:29:30Z")

</div>

I'm using the 1.1.0 ES version.

Em segunda-feira, 19 de maio de 2014 14h28min58s UTC-3, Sávio Salvarino  
Teles de Oliveira escreveu:

> When I run the following query, it takes much more time using the JAVA api  
> than using the REST call (for example using the HEAD ES plugin). Why is  
> this happening? Can anyone help me?
> 
> Thanks!!!
> 
> _Time:_
> 
> JAVA api time: 118 ms  
> REST call: 30 ms
> 
> _Query:_
> 
> {  
> "from": 0,  
> "size": 0,  
> "query": {  
> "query\_string": {  
> "default\_operator": "AND",  
> "query": "new"  
> }  
> },  
> "facets": {  
> "f": {  
> "terms": {  
> "field": "city",  
> "size": 10  
> },  
> "facet\_filter": {  
> "term": {  
> "state": "NY"  
> }  
> }  
> }  
> }  
> }

--  
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/178270c3-1098-41f7-97cd-4101c176f26a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/178270c3-1098-41f7-97cd-4101c176f26a%40googlegroups.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:** [May 19, 2014, 6:06pm UTC](https://discuss.elastic.co/t/why-is-the-java-api-query-slower-than-the-rest-call/17599/3 "2014-05-19T18:06:35Z")

</div>

Can you post the Java code as well? The REST API calls the Java API  
underneath, so by definition the REST call should always be slower. There  
must be something different in the Java code.

--  
Ivan

On Mon, May 19, 2014 at 10:29 AM, Sávio Salvarino Teles de Oliveira \<  
savio.teles@cuia.com.br\> wrote:

> I'm using the 1.1.0 ES version.
> 
> Em segunda-feira, 19 de maio de 2014 14h28min58s UTC-3, Sávio Salvarino  
> Teles de Oliveira escreveu:
> 
> > When I run the following query, it takes much more time using the JAVA  
> > api than using the REST call (for example using the HEAD ES plugin). Why is  
> > this happening? Can anyone help me?
> > 
> > Thanks!!!
> > 
> > _Time:_
> > 
> > JAVA api time: 118 ms  
> > REST call: 30 ms
> > 
> > _Query:_
> > 
> > {  
> > "from": 0,  
> > "size": 0,  
> > "query": {  
> > "query\_string": {  
> > "default\_operator": "AND",  
> > "query": "new"  
> > }  
> > },  
> > "facets": {  
> > "f": {  
> > "terms": {  
> > "field": "city",  
> > "size": 10  
> > },  
> > "facet\_filter": {  
> > "term": {  
> > "state": "NY"  
> > }  
> > }  
> > }  
> > }  
> > }
> 
> --  
> 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/178270c3-1098-41f7-97cd-4101c176f26a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/178270c3-1098-41f7-97cd-4101c176f26a%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/178270c3-1098-41f7-97cd-4101c176f26a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/178270c3-1098-41f7-97cd-4101c176f26a%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/CALY%3DcQCRypLMVAZUuMsxkws-EriOu8e3u%2BFWXp0bYJonN9q7LA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCRypLMVAZUuMsxkws-EriOu8e3u%2BFWXp0bYJonN9q7LA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![savioteles](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/savioteles/32/851_2.png) [@savioteles](https://discuss.elastic.co/u/savioteles)\
**Post date:** [May 19, 2014, 6:25pm UTC](https://discuss.elastic.co/t/why-is-the-java-api-query-slower-than-the-rest-call/17599/4 "2014-05-19T18:25:35Z")

</div>

Yes, the code is bellow:

_String query = ""query": {"query\_string": {"default\_operator":  
"AND","query": "new"}}";_  
_JSONObject jsonObject = new JSONObject(query);_  
_String jsonQuery = jsonObject.get("query").toString();_

_TermFilterBuilder termFilter = FilterBuilders.termFilter("state", "NY");_

_FacetBuilder facetBuilder =  
FacetBuilders.termsFacet("f").field("city").size(10);_  
_facetBuilder.facetFilter(termFilter);_

_SearchRequestBuilder request = client.prepareSearch("cities");_

_request.setQuery(QueryBuilders.wrapperQuery(jsonQuery));_

_request.addFacet(facetBuilder).setTypes(ATTR).setSearchType(SearchType.DFS\_QUERY\_AND\_FETCH).setFrom(0).setSize(0);_

_SearchResponse response = request.execute().actionGet();_

--  
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/CAFKmhPs\_J2cERAobLMsKo\_FMab%3DpDjECCCmY%3Duw7T%2B%2BLKTtBgg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFKmhPs_J2cERAobLMsKo_FMab%3DpDjECCCmY%3Duw7T%2B%2BLKTtBgg%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:** [May 19, 2014, 6:49pm UTC](https://discuss.elastic.co/t/why-is-the-java-api-query-slower-than-the-rest-call/17599/5 "2014-05-19T18:49:33Z")

</div>

Why are you creating a JSON object for the query string query? You can  
create a query builder object directly. Look at the same Java code on the  
Elasticsearch site:

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

Instead of the term query, substitute a QueryStringQueryBuilder. Perhaps  
the performance degradation is coming from the serializing/deserializing of  
the JSON object.

Default search type is QUERY\_THEN\_FETCH. Using DFS will have some  
performance impact, but in my testing it is negligible. Also, are you sure  
you want DFS\_QUERY\*_AND_\*FETCH?

--  
Ivan

On Mon, May 19, 2014 at 11:25 AM, Sávio S. Teles de Oliveira \<  
savio.teles@cuia.com.br\> wrote:

> Yes, the code is bellow:
> 
> _String query = ""query": {"query\_string": {"default\_operator":  
> "AND","query": "new"}}";_  
> _JSONObject jsonObject = new JSONObject(query);_  
> _String jsonQuery = jsonObject.get("query").toString();_
> 
> _TermFilterBuilder termFilter = FilterBuilders.termFilter("state", "NY");_
> 
> _FacetBuilder facetBuilder =  
> FacetBuilders.termsFacet("f").field("city").size(10);_  
> _facetBuilder.facetFilter(termFilter);_
> 
> _SearchRequestBuilder request = client.prepareSearch("cities");_
> 
> _request.setQuery(QueryBuilders.wrapperQuery(jsonQuery));_
> 
> _request.addFacet(facetBuilder).setTypes(ATTR).setSearchType(SearchType.DFS\_QUERY\_AND\_FETCH).setFrom(0).setSize(0);_
> 
> _SearchResponse response = request.execute().actionGet();_
> 
> --  
> 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/CAFKmhPs\_J2cERAobLMsKo\_FMab%3DpDjECCCmY%3Duw7T%2B%2BLKTtBgg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFKmhPs_J2cERAobLMsKo_FMab%3DpDjECCCmY%3Duw7T%2B%2BLKTtBgg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAFKmhPs\_J2cERAobLMsKo\_FMab%3DpDjECCCmY%3Duw7T%2B%2BLKTtBgg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAFKmhPs_J2cERAobLMsKo_FMab%3DpDjECCCmY%3Duw7T%2B%2BLKTtBgg%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%3DcQChYR2YFJEvO\_G6LwcoULDfQRNBbuVFF5qnkaEYwAc2jQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQChYR2YFJEvO_G6LwcoULDfQRNBbuVFF5qnkaEYwAc2jQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![savioteles](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/savioteles/32/851_2.png) [@savioteles](https://discuss.elastic.co/u/savioteles)\
**Post date:** [May 19, 2014, 7:09pm UTC](https://discuss.elastic.co/t/why-is-the-java-api-query-slower-than-the-rest-call/17599/6 "2014-05-19T19:09:47Z")

</div>

> Why are you creating a JSON object for the query string query? You can  
> create a query builder object directly. Look at the same Java code on the  
> Elasticsearch site:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/search.html)
> 
> Instead of the term query, substitute a QueryStringQueryBuilder. Perhaps  
> the performance degradation is coming from the serializing/deserializing of  
> the JSON object.

I have to use the JSON object because the query is dynamic and sent by the  
client.

Default search type is QUERY\_THEN\_FETCH. Using DFS will have some

> performance impact, but in my testing it is negligible. Also, are you sure  
> you want DFS\_QUERY\*_AND_\*FETCH?

I've changed to QUERY\_THEN\_FETCH, but didn't work!

I calculated the time when calling the request. Like:

_long time = System.currentTimeMillis();_  
_SearchResponse response = request.execute().actionGet();_

_time = System.currentTimeMillis() - time;_

2014-05-19 15:49 GMT-03:00 Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com):

> Why are you creating a JSON object for the query string query? You can  
> create a query builder object directly. Look at the same Java code on the  
> Elasticsearch site:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/search.html)
> 
> Instead of the term query, substitute a QueryStringQueryBuilder. Perhaps  
> the performance degradation is coming from the serializing/deserializing of  
> the JSON object.
> 
> Default search type is QUERY\_THEN\_FETCH. Using DFS will have some  
> performance impact, but in my testing it is negligible. Also, are you sure  
> you want DFS\_QUERY\*_AND_\*FETCH?
> 
> --  
> Ivan
> 
> On Mon, May 19, 2014 at 11:25 AM, Sávio S. Teles de Oliveira \<  
> savio.teles@cuia.com.br\> wrote:
> 
> > Yes, the code is bellow:
> > 
> > _String query = ""query": {"query\_string": {"default\_operator":  
> > "AND","query": "new"}}";_  
> > _JSONObject jsonObject = new JSONObject(query);_  
> > _String jsonQuery = jsonObject.get("query").toString();_
> > 
> > _TermFilterBuilder termFilter = FilterBuilders.termFilter("state", "NY");_
> > 
> > _FacetBuilder facetBuilder =  
> > FacetBuilders.termsFacet("f").field("city").size(10);_  
> > _facetBuilder.facetFilter(termFilter);_
> > 
> > _SearchRequestBuilder request = client.prepareSearch("cities");_
> > 
> > _request.setQuery(QueryBuilders.wrapperQuery(jsonQuery));_
> > 
> > _request.addFacet(facetBuilder).setTypes(ATTR).setSearchType(SearchType.DFS\_QUERY\_AND\_FETCH).setFrom(0).setSize(0);_
> > 
> > _SearchResponse response = request.execute().actionGet();_
> > 
> > --  
> > 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/CAFKmhPs\_J2cERAobLMsKo\_FMab%3DpDjECCCmY%3Duw7T%2B%2BLKTtBgg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFKmhPs_J2cERAobLMsKo_FMab%3DpDjECCCmY%3Duw7T%2B%2BLKTtBgg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAFKmhPs\_J2cERAobLMsKo\_FMab%3DpDjECCCmY%3Duw7T%2B%2BLKTtBgg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAFKmhPs_J2cERAobLMsKo_FMab%3DpDjECCCmY%3Duw7T%2B%2BLKTtBgg%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 a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/h3g3cb2mGJM/unsubscribe](https://groups.google.com/d/topic/elasticsearch/h3g3cb2mGJM/unsubscribe).  
> To unsubscribe from this group and all its topics, 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%3DcQChYR2YFJEvO\_G6LwcoULDfQRNBbuVFF5qnkaEYwAc2jQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQChYR2YFJEvO_G6LwcoULDfQRNBbuVFF5qnkaEYwAc2jQ%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQChYR2YFJEvO\_G6LwcoULDfQRNBbuVFF5qnkaEYwAc2jQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQChYR2YFJEvO_G6LwcoULDfQRNBbuVFF5qnkaEYwAc2jQ%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).

--  
Atenciosamente,  
Sávio S. Teles de Oliveira  
voice: +55 62 9136 6996  
[http://br.linkedin.com/in/savioteles](http://br.linkedin.com/in/savioteles)  
Mestrando em Ciências da Computação - UFG  
Arquiteto de Software  
CUIA Internet Brasil

--  
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/CAFKmhPsUD7YGbq\_\_Y%2B6hPwu8%2By3rC6O%2By9w2vq2fpaFMwOkuYg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFKmhPsUD7YGbq__Y%2B6hPwu8%2By3rC6O%2By9w2vq2fpaFMwOkuYg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![zkidkid](https://avatars.discourse-cdn.com/v4/letter/z/fbc32d/32.png) [@zkidkid](https://discuss.elastic.co/u/zkidkid)\
**Post date:** [May 20, 2014, 8:31am UTC](https://discuss.elastic.co/t/why-is-the-java-api-query-slower-than-the-rest-call/17599/7 "2014-05-20T08:31:07Z")

</div>

Could u try change this:  
_QueryBuilders.wrapperQuery(jsonQuery ...)_  
to: QueryBuilders.filteredQuery(...)

Maybe there have some different between filter & query order.

--  
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/ad71ccd9-c780-491a-b814-6b597e85c2c6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ad71ccd9-c780-491a-b814-6b597e85c2c6%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![savioteles](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/savioteles/32/851_2.png) [@savioteles](https://discuss.elastic.co/u/savioteles)\
**Post date:** [May 20, 2014, 10:37am UTC](https://discuss.elastic.co/t/why-is-the-java-api-query-slower-than-the-rest-call/17599/8 "2014-05-20T10:37:00Z")

</div>

I can't use QueryBuilders.\*filteredQuery(...) \*because the client may sent  
a query or a filter or both. Therefore, i have to use  
_QueryBuilders.wrapperQuery(jsonQuery  
...)._

2014-05-20 5:31 GMT-03:00 kidkid [zkidkid@gmail.com](mailto:zkidkid@gmail.com):

> Could u try change this:  
> _QueryBuilders.wrapperQuery(jsonQuery ...)_  
> to: QueryBuilders.filteredQuery(...)
> 
> Maybe there have some different between filter & query order.
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/h3g3cb2mGJM/unsubscribe](https://groups.google.com/d/topic/elasticsearch/h3g3cb2mGJM/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/ad71ccd9-c780-491a-b814-6b597e85c2c6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ad71ccd9-c780-491a-b814-6b597e85c2c6%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/ad71ccd9-c780-491a-b814-6b597e85c2c6%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/ad71ccd9-c780-491a-b814-6b597e85c2c6%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Atenciosamente,  
Sávio S. Teles de Oliveira  
voice: +55 62 9136 6996  
[http://br.linkedin.com/in/savioteles](http://br.linkedin.com/in/savioteles)  
Mestrando em Ciências da Computação - UFG  
Arquiteto de Software  
CUIA Internet Brasil

--  
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/CAFKmhPtpTDq%2BgEtf4DM9epY3fCvkVUgzp9FVCkos3j4EWAzEBg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFKmhPtpTDq%2BgEtf4DM9epY3fCvkVUgzp9FVCkos3j4EWAzEBg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![savioteles](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/savioteles/32/851_2.png) [@savioteles](https://discuss.elastic.co/u/savioteles)\
**Post date:** [May 21, 2014, 11:20am UTC](https://discuss.elastic.co/t/why-is-the-java-api-query-slower-than-the-rest-call/17599/9 "2014-05-21T11:20:30Z")

</div>

Any idea?

2014-05-20 7:37 GMT-03:00 Sávio S. Teles de Oliveira \<  
savio.teles@cuia.com.br\>:

> I can't use QueryBuilders.\*filteredQuery(...) \*because the client may  
> sent a query or a filter or both. Therefore, i have to use _QueryBuilders.wrapperQuery(jsonQuery  
> ...)._
> 
> 2014-05-20 5:31 GMT-03:00 kidkid [zkidkid@gmail.com](mailto:zkidkid@gmail.com):
> 
> Could u try change this:
> 
> > _QueryBuilders.wrapperQuery(jsonQuery ...)_  
> > to: QueryBuilders.filteredQuery(...)
> > 
> > Maybe there have some different between filter & query order.
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/h3g3cb2mGJM/unsubscribe](https://groups.google.com/d/topic/elasticsearch/h3g3cb2mGJM/unsubscribe).  
> > To unsubscribe from this group and all its topics, 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/ad71ccd9-c780-491a-b814-6b597e85c2c6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ad71ccd9-c780-491a-b814-6b597e85c2c6%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/ad71ccd9-c780-491a-b814-6b597e85c2c6%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/ad71ccd9-c780-491a-b814-6b597e85c2c6%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Atenciosamente,  
> Sávio S. Teles de Oliveira  
> voice: +55 62 9136 6996  
> [http://br.linkedin.com/in/savioteles](http://br.linkedin.com/in/savioteles)  
> Mestrando em Ciências da Computação - UFG  
> Arquiteto de Software  
> CUIA Internet Brasil

--  
Atenciosamente,  
Sávio S. Teles de Oliveira  
voice: +55 62 9136 6996  
[http://br.linkedin.com/in/savioteles](http://br.linkedin.com/in/savioteles)  
Mestrando em Ciências da Computação - UFG  
Arquiteto de Software  
CUIA Internet Brasil

--  
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/CAFKmhPv\_pdKZAAzuFq8kvi8qr1veXgc5-ZZGH9hiPsH1rkSWBw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFKmhPv_pdKZAAzuFq8kvi8qr1veXgc5-ZZGH9hiPsH1rkSWBw%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:27am UTC](https://discuss.elastic.co/t/why-is-the-java-api-query-slower-than-the-rest-call/17599/10 "2017-07-06T01:27:53Z")

</div>


