elasticsearch-php icon indicating copy to clipboard operation
elasticsearch-php copied to clipboard

SmartSerializer is not smart enough

Open Cocray opened this issue 5 years ago • 1 comments

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

Cocray avatar Jan 16 '20 09:01 Cocray

This is the same issue as https://github.com/elastic/elasticsearch-php/issues/495#issuecomment-258533457

Pyker avatar Sep 02 '20 14:09 Pyker

Closing this since we have a new serializer for v8.

ezimuel avatar Aug 24 '22 07:08 ezimuel