# How to retrieve stored fields using spring-data-opensearch with \_source disabled?

**URL:** <https://forum.opensearch.org/t/how-to-retrieve-stored-fields-using-spring-data-opensearch-with-source-disabled/19314>\
**Category:** OpenSearch Client Libraries\
**Tags:** opensearch-java\
**Created:** [May 11, 2024, 5:18pm UTC](https://forum.opensearch.org/t/how-to-retrieve-stored-fields-using-spring-data-opensearch-with-source-disabled/19314 "2024-05-11T17:18:56Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![gaobinlong](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/gaobinlong/32/5242_2.png) [@gaobinlong](https://forum.opensearch.org/u/gaobinlong)\
**Post date:** [May 12, 2024, 5:28am UTC](https://forum.opensearch.org/t/how-to-retrieve-stored-fields-using-spring-data-opensearch-with-source-disabled/19314/2 "2024-05-12T05:28:49Z")

</div>

I think for your case, when constructing `NativeSearchQuery`, `withStoredFields` should be used instead of `withFields`:

```auto
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder()
        .withQuery(QueryBuilders.termQuery("_id", documentId))
        .withStoredFields(storedFields)
        .build();

```

---

_[View the full topic](https://forum.opensearch.org/t/how-to-retrieve-stored-fields-using-spring-data-opensearch-with-source-disabled/19314)._
