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

Aggregation framework - filtering aggregations by nested object fields doesn't work correctly #4449

Closed
darklow opened this issue Dec 14, 2013 · 2 comments · Fixed by #104481

Comments

@darklow
Copy link

darklow commented Dec 14, 2013

Here i setup an mapping, queries and result:
https://gist.github.com/darklow/7964005

I also tried different queries, more simplified, without so much "nested" filters and queries (since in mapping i have include_in_parent: true nested is not required), but results all the time were same.

@jpountz
Copy link
Contributor

jpountz commented Dec 16, 2013

Does the following aggregation give back the result that you are expecting?

GET /movies/_search
{
   "query": {
      "nested": {
         "path": "credits",
         "query": {
            "match": {
               "credits.person_id": 1
            }
         }
      }
   },
   "aggs": {
      "credits" : {
          "nested" : {
              "path" : "credits"
          },
          "aggs" : {
              "person_1" : {
                  "filter" : {
                      "term" : {
                          "person_id" : 1
                      }
                  },
                  "aggs" : {
                      "departments" : {
                          "terms" : {
                              "field" : "department"
                          }
                      }
                  }
              }
          }
      }
   }
}

For every match, the aggregator:

  • first goes from the movies to the credits ("credits" aggregation)
  • then filter credits to only keep those that are about person_id: 1 ("person_1" aggregation)
  • finally compute counts of the departments for person_id: 1 ("department" aggregation)

@darklow
Copy link
Author

darklow commented Dec 16, 2013

This resolved my issue and returned correct results. Apparently i used wrong syntax.
Thank you for explaining and giving full example. New aggregation feature is great!

@darklow darklow closed this as completed Dec 16, 2013
jrodewig added a commit that referenced this issue Sep 16, 2021
We deprecated `accept_default_password` in 6.0 with PR #1665. However, we didn't
add a related item to the 6.0 breaking changes docs.

Similarly, we deprecated `xpack.security.authz.store.roles.index.cache.max_size`
and `xpack.security.authz.store.roles.index.cache.ttl` in 5.2 with PR #4449
However, we didn't add a related item to the 5.2 breaking changes docs.

This adds the missing items to the 7.15 deprecation docs.

Relates to #40496.
elasticsearchmachine pushed a commit that referenced this issue Sep 16, 2021
…77949)

We deprecated `accept_default_password` in 6.0 with PR #1665. However, we didn't
add a related item to the 6.0 breaking changes docs.

Similarly, we deprecated `xpack.security.authz.store.roles.index.cache.max_size`
and `xpack.security.authz.store.roles.index.cache.ttl` in 5.2 with PR #4449
However, we didn't add a related item to the 5.2 breaking changes docs.

This adds the missing items to the 7.15 deprecation docs.

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

Successfully merging a pull request may close this issue.

2 participants