# Query conatining multiple fields

**URL:** <https://discuss.elastic.co/t/query-conatining-multiple-fields/22851>\
**Category:** Elasticsearch\
**Created:** [March 24, 2015, 10:55am UTC](https://discuss.elastic.co/t/query-conatining-multiple-fields/22851 "2015-03-24T10:55:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![4m7u1](https://avatars.discourse-cdn.com/v4/letter/4/8e7dd6/32.png) [@4m7u1](https://discuss.elastic.co/u/4m7u1)\
**Post date:** [March 24, 2015, 10:55am UTC](https://discuss.elastic.co/t/query-conatining-multiple-fields/22851/1 "2015-03-24T10:55:20Z")

</div>

Hi, This is a part of source in elasticsearch index.

"\_source": {  
"InvoiceId": "a",  
"InvoiceNum": "b",  
"LastUpdatedBy": "FINUSER1",  
"SetOfBooksId": "1",  
"LastUpdateDate": "2015-03-20 18:31:16.592",  
"VendorId": "5",  
"InvoiceAmount": "1200",  
"InvoiceCurrencyCode": "USD",  
"AmountPaid": "NotFound",  
"PaymentCurrencyCode": "USD",  
}  
I need to query on multiple inputs using the JAVA API, for example say I  
have provided "InvoiceId" "InvoiceNum" as "a" and "b" .  
How can I query using these multiple inputs? I want a single response for  
this.  
One thing I came across was

MultiSearchResponse sr =  
client.prepareMultiSearch().add(srb1).add(srb2).execute().actionGet(); where  
SearchRequestBuilder srb1 =  
client.prepareSearch("dbdata2").setTypes("invoices2").setQuery(QueryBuilders.matchQuery("InvoiceId",  
"a"));  
SearchRequestBuilder srb2 =  
client.prepareSearch("dbdata2").setTypes("invoices2").setQuery(QueryBuilders.matchQuery("InvoiceNum","b"));

but these return individual results. Is there any way I can get a single  
output?

--  
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/4105c392-462a-4902-a762-c92dc92663ea%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4105c392-462a-4902-a762-c92dc92663ea%40googlegroups.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, 12:24am UTC](https://discuss.elastic.co/t/query-conatining-multiple-fields/22851/2 "2017-07-06T00:24:31Z")

</div>

Closed on July 6, 2017, 12:24am UTC


