문제

I am using NEST to connect to the elasticsearch server:

var searchBoxUri = new Uri("xxx");
var elasticSettings = new ConnectionSettings(searchBoxUri).SetDefaultIndex("xxx");
var client = new ElasticClient(elasticSettings);

I got this error:

'ElasticClient' is a 'namespace' but is used like a 'type'
도움이 되었습니까?

해결책

Try this one:

var client = new Nest.ElasticClient(elasticSettings);

You should use full qualified class name.

다른 팁

You can use something like this :

            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);

Where defaultIndex is a string with the name of the index .

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top