I’m trying to generate an average for each player from an array that contains a match score in each position, but I get the following error:
“Field binding must be a pure unary function.”
I already created this type of index with another format without problems. But in this case the error response is as if I had a function with more than one input variable.
I couldn’t identify it.
I’m using this fql to create the index:
q.CreateIndex({
name: "average_attacks_per_match_by_season_id",
source: {
collection: q.Collection("statistics"),
fields: {
attacks: q.Query(
q.Lambda(
"doc",
q.Let(
{
per_match: q.Add(
q.Select(['data', 'scouts', 'attacks_per_match'],
q.Var('doc')
)
)
},
q.If(
q.IsEmpty( q.Var('per_match') ),
0,
q.Round(
q.Mean(
q.Var('per_match'),
),
3
)
)
)
)
)
}
},
terms: [{ field: ["data", "season_id"] }],
values: [
{ binding: "attacks", reverse:true },
{ field: ["data", "player_id"] },
{ field: ["data", "team_id"] },
]
})