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

Support _first and _last parameter for missing bucket ordering in composite aggregation #1942

Merged
merged 3 commits into from
Jan 26, 2022

Conversation

penghuo
Copy link
Contributor

@penghuo penghuo commented Jan 19, 2022

Description

Support _first and _last parameter for missing bucket ordering in composite aggregation.
If missing_order is "_first" or "_last", regardless order, missing_bucket is at first or last respectively. for example, the following query will sort product asc and null bucket will be placed at last.

{
  "size": 0,
  "aggs": {
    "my_buckets": {
      "composite": {
        "sources": [
          {
            "product_name": {
              "terms": {
                "field": "product",
                "missing_bucket": true,
                "missing_order": "last",
                "order": "asc"
              }
            }
          }
        ]
      }
    }
  }
}

Issues Resolved

#1899

Check List

  • [x ] New functionality includes testing.
    • [x ] All tests pass
  • New functionality has been documented.
    • [x ] New functionality has javadoc added
  • [ x] Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

By default, if order is asc, missing_bucket at first, if order is desc, missing_bucket at last.
If missing_order is "_first" or "_last", regardless order, missing_bucket is at first or last respectively.

Signed-off-by: Peng Huo <[email protected]>
@opensearch-ci-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 134f068
Log 1990

Reports 1990

@penghuo penghuo marked this pull request as ready for review January 19, 2022 20:55
@penghuo penghuo requested a review from a team as a code owner January 19, 2022 20:55
@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success e9aed4d
Log 1998

Reports 1998

Copy link
Member

@saratvemulapalli saratvemulapalli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. It looks good to me as far as I understand.
Also we should add documentation for this feature, on OpenSearch its usually via Java docs.

I would like @nknize / @andrross to review for another pair of eyes.

Comment on lines +84 to +86
if (in.getVersion().onOrAfter(Version.V_2_0_0)) {
this.missingOrder = MissingOrder.readFromStream(in);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to leave this feature only for 2.0.0?
I dont see any harm to include this for 1.3.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.3.0 also works, there is no blocker.
totally agree, doc is necessary. i add javadoc on setter method. any suggestion for others?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you'd like this for 1.3.0 (I'm good w/ that) let's make the version change in a separate backportable PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer a separate backportable PR for 1.3.0.

Copy link
Collaborator

@nknize nknize left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM! Just a few nit picky changes.

Comment on lines +84 to +86
if (in.getVersion().onOrAfter(Version.V_2_0_0)) {
this.missingOrder = MissingOrder.readFromStream(in);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you'd like this for 1.3.0 (I'm good w/ that) let's make the version change in a separate backportable PR.

Signed-off-by: Peng Huo <[email protected]>
@penghuo
Copy link
Contributor Author

penghuo commented Jan 26, 2022

@nknize Thanks for the feedback, good point. I pushed a fix and resolve comments which I already addressed, but I am leaving 1 comment unresolved and want to double confirm with you.

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 04517f5
Log 2065

Reports 2065

@nknize
Copy link
Collaborator

nknize commented Jan 26, 2022

I prefer a separate backportable PR for 1.3.0.

I'm good w/ that!

@nknize nknize self-requested a review January 26, 2022 22:35
Copy link
Collaborator

@nknize nknize left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thx for the quick turnaround!

@nknize nknize merged commit 7a9314a into opensearch-project:main Jan 26, 2022
penghuo added a commit to penghuo/OpenSearch that referenced this pull request Jan 28, 2022
…r parameter (opensearch-project#1942)

InternalBucket should use MissingOrder to decide null values's order.

Signed-off-by: Peng Huo <[email protected]>
nknize pushed a commit that referenced this pull request Feb 1, 2022
…r parameter (#1942) (#2005)

Fix composite aggregation failed test cases introduce by missing_order parameter by using MissingOrder to decide null values's order in InternalBucket.

Signed-off-by: Peng Huo <[email protected]>
penghuo added a commit to penghuo/OpenSearch that referenced this pull request Feb 3, 2022
…site aggregation (opensearch-project#1942)

Support for "first" and "last" parameters for missing bucket ordering in composite aggregation.
By default, if order is asc, missing_bucket at first, if order is desc, missing_bucket at last. If
missing_order is "first" or "last", regardless order, missing_bucket is at first or last respectively.

Signed-off-by: Peng Huo <[email protected]>
saratvemulapalli pushed a commit that referenced this pull request Feb 15, 2022
…site aggregation (#1942) (#2049)

Support for "first" and "last" parameters for missing bucket ordering in composite aggregation.
By default, if order is asc, missing_bucket at first, if order is desc, missing_bucket at last. If
missing_order is "first" or "last", regardless order, missing_bucket is at first or last respectively.

Signed-off-by: Peng Huo <[email protected]>
andrross added a commit to andrross/OpenSearch that referenced this pull request Feb 16, 2022
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 this pull request may close these issues.

4 participants