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

There is no multiSearch method provided by ReactiveElasticsearchOperations in Spring Data Elasticsearch v4

Open vishalgoel2 opened this issue 2 years ago • 4 comments
trafficstars

Expected behavior I expect ReactiveElasticsearchOperations to provide a multiSearch method that can perform a multi-search request using the reactive Elasticsearch client.

Actual behavior Currently, there is no multiSearch method provided by ReactiveElasticsearchOperations.

Workaround As a workaround, one can use the StringQuery and create a JSON string that represents a multi-search request. However, this workaround requires manual construction of the multi-search request JSON string, which can be error-prone and cumbersome for complex multi-search requests.

Proposal I propose to add a multiSearch method to ReactiveElasticsearchOperations that can perform a multi-search request using the reactive Elasticsearch client. This method should simplify the construction of multi-search requests and improve the overall developer experience.

Additional context Multi-search requests are an important feature of Elasticsearch, and their absence in the reactive Spring Data Elasticsearch v4 library limits the functionality and flexibility of reactive Elasticsearch applications. It is also worth noting that the non-reactive version of Spring Data Elasticsearch already supports multiSearch.

vishalgoel2 avatar Mar 07 '23 10:03 vishalgoel2

Note: This would probably need to return a Flux<ReactivSearchHits<T>>.

sothawo avatar Mar 07 '23 11:03 sothawo

This won't definitely not be added to version 4, as 5.0 is already released, and new features are not backported to old versions.

sothawo avatar Mar 07 '23 11:03 sothawo

Would upgrading to Spring Data Elasticsearch 5 require us to adopt Spring Boot 3 and Spring 6? We may not be ready for this upgrade yet and need to evaluate our readiness before making any decisions. Is there any other workaround available for version 4 of the library, other than manually creating a JSON string? For instance, could we create a list of NativeSearchQuery objects and transform it into a StringQuery object instead?

vishalgoel2 avatar Mar 07 '23 12:03 vishalgoel2

Would upgrading to Spring Data Elasticsearch 5 require us to adopt Spring Boot 3 and Spring 6?

yes. But this feature would need to be implemented ayway first.

The problem with creating some string query or other work around is, that a multisearch can return different entities for the different queries, that would not be handled.

sothawo avatar Mar 07 '23 13:03 sothawo