Skip to content

[FEATURE] Support Multi search template API #2704

Closed
@gquintillan

Description

@gquintillan

It would be nice if org.springframework.data.elasticsearch.core.SearchOperations#multiSearch(java.util.List<? extends org.springframework.data.elasticsearch.core.query.Query>, java.lang.Class<T>) supports Multi Search Templates.

At the moment It is possible to use org.springframework.data.elasticsearch.core.query.SearchTemplateQuery like this:

private final ElasticsearchOperations elasticsearchOperations;

[...]

SearchTemplateQuery searchQueryA = SearchTemplateQuery.builder()
                .withId("search_query_template_id")
                .withParams(
                        Map.of(
                                "param_a", "value")))
                .build();
elasticsearchOperations.search(searchQueryA, CustomDoc.class);

But it would be nice to also be able to run Multi Search Templates like this:

private final ElasticsearchOperations elasticsearchOperations;

[...]

SearchTemplateQuery searchQueryA = SearchTemplateQuery.builder()
                .withId("search_query_template_id_a")
                .withParams(
                        Map.of(
                                "param_a", "value")))
                .build();

SearchTemplateQuery searchQueryB = SearchTemplateQuery.builder()
                .withId("search_query_template_id_b")
                .withParams(
                        Map.of(
                                "param_a", "value")))
                .build();

elasticsearchOperations.multiSearch(List.of(searchQueryA, searchQueryB), CustomDoc.class);

More info: https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-search-template.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions