2017-02-17 8 views

답변

0

너겟 패키지 관리자에서 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; 
    } 

메시지가 표시되면 서버 상태를 확인할 수 있습니다. 녹색과 노란색은 허용되며 빨간색은 문제를 일으킬 수 있습니다.

감사합니다 ............