The new ES 1.0.0.RC1 that is out might have better ways to do this with aggregations BUT here is a simple (and very verbose) script that works:
POST /test_one/grades/_search
{
"query" : {
"match_all": {}
},
"filter" : {
"script" : {
"script" : " sum=0; foreach( grade : doc['grades'].values) { sum = sum + grade }; avg = sum/doc['grades'].values.length; avg > 25; "
}
}
}
Data I tested with:
POST /test_one/grades
{
"name": "chicken",
"grades": [35,55,65]
}
POST /test_one/grades
{
"name": "pork",
"grades": [15,35,45]
}
POST /test_one/grades
{
"name": "kale",
"grades": [5,10,20]
}