Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Show only intersecting buckets to the Adjacency matrix aggregation #8832

Open
brusic opened this issue Jul 23, 2023 · 0 comments
Open
Labels
enhancement Enhancement or improvement to existing feature or request Search:Aggregations

Comments

@brusic
Copy link

brusic commented Jul 23, 2023

Is your feature request related to a problem? Please describe.

The Adjacency matrix aggregation will compute and return all buckets related to any of the combinations of the filters specified, including hits on a single filter. However, sometimes a user would want to return only the buckets related to an intersection and not for a single filter. An optional show_only_intersecting parameter would stop buckets resulting from a single filter being hit to be created.

The original intent of this feature was to support a minimum_should_match analogous to boolean queries, but the aggregation only returns adjacencies and not the combination of every filter, so the result could be confusing.

Describe the solution you'd like

From the official documentation, with the optional minimum_should_match parameter added:

GET opensearch_dashboards_sample_data_ecommerce/_search
{
  "size": 0,
  "aggs": {
    "interactions": {
      "adjacency_matrix": {
        "show_only_intersecting": true,
        "filters": {
          "grpA": {
            "match": {
              "manufacturer.keyword": "Low Tide Media"
            }
          },
          "grpB": {
            "match": {
              "manufacturer.keyword": "Elitelligence"
            }
          },
          "grpC": {
            "match": {
              "manufacturer.keyword": "Oceanavigations"
            }
          }
        }
      }
    }
  }
}

New response:

{
   ...
   "aggregations" : {
     "interactions" : {
       "buckets" : [
         {
           "key" : "grpA&grpB",
           "doc_count" : 590
         },
         {
           "key" : "grpA&grpC",
           "doc_count" : 329
         },
         {
           "key" : "grpB&grpC",
           "doc_count" : 299
         }
       ]
     }
   }
 }

Buckets grpA, grpB, and grpC have been omitted.

Describe alternatives you've considered

The existing solutions would be to return all buckets and then use a pipeline aggregation to reduce the number of buckets, or prune in application code. Both solutions work post-reduce, after the creation of buckets, so there is needless overhead involved. The coordinating node could see too many bucket errors, especially when used in conjunction with sub-aggregations.

Additional context

I already have a PR with a working solution ready to be reviewed if this feature is deemed to be useful. The original implementation to support minimum_should_match was more detailed, but now it would be a single if statement.

@brusic brusic added enhancement Enhancement or improvement to existing feature or request untriaged labels Jul 23, 2023
@brusic brusic changed the title [FEATURE] Add minimum should match parameter to Adjacency matrix aggregation [FEATURE] Add match all parameter to Adjacency matrix aggregation Jul 23, 2023
@brusic brusic changed the title [FEATURE] Add match all parameter to Adjacency matrix aggregation [FEATURE] Add minimum_should_match parameter to Adjacency matrix aggregation Jul 23, 2023
@brusic brusic changed the title [FEATURE] Add minimum_should_match parameter to Adjacency matrix aggregation [FEATURE] Show only intersecting buckets to the Adjacency matrix aggregation Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or improvement to existing feature or request Search:Aggregations
Projects
None yet
Development

No branches or pull requests

3 participants