I have this Query DSL which return the correct result when I query directly at ElasticSearch
GET /person/_search
{
"query": {
"match": {
"nameDetails.nameValue.firstName": {
"query": "Fawsu"
}
}
}
}
}
But in NEST C#, it doesn't return any result. May I know what's wrong with my syntax?
var response = _elasticClient.Search<Person> (s => s
.Index("person")
.Query(q => q
.Match(m => m
.Field(f => f.NameDetails.Name.First().NameValue.FirstName)
.Query("Fawsu")
)
)
);
or
var response = _elasticClient.Search<Person> (s => s
.Index("person")
.Query(q => q
.Match(m => m
.Field(f => f.NameDetails.Name[0].NameValue.FirstName)
.Query("Fawsu")
)
)
);
How do I see the query generated by NEST to troubleshoot this?
The expression in .Field(f => f.NameDetails.Name[0].NameValue.FirstName)
looks like it has an extra level, Name
, to the object graph compared to the expected string. I would expect the output of the expression would be
nameDetails.name.nameValue.firstName
which will not match the field "nameDetails.nameValue.firstName"
in the query.
You can see what NEST sends to Elasticsearch in a number of ways