How to modify the content of the field in source?

I want to process the query return value of the document in the source code and implement the following operations:

index:

{ "id": 1001,
"title":"abcd"
}

return:

{
"id": 1001,
"title": "bcde"
}

That is, replace the field, and the length of the string before and after the replacement is the same.

How to achieve this goal?

Welcome!

May be runtime fields could help. From the doc (emphasis is mine):

A runtime field is a field that is evaluated at query time. Runtime fields enable you to:

  • Add fields to existing documents without reindexing your data
  • Start working with your data without understanding how it’s structured
  • Override the value returned from an indexed field at query time
  • Define fields for a specific use without modifying the underlying schema