spring-data-examples icon indicating copy to clipboard operation
spring-data-examples copied to clipboard

Feature Suggestion: Add an example for updating a document

Open omniCoder77 opened this issue 5 months ago • 3 comments

Hi there,

I was going through the spring-data-elasticsearch-examples and found them incredibly helpful for getting started. I noticed that the examples cover creating, searching, and deleting documents really well, which is great for the basic CRUD operations.

However, I couldn't find a clear example of how to update an existing document. For someone learning the ropes, seeing the standard pattern for "get a document, change something, and save it back" would be super useful and would make the examples feel more complete.

I have a couple of ideas on how this could be added cleanly:

  • A new test in ElasticsearchOperationsTest.java that finds a conference, adds a new keyword to it, saves it, and then checks that the update worked.
  • The same kind of test in ReactiveElasticsearchOperationsTest.java to show how it's done in the reactive world.

This seems like a straightforward way to demonstrate a really common use case without cluttering the main application code.

I'd be more than happy to put together a pull request for this if you think it's a good idea. Let me know what you think!

omniCoder77 avatar Jul 25 '25 04:07 omniCoder77

Hi, just wanted to gently follow up on this. Still happy to contribute a PR if this is a feature you'd be interested in. Thanks!

omniCoder77 avatar Aug 08 '25 19:08 omniCoder77

Thanks for reaching out. There's lots of vacation going on and this one slipped. Feel free to submit a pull request, ideally using the ElasticSearchTemplate because the repository-based approach (findById) is covered by other modules to a great extent.

mp911de avatar Aug 11 '25 06:08 mp911de

Thank you so much for the feedback and the green light! That makes perfect sense. I will work on a pull request that uses ElasticsearchTemplate to demonstrate the update functionality as you suggested. I'll link it to this issue when it's ready.

omniCoder77 avatar Aug 11 '25 07:08 omniCoder77