42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using RestSharp;
|
|
using RestSharp.Extensions;
|
|
using RestSharp.Serializers;
|
|
using RestSharp.Authenticators;
|
|
|
|
using System.Security.Cryptography.X509Certificates;
|
|
using System.Net;
|
|
|
|
namespace ElasticSearchStudy.App
|
|
{
|
|
internal class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
Console.WriteLine("使用 ElistcSearch 简单测试项目");
|
|
if (args == null || args.Length == 0)
|
|
{
|
|
Console.WriteLine("没有启动参数");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine($"有 {args.Length} 个启动参数, 分别是 [{string.Join(" | ",args)}]");
|
|
}
|
|
|
|
var option = new RestClientOptions()
|
|
{
|
|
BaseUrl = new Uri("https://localhost:9201"),
|
|
Authenticator = new HttpBasicAuthenticator("elastic", "es-461400")
|
|
|
|
};
|
|
|
|
var restClient = new RestClient(option);
|
|
var request = new RestRequest("/_cat/health?v", Method.Get);
|
|
|
|
var healthResponse = restClient.Get(request);
|
|
|
|
var context = healthResponse.Content;
|
|
|
|
Console.WriteLine(context);
|
|
}
|
|
}
|
|
} |