I want to filter children in elastic search without changing the parent node, i have something like this data, and want to all games, but only "isVisible = true" members should appear with each game
So, i want to get the above game as is but with only 1 team member (John) i am using C#, and tried this:
var result = new List<Func<QueryContainerDescriptor<Review>, QueryContainer>>();
result.Add(a => a.Nested(n => n.Path("teamMembers").Query(q => q.Match(m => m.Field("teamMembers.isVisible").Query("true")))));
I think you might be misunderstanding how queries on nested types work.
Assuming that "teamMembers" is an array of objects mapped as a nested type, the query that you're performing will return Game documents that contain an object in the "teamMembers" array whose "isVisible" property is set to "true" (I'd pass the boolean true rather than a string here).
It won't return only the teamMembers who are visible, on the Game document, it will return the entire _source document. There are a couple of ways that you might collect only the teamMembers who are visible
Filter them out in application code, from the response, using LINQ .Where() or similar
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.