Skip to content

Add a hard way to refresh data #2722

Closed
@hantsy

Description

@hantsy

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()
  • ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions