我正在使用NEST连接到elasticsearch服务器:
var searchBoxUri = new Uri("xxx");
var elasticSettings = new ConnectionSettings(searchBoxUri).SetDefaultIndex("xxx");
var client = new ElasticClient(elasticSettings);
我收到了这个错误:
'ElasticClient' is a 'namespace' but is used like a 'type'
答案 0 :(得分:1)
试试这个:
var client = new Nest.ElasticClient(elasticSettings);
您应该使用完全限定的类名。
答案 1 :(得分:0)
您可以使用以下内容:
private ElasticClient _Instance;
var elasticSearchURI = ConfigurationManager.AppSettings["elasticSearchURI"];
var node = new Uri(elasticSearchURI);
var connectionPool = new SniffingConnectionPool(new[] { node });
var config = new ConnectionSettings(connectionPool, defaultIndex)
.SniffOnConnectionFault(false)
.SniffOnStartup(false)
.DisablePing();
_Instance = new ElasticClient(config);
其中defaultIndex是一个带有索引名称的字符串。