# How to add more than one term query in Java API?

**URL:** <https://discuss.elastic.co/t/how-to-add-more-than-one-term-query-in-java-api/14623>\
**Category:** Elasticsearch\
**Created:** [November 28, 2013, 6:40am UTC](https://discuss.elastic.co/t/how-to-add-more-than-one-term-query-in-java-api/14623 "2013-11-28T06:40:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Guo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniel_guo/32/1725_2.png) [@Daniel\_Guo](https://discuss.elastic.co/u/Daniel_Guo)\
**Post date:** [November 28, 2013, 6:40am UTC](https://discuss.elastic.co/t/how-to-add-more-than-one-term-query-in-java-api/14623/1 "2013-11-28T06:40:11Z")

</div>

Term query in Java API looks like:

SearchResponse searchResponse = client.prepareSearch("rank", "feedback").  
setQuery(QueryBuilders.termQuery("RANK\_LIST\_ID", "1")).execute().actionGet  
();

If I need more than one term query, how do I add them to the QueryBuilders?  
Thanks.

--  
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/46c35fad-d6f5-4700-9202-baa0337c03fa%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/46c35fad-d6f5-4700-9202-baa0337c03fa%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 28, 2013, 6:48am UTC](https://discuss.elastic.co/t/how-to-add-more-than-one-term-query-in-java-api/14623/2 "2013-11-28T06:48:07Z")

</div>

With a BoolQuery?

BTW, in your example, I would probably use a TermFilter instead a TermQuery.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 28 nov. 2013 à 07:40, Daniel Guo [daniel5hbs@gmail.com](mailto:daniel5hbs@gmail.com) a écrit :

Term query in Java API looks like:

SearchResponse searchResponse = client.prepareSearch("rank", "feedback").setQuery(QueryBuilders.termQuery("RANK\_LIST\_ID", "1")).execute().actionGet();

## If I need more than one term query, how do I add them to the QueryBuilders? Thanks.

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/46c35fad-d6f5-4700-9202-baa0337c03fa%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/46c35fad-d6f5-4700-9202-baa0337c03fa%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/45B259F6-C2F0-4AF8-B16F-D73D0388EEE7%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/45B259F6-C2F0-4AF8-B16F-D73D0388EEE7%40pilato.fr).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Daniel\_Guo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniel_guo/32/1725_2.png) [@Daniel\_Guo](https://discuss.elastic.co/u/Daniel_Guo)\
**Post date:** [November 28, 2013, 7:20am UTC](https://discuss.elastic.co/t/how-to-add-more-than-one-term-query-in-java-api/14623/3 "2013-11-28T07:20:40Z")

</div>

I'm trying on it, thanks.

On Thursday, November 28, 2013 2:48:07 PM UTC+8, David Pilato wrote:

> With a BoolQuery?
> 
> BTW, in your example, I would probably use a TermFilter instead a  
> TermQuery.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 28 nov. 2013 à 07:40, Daniel Guo \<[danie...@gmail.com](mailto:danie...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> Term query in Java API looks like:
> 
> SearchResponse searchResponse = client.prepareSearch("rank", "feedback").  
> setQuery(QueryBuilders.termQuery("RANK\_LIST\_ID", "1")).execute().actionGet  
> ();
> 
> If I need more than one term query, how do I add them to the  
> QueryBuilders? Thanks.
> 
> --  
> 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/46c35fad-d6f5-4700-9202-baa0337c03fa%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/46c35fad-d6f5-4700-9202-baa0337c03fa%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/fcd92e28-620a-472c-9789-3c47a4b18b54%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fcd92e28-620a-472c-9789-3c47a4b18b54%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:04am UTC](https://discuss.elastic.co/t/how-to-add-more-than-one-term-query-in-java-api/14623/4 "2017-07-06T02:04:23Z")

</div>


