Adjacency matrix aggregations

The adjacency_matrix aggregation lets you define filter expressions and returns a matrix of the intersecting filters where each non-empty cell in the matrix represents a bucket. You can find how many documents fall within any combination of filters.

Use the adjacency_matrix aggregation to discover how concepts are related by visualizing the data as graphs.

For example, in the sample eCommerce dataset, to analyze how the different manufacturing companies are related:

  1. GET opensearch_dashboards_sample_data_ecommerce/_search
  2. {
  3. "size": 0,
  4. "aggs": {
  5. "interactions": {
  6. "adjacency_matrix": {
  7. "filters": {
  8. "grpA": {
  9. "match": {
  10. "manufacturer.keyword": "Low Tide Media"
  11. }
  12. },
  13. "grpB": {
  14. "match": {
  15. "manufacturer.keyword": "Elitelligence"
  16. }
  17. },
  18. "grpC": {
  19. "match": {
  20. "manufacturer.keyword": "Oceanavigations"
  21. }
  22. }
  23. }
  24. }
  25. }
  26. }
  27. }

copy

Example response

  1. {
  2. ...
  3. "aggregations" : {
  4. "interactions" : {
  5. "buckets" : [
  6. {
  7. "key" : "grpA",
  8. "doc_count" : 1553
  9. },
  10. {
  11. "key" : "grpA&grpB",
  12. "doc_count" : 590
  13. },
  14. {
  15. "key" : "grpA&grpC",
  16. "doc_count" : 329
  17. },
  18. {
  19. "key" : "grpB",
  20. "doc_count" : 1370
  21. },
  22. {
  23. "key" : "grpB&grpC",
  24. "doc_count" : 299
  25. },
  26. {
  27. "key" : "grpC",
  28. "doc_count" : 1218
  29. }
  30. ]
  31. }
  32. }
  33. }

Let’s take a closer look at the result:

  1. {
  2. "key" : "grpA&grpB",
  3. "doc_count" : 590
  4. }
  • grpA: Products manufactured by Low Tide Media.
  • grpB: Products manufactured by Elitelligence.
  • 590: Number of products that are manufactured by both.

You can use OpenSearch Dashboards to represent this data with a network graph.