I created an index in my Elasticsearch server and I'm using .Net client NEST to connect to it. Some of the index properties have multiple fields and I want to fill just the correct field.
I created the class 'document' to this mappaing. but I do not know how to access fields of property.
this is the mapping I have (summarized):
"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"
}
}
}
}
and the document class:
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; }
}
}
How can I make an object of Document to fill just the field I want (here in this example description.en) and then use IndexDocument to add it to Elasticsearch? something like this:
Document doc = new Document();
doc.Description.en = "This is some description";
ElasticClient.IndexDocument(doc);