I created a quite complicated request to ES (I send it via curl), so I wanted to add a bit of documentation to it. I read that JSON does not allow comments, but I put a comment of type /* ... */ inside the request and it succeeded. Can I assume that ES allows such comments inside JSON request?
I'm currently using ES 2.4.2, but I'm more interested if current and future versions will allow comments.
Or maybe I can send requests in other languages, for example YAML, that allows comments?
I'm aware that I can use some tool to remove comments before I send it to ES, but I wanted to get sure if I really need to do this.
My request looks like this (it does not make much sense because you can use avg metric instead).
{
"query" :
{
"match_all" : {}
},
"aggregations":
{
"avg_score":
{
"scripted_metric":
{
"init_script" :
/* comment */
"_agg['scores'] = []; _agg['count'] = 0",
"map_script" :
"_agg.scores.add(doc['score'].value); _agg.count += 1",
"combine_script" :
"sum = 0; for (s in _agg.scores) { sum += s }; return [sum, _agg.count]",
"reduce_script" :
"avg_sum = 0; avg_count = 0; for (a in _aggs) { avg_sum += a[0]; avg_count += a[1]; }; return avg_sum / avg_count"
}
}
}
}