Aggregate on a term and "join" it to different term

Hey,

I have the following document:

{
      "companyId": 100, 
      "companyName": "name",
      "email" : "my_email@gmail.com"
}

I want to create a table that shows the number of documents per company.
So I want to run a filter to filter some of the emails, then aggegate on the companyId field.

I managed to get here.
But I don't have any idea how can I add the company name near the id, and how to remove the filter column, I just want to filter.
Is it possible?

To filter out some emails, you don't need to use the "Filters" aggregation -- instead, associate the visualization with a saved search that is associated just with the documents you want to apply to this visualization. That will get rid of the "filters" column.

To get both "companyid" and "companyName" into the table is trickier. If there is one-to-one mapping between the two, you can do a top-level topN "Terms" aggregation on "companyid" and then a top1 "Terms" sub-aggregation on "companyName" and you'll end up with that view.

1 Like