I have a is_hit boolean in my docs, and would like to display the hit ratio in a data table or metric visualisation
Is it possible? How?
Basically it's the average of is_hit where true == 100 and false == 0 but i can't do average on boolean fields, only on numbers
I was able to do this with a scripted field. I didn't have a boolean handy, but using a numeric bytes field and the following painless script, I had a new is_big field that was either 0 or 100. I could then use that scripted field in a metrics agg:
It's good to be cautious when considering scripted fields as they will negatively impact performance when dealing with a large amount of data. I'm glad it works for your use case, though!
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.