Using the elasticsearch .net NEST client API to get snapshots with query parameters

I'm using the Nest client c# API (version 7.0.0.0) to get elasticsearch (8.2.2) snapshots information.

response =
            _elasticClient.Snapshot.Get(
            "repository_name",
            "*"
            );

If I'm sending a rest request I'm sending query params to sort, order and set the max size of returned snapshots:

https://esurl:9200/_snapshot/repository_name/*?size=3&sort=start_time&order=desc

How can I do it using the API?

Hi @amirmono. I've just looked into these and they are missing as the documentation and API spec doesn't list them. However, they are valid, so we'll need to add support for them in an upcoming release. I'm going to create an issue to track this. Unfortunately, right now, you will be unable to use these from within the client.

Thanks! @stevejgordon Is there a way to do it with the low level client?

Hi, @amirmono. Yep, you could try something like this with the low-level client.

var response = client.LowLevel.Snapshot.Get<GetSnapshotResponse>("a-repository", "*", 
    new Elasticsearch.Net.Specification.SnapshotApi.GetSnapshotRequestParameters 
    { 
        QueryString =  new Dictionary<string, object>
        {
            { "size", 3 },
            { "order", "desc" },
            { "sort", "start_time" }
        }
    });

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.