Maybe to speed up sorting, you can save in the field definition how it should behave when storing values. So eventually he would remember only one field, max, min, avg, etc ... Later sorting would consist of reading only one field. It would be a good solution in a flat model. This would speed up document search. Indexing the field in such a way would prevent you from choosing a different aggregation method, but it is not always necessary for everyone. So the user would decide between search performance and subsequent dynamic search capability.
@GenericField(name = "bruttoPrice_sort", sortable = Sortable.YES, mode = MultiValue.AVG)
The user would have to choose whether to remember the calculated value or to calculate it during sorting. As for calculating values, median counting for nested multiple values is inefficient. This requires creating an array with the number of nested value elements in order to sort it. So calculating values when creating an index would be the solution here. Some functions, especially those that pull values up to aggregation, can be simplified for multiple nested values. So that he doesn't use ArrayList. |