elastic / elasticsearch-net

This strongly-typed, client library enables working with Elasticsearch. It is the official client maintained and supported by Elastic.
https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html
Apache License 2.0
11 stars 1.15k forks source link

Make it possible to do a MultiSearch with different types #8355

Open erik-kallen opened 1 month ago

erik-kallen commented 1 month ago

Is your feature request related to a problem? Please describe. Unless I'm missing something, it appears to not be possible to perform a multisearch/multiget with different types from different indices in the same request

Describe the solution you'd like

Something like

var response = await _client.MultiSearchAsync(req =>
{
    req.AddSearch<FirstType>(q => q.Index("FirstIndex").SomethingElse(...));
    req.AddSearch<SecondType>(q => q.Index("SecondIndex").SomethingElse(...));
});

I guess the response type would have to be MultiSearchResponse<object>.

Describe alternatives you've considered Currently I do two requests and use Task.WhenAll(), which works but seems like it causes an unnecessary workload for Elastic.

flobernd commented 1 month ago

This sounds a little bit like the "multi" version of what's described in #7792

erik-kallen commented 1 month ago

Related, but not quite. In this case I only need the same filter type as output type, but different for each query. Though using different filter and output types for multi as well is a natural improvement that would certainly be useful.