NEST连接:ConnectionSettings没有参数'defaultIndex'

时间:2016-02-22 19:16:45

标签: elasticsearch nest

 public class Class1
    {
        public static Uri node;
        public static ConnectionSettings settings;
        public static ElasticClient client;

        public static void Main(string[] args)
        {
            node = new Uri("http://localhost:9200");
            settings = new ConnectionSettings(node, defaultIndex: "my-application");
            var client = new ConnectionSettings(settings);
        }
    }

构建此代码时出现此错误。我指的是: 弹性搜索文档:elastic search nest doc Nest doc:Nest doc

我有VS Express 2015 for NEST的NEST 2.0.2版本。我认为文档适用于旧版本的NEST。有人可以建议我一些最新的文件或什么可以解决这个问题?

1 个答案:

答案 0 :(得分:3)

默认索引可以通过ConnectionSettings

的方法设置
public class Class1
{
    public static Uri node;
    public static ConnectionSettings settings;
    public static ElasticClient client;

    public static void Main(string[] args)
    {
        node = new Uri("http://localhost:9200");
        settings = new ConnectionSettings(node);
        settings.DefaultIndex("my-application");
        var client = new ElasticClient(settings);
    }
}