This works fine, but in the result I have "total_goals" for each player, but not the first name and last name. How do I include the first and last name in the results ?
I forgot to tell one thing. The latter is not always better.
Script_fields are calculated for only matched document, while runtime mappings are calculated for all documents. Though this is the very reason that runtime mappings can be used for query and aggregation, if the index is huge and you query to filter few documents, script_fields could be much faster. In this case of match_all query, there is no difference in fact.
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.