2
votes

I have a badly designed document structure:

{
  "_index": "items",
  "_type": "item",
  "_id": "CD5D8F6516A88805FA826C10777B1750D9AAF5DA9CDD8E264757AB7EEC22B1EB",
  "_score": 1,
  "_source": {
  "title": "Textverständnis 5",
  "active": true,
  "successorId": null,
  "metadata": {
    "Fach": "DE",
    "Kompetenz": "Les",
    "code": "C_SX_DE_Les_A0016_00149_V00",
     ...
   }
  }
}

I would like to retrieve the the title, Fach, and code from the above document.

@Document(indexName = "items", type = "item")
@Data
public class Item {

   @Id
   private String id;
   private String title;
   private Metadata metadata;

   @Data
   static class Metadata {
     private String Fach;
     private String code;
   }

}

Retrieving the title, code are ok, but the Fach field returns null. Do you know how could I map this field? It seems the issue is with the upper case, but unfortunately I cannot change the document structure.

Could you help?

Thanks.

1

1 Answers

2
votes

was solved using Jackson's @JsonProperty annotation like:

@Document(indexName = "items", type = "item")
@Data
public class Item {

   @Id
   private String id;
   private String title;
   private Metadata metadata;

   @Data
   static class Metadata {

     @JsonProperty("Fach")
     private String subject;
     private String code;
   }

}