I have these data in my elasticsearch with this structure.
How do I search firstName, middleName and surname from this array? Note: The NameDetails array length is dynamic. Person A could have just one element of NameDetails. Person B could have 3 elements of NameDetails.
At the moment, I could only search by gender. I am using NEST nuget C#. This is my query.
var response = await _elasticClient.SearchAsync<Person>(s => s
.Query(q => q
.Bool(b => b.Must(
mu => mu
.Match(m => m
.Field(f => f.Gender)
.Query(Gender)
)
)
)
)
);
In NEST, I tried with this code but return no result.
var response = _elasticClient.Search <Model.Entities.Split.Person.Person> (s => s
.Index("person")
.Query(q => q
.Match(m => m
.Field(f => f.NameDetails.Name[0].NameValue.FirstName)
.Query("Fawsu")
)
)
);
But if I directly run the DSL query at ElasticSearch with query below, it returns result.
GET /person/_search
{
"query": {
"match": {
"nameDetails.nameValue.firstName": {
"query": "Fawsu"
}
}
}
}
}
or
GET /person/_search
{
"query": {
"bool": {
"must": [
{
"fuzzy": {
"nameDetails.nameValue.surname": {
"value": "Pibba",
"fuzziness": "AUTO"
}
}
},
{
"fuzzy": {
"nameDetails.nameValue.firstName": {
"value": "Fawsu",
"fuzziness": "AUTO"
}
}
}
]
}
}
}

