0

不知何故,我的对象的 id 字段没有被存储,但所有其他字段都是?

编码:

// Assuming a list of Products
var products = // entity framework code to get a list of products
var node = new Uri("http://localhost:9200");
var settings = new ConnectionSettings(node);
var client = new ElasticClient(settings);
var descriptor = new BulkDescriptor();    
descriptor.IndexMany(products, (bd, q) => bd.Id(q.id).Index("products"));
client.Bulk(descriptor);

我正在使用的示例产品类:

public class Product
{
    public string id { get; set; }
    public string nameEn { get; set; }
    public string nameFr { get; set; }
}

结果如 Kabana 所示:

id: nameEn: nameFr: _id:C _type:productsearch _index:products _score:1

请注意该id字段如何为空,但 Elasticsearch_id字段已正确定义。

谢谢你的帮助!

4

0 回答 0