Scripted field

Hi all,
My index fields consists of

  1. index_name (containing P01, P02)
  2. X (numbers)

How can i scripted the field to display the subtracted result of P01 of X - P02 of X?
Thanks in advance.

Can you please show an example document and what the expected output would be?

Hi Christian,
X of P01 = 10
X of P02 = 8

Graph to show net value of X - 2

Thanks

That does not show the document structure. Scripted fields are limited to the scope of a single document, so if these values reside in different documents you will not be able to use scripted fields.

Apologies for late reply, hope this helps. Can I script to subtract X from different index_name in same index pattern?

"_source": {
"index_name": "P01",
},
"statistic_type": "count",
"x": 10

"_source": {
"index_name": "P02",
},
"statistic_type": "count",
"x": 2

Thanks.

No. Scripted fields require all data to be in a single document.

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