# Use ElasticSearch API to provide json filter

**URL:** https://discuss.elastic.co/t/use-elasticsearch-api-to-provide-json-filter/23192
**Category:** Elasticsearch
**Created:** [April 10, 2015, 6:28pm UTC](https://discuss.elastic.co/t/use-elasticsearch-api-to-provide-json-filter/23192 "2015-04-10T18:28:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![prateek](https://avatars.discourse-cdn.com/v4/letter/p/ee7513/32.png) [@prateek](https://discuss.elastic.co/u/prateek)
#### Post date: [April 10, 2015, 6:28pm UTC](https://discuss.elastic.co/t/use-elasticsearch-api-to-provide-json-filter/23192/1 "2015-04-10T18:28:24Z")

</div>

I am having requirement where in I need to use filter specified in json  
through elasticsearch Java API.

for example below elasticsearch json filter needs to be used through Java  
API:  
"filter" : {  
"bool" : {  
"should" : [  
{ "term" : {"productID" : "KDKE-B-9947-#kL5"}},  
{ "bool" : {  
"must" : [  
{ "term" : {"productID" : "JODL-X-1937-#pV7"}},  
{ "term" : {"price" : 30}}  
]  
}}  
]  
}  
}

I have explored SearchRequestBuilder.setExtraSource and  
SearchRequestBuilder.setSearchType but they do not solve the above issue.  
How would I go about it?

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/fa5ffb7c-f6f4-474a-80c0-2c0e67a81b5b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fa5ffb7c-f6f4-474a-80c0-2c0e67a81b5b%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:20am UTC](https://discuss.elastic.co/t/use-elasticsearch-api-to-provide-json-filter/23192/2 "2017-07-06T00:20:19Z")

</div>


