spring-projects / spring-data-elasticsearch

Provide support to increase developer productivity in Java when using Elasticsearch. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-elasticsearch/
Apache License 2.0
2.9k stars 1.33k forks source link

Question. Could you share any docs for dirty checking for Spring ElasitcSearch Data #2970

Closed codeleeks closed 1 week ago

codeleeks commented 3 weeks ago

Hello. i'm testing spring-data-elasticsearch for my project.

recently it seems like spring-data-elasticsearch doesn't support dirty checking.

@Service
@Transactional
@RequiredArgsConstructor
public class PostIndexService {
    private final PostIndexRepository postIndexRepository;

    public void update(Post post) {
        PostIndex postIndex = postIndexRepository.findByPostId(post.getId())
                .orElseThrow(IllegalArgumentException::new);
        postIndex.setTitle(post.getTitle());
// without following line, it doesn't update fields in elastic search db.
//        postIndexRepository.save(postIndex)
    }

could you share any official docs about this dirty checking? i want to make sure it is true. i wonder if any misconfiguration might apply in my project.

Also, if you have time, please organize differences between RDB based spring data and spring-data-elasticsearch. i wonder if there are few more differences like this dirty checking. i want to avoid unnecessary debugging.

sothawo commented 3 weeks ago

There is no dirty checking; a save call should send the data to Elasticsearch no matter if it existed before or not. How do you check if the document in Elasticsearch is modified? Have you any special refresh settings active? If this is reproducible provide a runnable minimal example that shows this behavior.

spring-projects-issues commented 2 weeks ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues commented 1 week ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.