Hello dear friends, I have a question. I want to retrieve the _id of a document, how can I do that with using Nest?
The field I want to reach is the following "_id" field :
"_id" : "4912ba5cfb86ea63541c7007b1791ab3a6f0d54a",
"_index" : "people",
"_type" : "_doc",
"_id" : "4912ba5cfb86ea63541c7007b1791ab3a6f0d54a",
"_score" : 1.0,
"_source" : {
"country" : "Turkey",
"surname" : "Bayrak",
"name" : "Esra",
"email" : "esrabayrak@gmail.com",
"age" : "88"
}
For this I tried things like below. I used the Source plugin but I can't access the _id :
My model doesn't have a prop called id. Elasticsearch created the _id field itself.
string GetDocumentId(string Name) {
var searchResponse = elasticClient.Search<MyModelName>(s => s
.Index(people)
.Query(q => q
.Bool(b => b
.Must(
m => m.Match(mm => mm.Field(f => f.name).Query("Esra"))
)))
);
string temp = searchResponse.Hits.Select(s => s.Id).ToString();
return temp;
}
);
I would be very happy if you help. Thank you from now.