# Fallback if field in \_source doesn't exist

**URL:** <https://discuss.elastic.co/t/fallback-if-field-in-source-doesnt-exist/374259>\
**Category:** Elastic Search\
**Created:** [February 8, 2025, 1:10pm UTC](https://discuss.elastic.co/t/fallback-if-field-in-source-doesnt-exist/374259 "2025-02-08T13:10:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![maganap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maganap/32/77245_2.png) [@maganap](https://discuss.elastic.co/u/maganap)\
**Post date:** [February 8, 2025, 1:10pm UTC](https://discuss.elastic.co/t/fallback-if-field-in-source-doesnt-exist/374259/1 "2025-02-08T13:10:45Z")

</div>

Hello!

I have documents that contain a text field, and a few translations in other fields.  
Some documents do have the original text, but are missing the translations.

I'm using a regular query and retrieving only the field I need according to the language, by using with `_source` field. I want to avoid retrieving both, the original and the requested translation every time.

Is there a way to retrieve a "fallback" field if the one used in `_source` does not exist?

Something like "retrieve `_source['text_es']` but fallback to `_source['text_en']` if `text_es` is `null`".

Thx!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 8, 2025, 4:14pm UTC](https://discuss.elastic.co/t/fallback-if-field-in-source-doesnt-exist/374259/2 "2025-02-08T16:14:55Z")

</div>

Welcome!

Have a look at [runtime fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/runtime.html). That could help.

---

<div class="post-metadata">

**Author:** ![maganap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maganap/32/77245_2.png) [@maganap](https://discuss.elastic.co/u/maganap)\
**Post date:** [February 9, 2025, 7:07pm UTC](https://discuss.elastic.co/t/fallback-if-field-in-source-doesnt-exist/374259/3 "2025-02-09T19:07:16Z")

</div>

That would definitively solve our issue! But I just noticed it's available since 7.12 and we're using a very old 7.8.  
We'll be upgrading to 8.x in the next few weeks so, I'll keep the ugly double field in our \_source until then.

Thank you very much for your help

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 9, 2025, 8:19pm UTC](https://discuss.elastic.co/t/fallback-if-field-in-source-doesnt-exist/374259/4 "2025-02-09T20:19:16Z")

</div>

Oh yes! It's urgent that you upgrade to at least 7.17 or better 8.17 😉

---

<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 9, 2025, 8:19pm UTC](https://discuss.elastic.co/t/fallback-if-field-in-source-doesnt-exist/374259/5 "2025-03-09T20:19:30Z")

</div>

Closed on March 9, 2025, 8:19pm UTC

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