I am new to elastic search and we need to migrate from mongodb to elastic. we used
public class Book
{
[BsonId]
public string Id { get; set; }
public string ApplicationId { get; set; }
public string UserName { get; set; }
public string UserId{ get; set; }
public DateTime CurrDate { get; set; }
public int Counter { get; set; }
public DateTimeOffset CurrDateOffset { get; set; }
[BsonExtraElements]
public BsonDocument Metadata { get; set; }
}
BsonDocument support custom json object. so I can insert an object with pre-define property & custom json string
As a example
var basonDoc = BsonSerializer.Deserialize<BsonDocument>(@"{
""emp-name"":""Kasun kalhara"",
""emp-age"":30,
""emp-position"":""Associate Developer""
}");
var indexResponse = await elasticClient.IndexDocument(new BookElasticSearch
{
Id = Guid.NewGuid().ToString(),
UserId = "test@test.ai",
UserName = "test test Silva",
CurrDate = DateTime.Now,
CurrDateOffset = DateTimeOffset.Now,
Counter = -1,
Metadata = basonDoc
});
How can I do that using NEST or any way in .net core