Search⌘ K
AI Features

Auditing

Explore auditing in Spring Data Elasticsearch to automatically track metadata like creation and modification timestamps, and user information. Understand how to annotate document classes and configure AuditorAware to enhance data governance and maintain traceability in your applications.

Auditing in Spring Data Elasticsearch involves automatically tracking and managing metadata changes in indexed documents. It captures details like creation, modification timestamps, and user identifiers, enhancing data governance, traceability, and compliance. Auditing enables robust record-keeping and historical analysis in Elasticsearch-based applications.

Auditing metadata in document classes

First, let’s add a few properties in the POJOs that map the auditing metadata field in the database.

The Book document

Let’s add properties like createdBy, dateCreated, updatedBy, and dateUpdated to the Book class. The underlying Spring Data Elasticsearch will take care of updating the datastore with the corresponding fields in the book document. ...