没有 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
答案 0 :(得分:1)
显然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);