Question

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'
Was it helpful?

Solution

Try this one:

var client = new Nest.ElasticClient(elasticSettings);

You should use full qualified class name.

OTHER TIPS

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 .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top