I need to perform math functions on fields with different timestamps. For example, current value of field x, qualified by its size and the last valid value of field y:
Are x and y part of the same document or are they stored as individual docs? You say, they have different timestamp, which makes me think you talk about individual docs.
I think it will be easier for me and others if you can provide an example with input doc(s) and the expected output.
Thank you for your reply. They are part of the same index; however, different document, i.e., were received through 2 different jsons, e.g., {"x":vlaue_1, ...} and {"y":value_2,...}.
In this case you won't be able to solve your use case with a scripted field, a scripted field can not work over 2 documents, but only within the same document. With other words, a scripted field would only work if x and y are part of the same document.
In order to combine docs you need aggregations. Do the docs you want to combine share a field with the same value, e.g. an id? In this case you would group the docs using that id (e.g. with a terms aggregation) and use another aggregation to combine x and y.
For large data sets, you need a composite aggregation, if you aim for persisting the result in an index again - as a new document - you can use a transform.
Thank you for your prompt reply. Documents do share a common unique field, would you be able to point to an example, for aggragation templating purposes?
Cheers,
You can check this discuss post, this is about merging 2 documents. Conceptually you want the same but in addition you want to apply a calculation. In a nutshell you need to get the values for x and y in the map phase and do the calculation in the reduce phase.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.