Visualizing a N:N relationship

Normally a company buys from one shop, based on its location. But some shopkeepers have been actively trying to steal companies from other shops. To visualize this, I would like to:

Make a list of all companies that buy from at least two shops.
By extension, I would like to see this in a timeline, so I could see when a company has jumped shop.

Typically 1:N or N:N relationships are based on foreign keys and queries join tables together in results where data structures have nesting. Elasticsearch doesn't have a feature to join documents together based on keys: it works best with flat data structures.

Therefore, the visualize the info how you want is to flatten the data at the time of indexing. When the company data is indexed, include a field such as number_of_suppliers. Then you can filter on that number and visualize it, in a date histogram line chart for example, where date is the x-axis, the value of number_of_suppliers is the y-axis, and the data is aggregated by company.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.