I need to calculate the weighted sums of sets of documents. The weight is based on the fields of the document so I'm using scripts, in a particular a sum aggregation with a script inside filter aggregations. The weights are fixed per call (i.e. all the sum aggregations use the exact same script and pararms).
I have implemented this but I'm not completely satisfied with the solution for 2 reasons:
The script runs multiple times for the same document (for every filter the document matches).
I need to pass the parameters for the script multiple times. This param object could get quite big, and I don't want to risk hitting ES max request size.
I think it would help greatly if you shared the requests you created, so people could get a feeling what you are after.
Also, do you think it is possible to precalculate anything of this before storing the document, so you could add it to the document itself to be faster on the query side?
About your suggestion - the weights are determined by the user, and not on index time (and it's very possible a later request will have different weights on the exact same data), so sadly no.
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.