Hello,
I’m having some performance issues using the min function and geodist. The exists check performed by MinFloatFunction can cause this to be evaluated three times if it’s the first clause in the min or twice for the others. Example sort function: min(if(lte(20,geodist()),13,15),13,27) There were some notes <https://github.com/apache/lucene/commit/d8146460f0eca4641f0e48793b6053a88be5c7d1#diff-cdd1ae1b418ea74ca689c6e68e61f4e5b4c6f77f6408a4e6cf76ed8421b24d09R97> from when the exists check was added that suggests wrapping with `def` but that seems to make it worse not better. I’ve made a small project to highlight the issue at https://github.com/davwil00/solr-sort-test/ There is a single test class which prints out the number of times the haversine distance is calculated. Given the relative expense of the geodist calculations, any assistance in reducing the number of repeated calls would be appreciated. I can avoid the 3 calls by using a different first clause but it will still be evaluated twice. Thanks, David