core icon indicating copy to clipboard operation
core copied to clipboard

Elasticsearch Denormalizer returns null for fields composed of two ore more words (ex. firstName)

Open imaximius opened this issue 4 years ago • 3 comments

API Platform version(s) affected: 2.6.3

Description
As mentioned in summary there is an issue with getting data form Elasticsearch. It reproduced when I tried to get data for fields that composed of several words (ex. firstName, createdAt etc.) Result the same for jsonld and graphql normalizers and for nested objects as well.

How to reproduce

  1. Enable support for Elasticsearch
  2. Create model and field with two words name
  3. Store some data
  4. Try to get data by using jsonld or graphql formats
  5. Result for fields with two words name will be empty

Possible Solution
There is could be a bug with comparing allowedAttributes to attributes from ES result. Method getAllowedAttributes of AbstractObjectNormalizer returns allowed attributes in camel case whereas attributes in ES source wrote in snake_case

imaximius avatar Feb 11 '21 14:02 imaximius

I think we definitely have a problem with documents with fields in snake case (cf. https://github.com/api-platform/docs/pull/1204#issuecomment-767554491). I will investigate this in the next few weeks.

meyerbaptiste avatar Feb 11 '21 14:02 meyerbaptiste

Thanks a lot. I'll be waiting

imaximius avatar Feb 11 '21 14:02 imaximius

@imaximius i can confirm issue comes from getAllowedAttributes comparison (snakeCase in ES vs CameCasel in models) @meyerbaptiste got ideas to solve this ?

Regards

lwillems avatar Mar 02 '22 16:03 lwillems