没有,SniffingConnectionPool 似乎可以工作。
var settings2 = new ConnectionSettings(new Uri(elasticSearchUri))
_elasticClient = new ElasticClient(settings2);
但是在下面的ConnectionSettings中使用 SniffingConnectionPool :
var settings2 = new ConnectionSettings(new SniffingConnectionPool(new[] { new Uri(elasticSearchUri) }))
.DefaultIndex("myindex")
.DisableDirectStreaming(true);
错误结果如下:
“嗅探群集状态失败。”
Splunk日志
Unable to import data to ElasticSearch - Failed sniffing cluster state. PipelineException Project.ScheduledJobService LOCAL ERROR
Unable to import data to ElasticSearch - One or more errors occurred. AggregateException Project.ScheduledJobService LOCAL ERROR
Unable to import data to ElasticSearch - Object reference not set to an instance of an object.
NullReferenceException Project.ScheduledJobService
完整跟踪:
at Elasticsearch.Net.RequestPipeline.Sniff() in C:\Users\russ\source\elasticsearch-net-2.x\src\Elasticsearch.Net\Transport\Pipeline\RequestPipeline.cs:line 358
at Elasticsearch.Net.RequestPipeline.FirstPoolUsage(SemaphoreSlim semaphore) in C:\Users\russ\source\elasticsearch-net-2.x\src\Elasticsearch.Net\Transport\Pipeline\RequestPipeline.cs:line 143
at Elasticsearch.Net.Transport`1.Request[TReturn](HttpMethod method, String path, PostData`1 data, IRequestParameters requestParameters) in C:\Users\russ\source\elasticsearch-net-2.x\src\Elasticsearch.Net\Transport\Transport.cs:line 53
at Elasticsearch.Net.ElasticLowLevelClient.DoRequest[T](HttpMethod method, String path, PostData`1 data, IRequestParameters requestParameters) in C:\Users\russ\source\elasticsearch-net-2.x\src\Elasticsearch.Net\ElasticLowLevelClient.cs:line 58
at Elasticsearch.Net.ElasticLowLevelClient.Bulk[T](PostData`1 body, Func`2 requestParameters) in C:\Users\russ\source\elasticsearch-net-2.x\src\Elasticsearch.Net\ElasticLowLevelClient.Generated.cs:line 32
at Nest.LowLevelDispatch.BulkDispatch[T](IRequest`1 p, PostData`1 body) in C:\Users\russ\source\elasticsearch-net-2.x\src\Nest\_Generated\_LowLevelDispatch.generated.cs:line 26
at Nest.ElasticClient.Nest.IHighLevelToLowLevelDispatcher.Dispatch[TRequest,TQueryString,TResponse](TRequest request, Func`3 responseGenerator, Func`3 dispatch) in C:\Users\russ\source\elasticsearch-net-2.x\src\Nest\ElasticClient.cs:line 56
at Nest.ElasticClient.Nest.IHighLevelToLowLevelDispatcher.Dispatch[TRequest,TQueryString,TResponse](TRequest request, Func`3 dispatch) in C:\Users\russ\source\elasticsearch-net-2.x\src\Nest\ElasticClient.cs:line 46
at Nest.ElasticClient.Bulk(IBulkRequest request) in C:\Users\russ\source\elasticsearch-net-2.x\src\Nest\Document\Multiple\Bulk\ElasticClient-Bulk.cs:line 32
at Project.Core.Services.ElasticSearchService.IndexMultiple(IEnumerable`1 documents)
at Project.ScheduledJobService.Jobs.ElasticSearch.ElasticSearchTrackedChangesDataImportJob.Execute() in C:\Users\Martynas.Valaika\Code\Project\Main\Source\Project\Project.ScheduledJobService\Jobs\Elasticsearch\ElasticSearchTrackedChangesDataImportJob.cs:line 35
最佳答案
显然,ES 5.0中存在一个错误。将SniffingConnectionPool替换为SingleNodeConnectionPool应该可以完成这项工作。
var pool = new SingleNodeConnectionPool(new Uri(uri));
var settings = new ConnectionSettings(pool, connectionSettings => new MyJsonNetSerializer(connectionSettings))
.DefaultIndex("seetickets_search_results")
.DisableDirectStreaming();
_elasticClient = new ElasticClient(settings);
关于c# - 使用SniffingConnectionPool时出现Nest 2.4.6错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40469612/