有没有一种方法可以通过c#中的Nest列出所有Kibana仪表板



我可以使用Postman:之类的简单get请求来获取仪表板列表

http://localhost:9200/.kibana/_search?q=type:dashboard&size=20

然而,我需要使用C#中的Nest客户端来获得列表,我不知道如何使用ElasticClient DSL来形成这种搜索请求。对于更多";传统的";搜索我会使用类似的东西:

var settings = new ConnectionSettings(new Uri("http://localhost:9200/"))
.DefaultMappingFor<ElasticCustomerDTO>(i => i
.IndexName("customer")
.IdProperty(p => p.Identifier)
);
var client = new ElasticClient(settings);
ISearchResponse<ElasticCustomerDTO> searchResponse = client.Search<ElasticCustomerDTO>(s => s
.Query(q => q
.SimpleQueryString(f => f
.Query(filter.Name)
)
)
);

我很难以这种形式创建任何类似于仪表板搜索查询的内容(至少是任何返回结果的内容(。如有任何帮助,我们将不胜感激。

您可以使用下面的NEST查询来获取Kibana仪表板

var searchResponse = await client.SearchAsync<Dictionary<string, object>>(s => s
.Index(".kibana")
.QueryOnQueryString("type:dashboard")
.Size(20));
foreach (var document in searchResponse.Documents)
{
Console.WriteLine(((Dictionary<string, object>)document["dashboard"])["title"]);
}

我使用Dictionary<string, object>作为返回类型,因为我认为NEST中没有任何类型表示Kibana DTO。

最新更新