Having problems in filtering for a chart created with multiple document types

In elastic search I have documents of two different types (a&b). Now I create a chart where the aggregation on Y axis is based on a common term of both the types and the sub-aggregation of the bar chart is done via a field present in only one of the types(say b). Now this chart is part of a dashboard and I apply a filter based on a field present only in the other type(say a). The chart then says "No results :|". Is there a better way to handle this? I first thought of entering an array of objects of this document into the other but then it was not giving me the field to create charts. Any better solution?

If I understand your example correctly it sounds like things are behaving as they should. Here is a more concrete example that maybe you can use to better explain what you want


Let's say you have an index people with two types:

people/child: { name, age, favorite_color }
people/adult: { name, age, job }

And the data:

people/adult/1: { "john", 21, "baker"  }
people/adult/2: { "jane", 25, "doctor" }
people/adult/3: { "stan", 40, "doctor" }
people/child/4: { "joan", 5,  "purple" }

If you created a chart with bars showing the average age of people based on their job, you would get:

2 |   X
1 |   X       X
   --------------
    doctor  baker 

If you then filtered all of the people by favorite_color:purple, the data would only contain people/child/4, who does not have a job, and therefore the chart showing people grouped by their job would not have any data to work with.

@spalger that is what I expect it to do. But the problem is that instead of showing people/child/4 it shows "No Results :|"