“ Nest.ConnectionSettings”不包含“ SetDefaultIndex”的定义,也没有扩展方法“ SetDefaultIndex”

时间:2018-07-05 06:55:35

标签: elasticsearch nest elasticsearch-aggregation

我正在尝试将ES 1.7.0升级到ES 6.3,为此,我将NEST API 0.12更新到了6.1.0,并且遇到了以下错误-

'Nest.ConnectionSettings'不包含'SetDefaultIndex'的定义,并且找不到扩展方法'SetDefaultIndex'接受类型为'Nest.ConnectionSettings'的第一个参数(您是否缺少using指令或程序集引用? )

private void InitializeES()
    {
        _uri = new Uri(ConfigurationManager.AppSettings["ElasticSearchEngineURI"]);
        _indexName = ConfigurationManager.AppSettings[_connectionStringName];
        _connectionSettings = new ConnectionSettings(_uri);
        _connectionSettings.SetDefaultIndex(_indexName);
        _connectionSettings.SetTimeout(180000);
        _client = new ElasticClient(_connectionSettings);
        CheckIndexExistance();
    }

请协助

1 个答案:

答案 0 :(得分:0)

如果您将代码更新为

private void InitializeES()
{
    _uri = new Uri(ConfigurationManager.AppSettings["ElasticSearchEngineURI"]);
    _indexName = ConfigurationManager.AppSettings[_connectionStringName];
    _connectionSettings = new ConnectionSettings(_uri);
    _connectionSettings.DefaultIndex(_indexName);
    _connectionSettings.RequestTimeout(TimeSpan.FromMilliseconds(180000));
    _client = new ElasticClient(_connectionSettings);
    CheckIndexExistance();
}

它将起作用。请务必阅读之间的重大变更说明

以及博客帖子