elasticsearch/elasticsearch — pull request #7850 by brwe (2014-09-24 07:24:15+00:00)
Title: significant terms: add scriptable significance heuristic

This commit adds scripting capability to significant_terms.
Custom heuristics can be implemented with a script that provides
parameters subset_freq, superset_freq,subset_size, superset_size.

Script heuristic and results have to be serialized. When deserializing the ScriptService is not available and the new score cannot be computed immediately after reading the result.
Therefore, instead of re-computing the score the score is serialized with each bucket.
For the reduce phase the script is initialized before buckets are reduced (https://github.com/brwe/elasticsearch/compare/elasticsearch:master...brwe:significant-terms-scripting?expand=1#diff-ba5a615f489137f2b16d37bc54dd3f8dR174) which seems a little clumsy to me. Happy for any suggestion.