Skip to content

I think that the object to express a nested query with filters is missing (or at least I did not understand which is the correct object to use) #8507

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

Closed
alkampfergit opened this issue May 2, 2025 · 1 comment

Comments

@alkampfergit
Copy link

How can I create a nested aggregation with filters?

I have the following aggregation json, and I'm trying to express with the new driver. Actually I have code that works perfectly with NEST7, but I want to transition everything to the new driver since NEST is deprecated.

My problem is that, in the new driver I found a FiltersAggregation object that has the property filters not filter (single filter), so it does not generate the query below.

Can you point me on the right direction? The new driver really lacks extensive documentation and if you search you got most of the information on the old driver and nothing on the new one.

 "aggs": {
    "JarvisField_1/JarvisField_3": {
      "nested": {
        "path": "nested"
      },
      "aggs": {
        "path_filter": {
          "filter": {
            "term": {
              "nested.path.na": "JarvisField_1/JarvisField_3"
            }
          },
          "aggs": {
            "JarvisField_1/JarvisField_3": {
              "terms": {
                "field": "nested.svalue",
                "size": 1
              },
              "aggs": {
                "reverse_nested": {
                  "reverse_nested": {}
                }
              }
            }
          }
        }
      }
    },
    "@@nesteduncategorized": {
      "filter": {
        "bool": {
          "must_not": [
            {
              "nested": {
                "path": "nested",
                "query": {
                  "term": {
                    "nested.path.na": "JarvisField_1/JarvisField_3"
                  }
                }
              }
            }
          ]
        }
      },
      "aggs": {
        "@@uncategorized": {
          "filter": {
            "match_all": {}
          }
        }
      }
    }
  },
@alkampfergit
Copy link
Author

Ok solved, I just needed to do

Aggregation.Filter(filterTermQuery);

I still think that a comprehensive set of example could be good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant