Parameters for match query

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

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