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

@alkampfergit

Description

@alkampfergit

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": {}
          }
        }
      }
    }
  },

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions