我创建了这个mappaing的类“document”。但是我不知道如何访问属性字段。
这是我的映射(摘要):
"mappings": {
"document": {
"properties": {
"baseUniqueID": {
"type": "keyword"
},
"description": {
"type": "text",
"fields": {
"en": {
"type": "text",
"analyzer": "english"
},
"fa": {
"type": "text",
"analyzer": "nofapersian"
},
"fr": {
"type": "text",
"analyzer": "french"
}
}
},
"documentDate": {
"type": "date"
},
"documentType_Id": {
"type": "keyword"
},
"id": {
"type": "long"
}
}
}
}
文档类:
public class Document : BaseInt32KeyEntity
{
public string BaseUniqueID{ get; set; }
public int? Weight { get; set; }
public DateTime DocumentDate { get; set; }
public string Description { get; set; }
public int DocumentType_Id { get; set; }
}
}
如何使Document对象只填充所需的字段(在这个示例description.en中),然后使用IndexDocument将其添加到Elasticsearch?像这样的:
Document doc = new Document();
doc.Description.en = "This is some description";
ElasticClient.IndexDocument(doc);