Using NEST .NET library I worte following query.
var result = client.Search<StudenntBrief>(s => s.Type("Students").Query(q => q.Term("Name","Robert")));
It worked fine and got 7 results.
Instead of using maigic string to represent field i tried to use expression as follows.
var result = client.Search<StudenntBrief>(s => s.Type("Students").Query(q => q.Term(t => t.Name,"Robert")));
I found zero results.
Here is one more example.
Works.
var result = client.Search<StudenntBrief>(s => s.Type("Students").Query(q => q.MultiMatch(a => a.OnFields(new List<string{"Name"}).Query("Robert"))));
Doesn't works.
var result = client.Search<StudenntBrief>(s => s.Type("Students").Query(q => q.MultiMatch(a => a.OnFields(f=> f.Name).Query("Robert"))));
I am wondering why query using expression to represent field is not working.