Fallback if field in _source doesn't exist

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!

Welcome!

Have a look at runtime fields. That could help.

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

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

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