Home > OS >  Using the elasticsearch .net Nest client API to get snapshots with query parameters
Using the elasticsearch .net Nest client API to get snapshots with query parameters

Time:07-22

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?

CodePudding user response:

Accoring to the elasic team , the high level client is currently missing this functionalty. They will add this in a near release. For now it is possible to use the low level client, as they suggested:

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" }
    }
});
  • Related