Ignore JsonIgnore in Elasticsearch Ignore JsonIgnore in Elasticsearch elasticsearch elasticsearch

Ignore JsonIgnore in Elasticsearch


You could use Jackson JsonView for your purpose. You can define one view which will be used to serialize pojo for the application user :

Create the views as class, one public and one private:

class Views {         static class Public { }         static class Private extends Public { }}

Then uses the view in your Pojo as an annotation:

@Id@JsonView(Views.Private.class) String name;private Long id;@JsonView(Views.Public.class) String name;private String publicField;

and then serialize your pojo for the application user using the view:

objectMapper.writeValueUsingView(out, beanInstance, Views.Public.class);

This is one example of many others on how view can fit your question. Eg. you can use too objectMapper.configure(SerializationConfig.Feature.DEFAULT_VIEW_INCLUSION, false); to exclude field without view annotation and remove the Private view.