【问题标题】:Dispatching Index() from NEST into to Elasticsearch.NET failed将 Index() 从 NEST 分派到 Elasticsearch.NET 失败
【发布时间】:2016-02-28 19:59:44
【问题描述】:

我在使用 Nest 和 Elasticsearch.NET 时调用 client.Index 时出错

var httpConnection = new AwsHttpConnection(new AwsSettings
{
    AccessKey = "AKIAIFIV4LN6XZAFVX7Q",
    SecretKey = "MySecretKey",
    Region = "us-east-1",
});

var pool = new SingleNodeConnectionPool(new Uri(sSearchURI));
var config = new ConnectionSettings(pool, httpConnection);
var client = new ElasticClient(config);
var person = new Person
{
    Id = "1",
    Firstname = "Martijn",
    Lastname = "Laarman"
};
var index = client.Index(person);

将 Index() 从 NEST 分派到 Elasticsearch.NET 失败
收到一个标记为 PUT 的请求 这个端点接受 POST,PUT 的 请求可能没有提供足够的信息来进行任何 这些端点:
- /{index}/{type}
- /{index}/{type}/{id}

有什么想法吗?

【问题讨论】:

  • 它似乎无法推断索引或类型信息。只是为了检验这个理论,你可以尝试更明确的方式:client.Index(person, i => i.Index("persons").Type("person").Id(person.Id)); 吗?

标签: c# elasticsearch nest


【解决方案1】:

需要设置默认索引:

settings.DefaultIndex("indexName");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-11
    • 2016-10-26
    • 1970-01-01
    • 1970-01-01
    • 2020-01-26
    • 2021-10-13
    • 1970-01-01
    相关资源
    最近更新 更多