Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a hard way to refresh data #2722

Closed
hantsy opened this issue Oct 8, 2023 · 1 comment · Fixed by #2725
Closed

Add a hard way to refresh data #2722

hantsy opened this issue Oct 8, 2023 · 1 comment · Fixed by #2725
Labels
type: enhancement A general enhancement

Comments

@hantsy
Copy link

hantsy commented Oct 8, 2023

Spring Boot still does not provides a property to configure the refresh policy, see: spring-projects/spring-boot#30379

I have to configure the RefreshPolicy to IMMEDIATE through the Spring Data base configuration class to make my Data Elasticsearch example tests to get passed.

If possible to add a refresh method into the ElasticsearchRepository/ElasticsearchOperations(both blocking and reactive) to allow developers to sync the data by force, make it available for search after the refresh is called.

interface PostRepository extends ReactiveElasticsearchRepository<Post, String> {
}

// posts is PostRepository bean
this.posts
      .saveAll(
            List.of(
                  Post.builder().title("Post one").content("content of post one").build(),
                  Post.builder().title("Post two").content("content of post two").build()
            )
      )
      .doOnTerminate(() -> {
          log.debug("terminating...");
          this.posts.refresh().then(); // sync the indices by force.
      })
      .doOnComplete(() -> {
          log.debug("completing...");
      })
      .subscribe(data -> {
          log.debug("saved data: {}", data);
      });

Similar to the flush in JPA and Spring Data JPA, add some convenient methods to ElasticsearchRepository/ElasticsearchOperations.

  • saveAndRefresh()
  • saveAllAndRefresh()
  • refresh()
  • bulkUpdateAndRefresh()
  • ...
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 8, 2023
sothawo added a commit that referenced this issue Oct 11, 2023
Original Pull Request #2725
Closes #2722
@sothawo sothawo added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 11, 2023
@sothawo sothawo added this to the 5.2 RC1 (2023.1.0) milestone Oct 11, 2023
@sothawo
Copy link
Collaborator

sothawo commented Oct 11, 2023

see description of PR #2725

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants