从 POST 上不成功的低级别调用构建的无效 NEST 响应
Invalid NEST response built from a unsuccessful low level call on POST
我想从 C# 代码配置 NEST
当我使用 Kibana 命令时 GET /_cat/indices?v
我得到这个结果:
我的测试指数是"customer"
我正在使用 Elasticsearch.Net 和 NEST:.NET 客户端 [6.x]
弹性“6.5.4”,
现在这就是我在 C# 上的配置方式:
var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
.DefaultIndex("customer");
var client = new ElasticClient(settings);
var newCustomer = new Customer
{
name = "test_name",
OS = "test_os",
script = "test_script"
};
var indexResponse = client.IndexDocument(newCustomer);
我得到一个错误:
Invalid NEST response built from a unsuccessful low level call on POST: /customer/customer
为什么它构建请求到 /customer/customer ???
我配置错了什么?
错误信息:
从 POST 上不成功的低级别调用构建的无效 NEST 响应:/customer/customer
此 API 调用的审计跟踪:
- 错误响应:节点:http://localhost:9200/ 占用:00:00:00.2817669
OriginalException:Elasticsearch.Net.ElasticsearchClientException:远程服务器返回错误:(400)无效请求。调用:状态代码 400 来自:POST /customer/customer。 ServerError:类型:illegal_argument_exception 原因:"Rejecting mapping update to [customer] as the final mapping would have more than 1 type: [_doc, customer]" ---> System.Net.WebException:远程服务器返回错误:(400) 无效请求。
您在 ES 中已有一个映射,但您要索引的文档与其不匹配。
why does it build request to /customer/customer ??? What am I configurating wrong?
它将其构建为 customer
(索引)和 customer
(类型),因为
- 索引请求未指定应将文档编入索引的索引,因此请求使用 configured default index from
ConnectionSettings
- 索引请求未指定文档类型,因此 NEST infers the type name 来自 POCO 类型名称,将其小写。
如果你想为所有的POCO设置一个默认的类型名称,你可以使用
var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
.DefaultIndex("customer")
.DefaultTypeName("_doc"); // <--- type name used for all POCOs
我想从 C# 代码配置 NEST
当我使用 Kibana 命令时 GET /_cat/indices?v
我得到这个结果:
我的测试指数是"customer"
我正在使用 Elasticsearch.Net 和 NEST:.NET 客户端 [6.x] 弹性“6.5.4”, 现在这就是我在 C# 上的配置方式:
var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
.DefaultIndex("customer");
var client = new ElasticClient(settings);
var newCustomer = new Customer
{
name = "test_name",
OS = "test_os",
script = "test_script"
};
var indexResponse = client.IndexDocument(newCustomer);
我得到一个错误:
Invalid NEST response built from a unsuccessful low level call on POST: /customer/customer
为什么它构建请求到 /customer/customer ??? 我配置错了什么?
错误信息:
从 POST 上不成功的低级别调用构建的无效 NEST 响应:/customer/customer 此 API 调用的审计跟踪: - 错误响应:节点:http://localhost:9200/ 占用:00:00:00.2817669 OriginalException:Elasticsearch.Net.ElasticsearchClientException:远程服务器返回错误:(400)无效请求。调用:状态代码 400 来自:POST /customer/customer。 ServerError:类型:illegal_argument_exception 原因:"Rejecting mapping update to [customer] as the final mapping would have more than 1 type: [_doc, customer]" ---> System.Net.WebException:远程服务器返回错误:(400) 无效请求。
您在 ES 中已有一个映射,但您要索引的文档与其不匹配。
why does it build request to /customer/customer ??? What am I configurating wrong?
它将其构建为 customer
(索引)和 customer
(类型),因为
- 索引请求未指定应将文档编入索引的索引,因此请求使用 configured default index from
ConnectionSettings
- 索引请求未指定文档类型,因此 NEST infers the type name 来自 POCO 类型名称,将其小写。
如果你想为所有的POCO设置一个默认的类型名称,你可以使用
var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
.DefaultIndex("customer")
.DefaultTypeName("_doc"); // <--- type name used for all POCOs