ElasticSearch NEST 客户端上的 CreateAsync 和 IndexAsync 方法有什么区别?
What is the difference between CreateAsync and IndexAsync methods on ElasticSearch NEST client?
我发现 Create()
方法需要实体 class 中的 Id
字段,但 Index()
不需要它。我不知道为什么。
Elasticsearch 中的创建 API 和索引 API 之间存在根本区别;
- create API will create the document if it does not exist, and will return an error if it does exist. The create API request must contain the index, type and id in the request URI. The id field can be inferred from the POCO 或可以在请求中明确设置。
如果文档不存在,- index API 将创建该文档,如果存在,将覆盖该文档。传递 id 是可选的,如果不传递 id,Elasticsearch 将为文档生成一个 id。
此差异反映在 .NET 客户端上公开的 Create()
和 Index()
方法中。
我发现 Create()
方法需要实体 class 中的 Id
字段,但 Index()
不需要它。我不知道为什么。
Elasticsearch 中的创建 API 和索引 API 之间存在根本区别;
- create API will create the document if it does not exist, and will return an error if it does exist. The create API request must contain the index, type and id in the request URI. The id field can be inferred from the POCO 或可以在请求中明确设置。 如果文档不存在,
- index API 将创建该文档,如果存在,将覆盖该文档。传递 id 是可选的,如果不传递 id,Elasticsearch 将为文档生成一个 id。
此差异反映在 .NET 客户端上公开的 Create()
和 Index()
方法中。