# How to use filter\_path in java api?

**URL:** <https://discuss.elastic.co/t/how-to-use-filter-path-in-java-api/42844>\
**Category:** Elasticsearch\
**Created:** [February 26, 2016, 10:46am UTC](https://discuss.elastic.co/t/how-to-use-filter-path-in-java-api/42844 "2016-02-26T10:46:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![laigood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/laigood/32/30060_2.png) [@laigood](https://discuss.elastic.co/u/laigood)\
**Post date:** [February 26, 2016, 10:46am UTC](https://discuss.elastic.co/t/how-to-use-filter-path-in-java-api/42844/1 "2016-02-26T10:46:14Z")

</div>

I found in the doc that "All REST APIs accept a filter\_path parameter that can be used to reduce the response returned by elasticsearch". But I can't find this parameters in SearchRequestBuilder like other parameters.How can i use this function in java?Thinks

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [March 1, 2016, 9:13am UTC](https://discuss.elastic.co/t/how-to-use-filter-path-in-java-api/42844/2 "2016-03-01T09:13:07Z")

</div>

Hi,

when using the Java client API, you use either the [node or the transport client](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/client.html) which use another wire protocol. There is no REST client for Java and hence this option is not supported.

Note that Elasticsearch still reads all fields from the index. `filter_path` is just applied when a document is serialized to JSON.

Daniel

---

<div class="post-metadata">

**Author:** ![Akita](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Akita](https://discuss.elastic.co/u/Akita)\
**Post date:** [June 10, 2016, 12:41pm UTC](https://discuss.elastic.co/t/how-to-use-filter-path-in-java-api/42844/3 "2016-06-10T12:41:27Z")

</div>

Hi,

What about the class FilterPath I found here:  
[https://static.javadoc.io/org.elasticsearch/elasticsearch/2.3.0/org/elasticsearch/common/xcontent/support/filtering/FilterPath.html](https://static.javadoc.io/org.elasticsearch/elasticsearch/2.3.0/org/elasticsearch/common/xcontent/support/filtering/FilterPath.html)?

Can it be used to reduce the response? Or does this class have another purpose?  
I not sure to understand how it works.

Thanks

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [June 10, 2016, 1:20pm UTC](https://discuss.elastic.co/t/how-to-use-filter-path-in-java-api/42844/4 "2016-06-10T13:20:15Z")

</div>

Filter path is a rest layer thing. The transport client doesn't do rest so  
it isn't a thing. In 5.0 there are the beginnings of a rest client in Java  
and it'll have those options.

---

<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:44pm UTC](https://discuss.elastic.co/t/how-to-use-filter-path-in-java-api/42844/5 "2017-07-05T22:44:46Z")

</div>


