Map absolute values to relative ones and store them in a new (transient) field

Hello guys,

I have recently gotten a requirement for an existing search functionality. I have gone through the official docs but haven't found a functionality which would work for this specific use case.

In my index, the records hold a score field which is a number.

The requirement is to convert these values from absolute values to values relative between records when querying. Conversion would need to happen after query execution, since the relative values depend on the number of records.

This new value represents a priority based on the score, highest priority being 1 and going from 1 to n, n being the number of records. Optimally these relative values would be saved to a new transient field.

data being queried: [{"score": 29.4},{"score": 153.2},{"score": 76.0}]
result set: [{"score": 29.4,"prio": 3},{"score": 153.2, "prio": 1},{"score": 76.0, "prio": 2}]

I query the data with pagination ( from / size ), which means querying all records and then mapping absolute values to relative ones client side would make an unacceptable performance hit.

Any idea or hint would be much appreciated.


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