Should i use emit() when using runtime field

Hello, i'm trying to sum 2 fields in index template using runtime field. Currently, my script is like this: doc['a'].value + doc['b'].value. Do i need to emit like this: emit(doc['a'].value + doc['b'].value) so that the new field gets populated with the sum of a and b or is it enough without emit?

You will need to use emit to return the values. There's more detail here on painless runtime fields if that helps.

1 Like

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