2

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 Answer 1

2

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;
   }

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.