# ES 1.0.0 Source filtering using the Java API

**URL:** <https://discuss.elastic.co/t/es-1-0-0-source-filtering-using-the-java-api/16014>\
**Category:** Elasticsearch\
**Created:** [February 25, 2014, 5:05pm UTC](https://discuss.elastic.co/t/es-1-0-0-source-filtering-using-the-java-api/16014 "2014-02-25T17:05:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [February 25, 2014, 5:05pm UTC](https://discuss.elastic.co/t/es-1-0-0-source-filtering-using-the-java-api/16014/1 "2014-02-25T17:05:25Z")

</div>

I'm migrating to 1.0.0 and a few of my queries are broken because I am  
using the 'fields' parameter. I understand I need to use source filtering  
as per the link below but his there support for source filtering using the  
Java AP yetI?

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-request-source-filtering.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-request-source-filtering.html)

--  
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/b65acf48-c13d-4d64-ad4b-a95aa47b89c9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b65acf48-c13d-4d64-ad4b-a95aa47b89c9%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [February 25, 2014, 8:41pm UTC](https://discuss.elastic.co/t/es-1-0-0-source-filtering-using-the-java-api/16014/2 "2014-02-25T20:41:37Z")

</div>

Yes you can use the client.setFetchSource() method:

```
  SearchResponse response = client.prepareSearch("index")
    .setFetchSource(new String[] {"field1", "field2"}, null)
    .execute()
    .actionGet();

```

--  
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/0de2a992-2397-476d-8a96-345026b60aae%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0de2a992-2397-476d-8a96-345026b60aae%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [February 25, 2014, 9:22pm UTC](https://discuss.elastic.co/t/es-1-0-0-source-filtering-using-the-java-api/16014/3 "2014-02-25T21:22:22Z")

</div>

Thanks for your response.I can't see the method 'setFetchSource' in the  
Client class. Are you sure that is in 1.0.0?

On Tuesday, February 25, 2014 8:41:37 PM UTC, Binh Ly wrote:

> Yes you can use the client.setFetchSource() method:
> 
> ```
> SearchResponse response = client.prepareSearch("index")
> .setFetchSource(new String[] {"field1", "field2"}, null)
> .execute()
> .actionGet();
> 
> ```

--  
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/d9b1aa0b-80f8-49a8-9f50-5e54db05562c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d9b1aa0b-80f8-49a8-9f50-5e54db05562c%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [February 25, 2014, 10:23pm UTC](https://discuss.elastic.co/t/es-1-0-0-source-filtering-using-the-java-api/16014/4 "2014-02-25T22:23:46Z")

</div>

Hmmm, can please double-check. I can see it from the tests here:

> <https://github.com/elastic/elasticsearch/blob/v1.0.0/src/test/java/org/elasticsearch/search/source/SourceFetchingTests.java>

--  
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/a0676082-5638-4f16-b5b7-76fb42ac2a5e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a0676082-5638-4f16-b5b7-76fb42ac2a5e%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [February 25, 2014, 10:49pm UTC](https://discuss.elastic.co/t/es-1-0-0-source-filtering-using-the-java-api/16014/5 "2014-02-25T22:49:07Z")

</div>

Yes, I can see it. Thanks.

> On 25 Feb 2014, at 22:23, Binh Ly [binhly\_es@yahoo.com](mailto:binhly_es@yahoo.com) wrote:
> 
> Hmmm, can please double-check. I can see it from the tests here:
> 
> ## [https://github.com/elasticsearch/elasticsearch/blob/v1.0.0/src/test/java/org/elasticsearch/search/source/SourceFetchingTests.java](https://github.com/elasticsearch/elasticsearch/blob/v1.0.0/src/test/java/org/elasticsearch/search/source/SourceFetchingTests.java)
> 
> 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/a0676082-5638-4f16-b5b7-76fb42ac2a5e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a0676082-5638-4f16-b5b7-76fb42ac2a5e%40googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/9E1DEA66-32A9-4AFC-B0EB-C5507A72B266%40gmail.com](https://groups.google.com/d/msgid/elasticsearch/9E1DEA66-32A9-4AFC-B0EB-C5507A72B266%40gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:47am UTC](https://discuss.elastic.co/t/es-1-0-0-source-filtering-using-the-java-api/16014/6 "2017-07-06T01:47:19Z")

</div>


