# How to do multiple filter query in Elasticsearch using Java?

**URL:** <https://discuss.elastic.co/t/how-to-do-multiple-filter-query-in-elasticsearch-using-java/54075>\
**Category:** Elasticsearch\
**Created:** [June 27, 2016, 8:37pm UTC](https://discuss.elastic.co/t/how-to-do-multiple-filter-query-in-elasticsearch-using-java/54075 "2016-06-27T20:37:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![njais2](https://avatars.discourse-cdn.com/v4/letter/n/258eb7/32.png) [@njais2](https://discuss.elastic.co/u/njais2)\
**Post date:** [June 27, 2016, 8:37pm UTC](https://discuss.elastic.co/t/how-to-do-multiple-filter-query-in-elasticsearch-using-java/54075/1 "2016-06-27T20:37:28Z")

</div>

I have build a web app on top of elasticsearch. I would like to do a multiple filter using Java.

Elasticsearch Query:

```
    {
  "query": {
    "bool": {
      "must": [
        {"match": {
          "T": "TEXT"},
              "match": {
                "new_content": "TEXT"
              }
            },
          
          ],
          "filter": {
            "term": {
              "collection": "xyz"
            },
            "term": {
              "collection": "abc"
            }

```

I want to filter the query such that it should filter on the same field `collection` with two different values(for eg,"xyz" and "abc")

Right now, I have coded a Java program for the single filter.

```
    BoolQueryBuilder boolQuery = QueryBuilders.boolQuery()
    				.must(QueryBuilders.simpleQueryStringQuery(query).field("newContent").field("T"))
    				.filter(QueryBuilders.termQuery(Collection, "abc"));

```

How should I filter a query on the same field for multiple values?

---

<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 5, 2017, 10:40pm UTC](https://discuss.elastic.co/t/how-to-do-multiple-filter-query-in-elasticsearch-using-java/54075/2 "2017-07-05T22:40:06Z")

</div>


