ElasticClient.TryConnect已从NEST中删除了吗?

Max*_*Max 1 elasticsearch nest

这是我们过去用来ping Elastic Search节点的代码片段,只是为了检查它是否在那里:

Nest.ElasticClient client; // has been initialized
ConnectionStatus connStatus;
client.TryConnect(out connStatus);  
var isHealthy = connStatus.Success;
Run Code Online (Sandbox Code Playgroud)

它似乎ElasticClient.TryConnect已在NEST 0.11.5中删除.是完全消失还是只是像MapRaw/CreateIndexRaw一样被移到了其他地方?

如果它被删除,这就是我打算做的事情:

Nest.ElasticClient client; // has been initialized
var connectionStatus = client.Connection.GetSync("/");
var isHealthy = connectionStatus.Success;
Run Code Online (Sandbox Code Playgroud)

看起来这样有效 - 或者有更好的替代方法TryConnect吗?

Mar*_*man 5

yes they have. See the release notes: https://github.com/Mpdreamz/NEST/releases/tag/0.11.5.0

Excerpt from the release notes:

Removed IsValid and TryConnect()

The first 2 features of ElasticClient I wrote nearly three years ago which seemed like a good idea at the time. TryConnect() and .IsValid() are two confusing ways to check if your node is up, RootNodeInfo() now returns a mapped response of the info elasticsearch returns when you hit a node at the root (version, lucene_version etc), or you can call client.Raw.MainGet() or perhaps even better client.Raw.MainHead() or even client.Connection.HeadSync("/").

You catch my drift: with so many ways of querying the root .IsValid and TryConnect() is just fluff that only introduces confusion.