0
Nugetのパッケージマネージャーからエラスティックサーチクライアントネストをダウンロードしました。C#を使用してElastic検索サーバーの健全性をチェックする方法は?
と私はサーバーの正常性をチェックする機能を認識できません。
お願いします。
ありがとうございます。 いずれの回答もありがとうございます。
Nugetのパッケージマネージャーからエラスティックサーチクライアントネストをダウンロードしました。C#を使用してElastic検索サーバーの健全性をチェックする方法は?
と私はサーバーの正常性をチェックする機能を認識できません。
お願いします。
ありがとうございます。 いずれの回答もありがとうございます。
NugetパッケージマネージャからElasticSearch.netとNestをインストールする必要があります。両方とも同じバージョンでなければなりません。
Nest Elastic Clientを使用してステータスを確認する方法があります。
public string HealthCheck(WaitForStatus waitForStatus = WaitForStatus.Red, bool logResults = false)
{
var response = this._client.ClusterHealth(new ClusterHealthRequest() { WaitForStatus = waitForStatus });
var healthColor = response.Status.ToLower();
// this will give you the color code of the elastic search server health.
switch (healthColor)
{
case "green":
var message = "ElasticSearch Server health check returned [GREEN]";
break;
case "yellow":
var message = "ElasticSearch Server health check returned [YELLOW] (yellow is normal for single node clusters) ";
break;
default: // Includes "red"
var message = "ElasticSearch Server health check returned [{0}]".FormatInLine(response.Status.ToUpper());
break;
}
return message;
}
あなたが取得したメッセージによって、サーバーの正常性を確認できます。 緑色と黄色を使用できますが、赤色の場合は問題が発生することがあります。
ありがとう............