elasticsearch-net icon indicating copy to clipboard operation
elasticsearch-net copied to clipboard

Use MultisearchBodyDescriptor with MultiSearchRequestDescriptor

Open Tora-Bora opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. I'm trying to migrate our code from NEST to the new client. Unable to migrate the MultiSearchAsync using descriptors. The method accepts type MultiSearchRequestDescriptor, also I found the type MultisearchBodyDescriptor that I can use to build a search request. But seems like there is no way to use MultisearchBodyDescriptor at all.

The MultiSearchRequestDescriptor.AddSearch accepts SearchRequestItem and there is no option to provide the MultisearchBodyDescriptor anyhow.

Describe the solution you'd like Add method to MultiSearchRequestDescriptor.AddSearch that accepts MultisearchBodyDescriptor parameter

Describe alternatives you've considered Would be also great if we can to cast SearchRequestDescriptor to MultisearchBodyDescriptor

Tora-Bora avatar Oct 18 '23 06:10 Tora-Bora

Improving usability of the multisearch endpoint is definitely on my list. The initializer based approach works for now, but I agree it might be useful to support descriptors here as well:

var multiSearchResponse = await _elasticsearchClient.MultiSearchAsync<Place>(r =>
{
    foreach (var fullTextQuery in fullTextQueries)
    {
        r.AddSearch(new SearchRequestItem(
            new MultisearchHeader { Index = "my-index" },
            new MultisearchBody { /*...*/ }));
    }
});

flobernd avatar Oct 24 '23 11:10 flobernd