elasticsearch-php
elasticsearch-php copied to clipboard
SmartSerializer is not smart enough
Summary of problem or feature request
The file SmartSerializer.php encode $data into a json string if this variable is an array. If it is an empty array, you transform it into '{}' and that's ok (line 38 of this file). But sometimes, if it's not empty, you can have inside a part which is an empty array, like in Global Aggragations:
{
...,
"aggs": {
"all_documents": {
"global": {}, <---- ES waits this value, but json_encode will return "global": []
"aggs": {
...
}
}
},
...
}
I think you should replace each string '[]' into '{}'.
Thanks a lot
System details
- PHP Version 7.3
- ES-PHP client version 7.4
- Elasticsearch version 7.4
This is the same issue as https://github.com/elastic/elasticsearch-php/issues/495#issuecomment-258533457
Closing this since we have a new serializer for v8.