# Dynamic list of fields to be returned in search

**URL:** <https://discuss.elastic.co/t/dynamic-list-of-fields-to-be-returned-in-search/119699>\
**Category:** Elasticsearch\
**Created:** [February 13, 2018, 7:35pm UTC](https://discuss.elastic.co/t/dynamic-list-of-fields-to-be-returned-in-search/119699 "2018-02-13T19:35:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hariso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hariso/32/50668_2.png) [@hariso](https://discuss.elastic.co/u/hariso)\
**Post date:** [February 13, 2018, 7:35pm UTC](https://discuss.elastic.co/t/dynamic-list-of-fields-to-be-returned-in-search/119699/1 "2018-02-13T19:35:30Z")

</div>

Is it possible to configure Elasticsearch so that it returns different fields for different documents, based on some criteria?  
For example: if a field called "foo" \>= 40, then return all fields. If not, return all fields except field "bar"?

The context for this is following: I am reindexing data from an ES 1.7 index into ES 5.6. Due to a bug, ES 1.7 contains documents which are huge (several hundreds of MBs). Because of that, ES 5.6 cannot get done with reindexing, since its internal buffer is [limited to "only" 200 MB](https://github.com/elastic/elasticsearch/pull/21222) and is [not configurable](https://github.com/elastic/elasticsearch/issues/21185).

While I could do what Nik proposed in [a comment on Github](https://github.com/elastic/elasticsearch/issues/21185#issuecomment-287114580), i.e. reindexing in 2 passes, I wonder if there is an easier way to do that. If I could simply omit the huge fields from the source, that would simplify reindexing significantly.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [February 16, 2018, 5:23pm UTC](https://discuss.elastic.co/t/dynamic-list-of-fields-to-be-returned-in-search/119699/2 "2018-02-16T17:23:48Z")

</div>

> [@hariso](#):
>
> While I could do what Nik proposed in a comment on Github, i.e. reindexing in 2 passes, I wonder if there is an easier way to do that.

I think this IS the easiest way to do that.

---

<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:** [March 16, 2018, 5:24pm UTC](https://discuss.elastic.co/t/dynamic-list-of-fields-to-be-returned-in-search/119699/3 "2018-03-16T17:24:18Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
