# Parameters for match query

**URL:** <https://discuss.elastic.co/t/parameters-for-match-query/129454>\
**Category:** Elasticsearch\
**Created:** [April 25, 2018, 10:21am UTC](https://discuss.elastic.co/t/parameters-for-match-query/129454 "2018-04-25T10:21:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![devil\_srj7](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@devil\_srj7](https://discuss.elastic.co/u/devil_srj7)\
**Post date:** [April 25, 2018, 10:21am UTC](https://discuss.elastic.co/t/parameters-for-match-query/129454/1 "2018-04-25T10:21:36Z")

</div>

i have a java application in which I have implemented low level rest client.  
i define parameters in java in different variables and pass those in match query.  
As i take the parameters from user, if the user does not give any value i need to match to all the related to that match.

Ex.

int num\_office\_id= null;

take num\_office\_id from user;  
it can be a single value or multiple values  
like 3 or 3,4,5,6.

```
{
  "query": {
     "bool": {
       "must": [
         {"terms": {"num_office_id":num_office_id }},
       ]
     }
   },
   "aggs": {
     "sumofamount": {
       "sum": {
         "field": "num_amount"
       }
     }
   }
}

```

how can we implement these as required.

**Thanks**

---

<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:** [May 23, 2018, 10:21am UTC](https://discuss.elastic.co/t/parameters-for-match-query/129454/2 "2018-05-23T10:21:39Z")

</div>

Closed on May 23, 2018, 10:21am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
