documentation-website icon indicating copy to clipboard operation
documentation-website copied to clipboard

Update the example of the multiple terms aggregation by muliple orders.

Open Zhikai-VM opened this issue 9 months ago • 5 comments

Description

Update the example of the multiple terms aggregation.

Issues Resolved

Closes #7037

Checklist

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

Zhikai-VM avatar Apr 28 '24 02:04 Zhikai-VM

I suggest we don't remove the original example, but add a new one. Because if it needs only 1 order, it could use original one. If we change document like this way, it could confuse the old order style is not supported. But it is not true, it can support both one order with {...} or multiple order with [...].

ankyhe avatar Apr 28 '24 02:04 ankyhe

I suggest we don't remove the original example, but add a new one. Because if it needs only 1 order, it could use original one. If we change document like this way, it could confuse the old order style is not supported. But it is not true, it can support both one order with {...} or multiple order with [...].

I got your point, but the current document is not correct. I am trying to fix it to make it accurate.

Zhikai-VM avatar Apr 29 '24 03:04 Zhikai-VM

@bowenlan-amzn - What are your thoughts on this?

hdhalter avatar Apr 29 '24 16:04 hdhalter

@bowenlan-amzn - What are your thoughts on this?

Please refer to the update in PR: https://github.com/opensearch-project/OpenSearch/pull/13400

Zhikai-VM avatar Apr 30 '24 02:04 Zhikai-VM

Hi @dblock - Can you please comment with your thoughts? Thanks.

hdhalter avatar May 02 '24 00:05 hdhalter

The current example is incorrect, if I understand correctly it has to be an array of orders, even with 1 order. There's no point in having an array of 1 and then another example with an array of 2, is there?

dblock avatar May 06 '24 11:05 dblock

The current example is incorrect, if I understand correctly it has to be an array of orders, even with 1 order. There's no point in having an array of 1 and then another example with an array of 2, is there?

As far as I know, there is no example of array in the offical doc.

Zhikai-VM avatar May 06 '24 23:05 Zhikai-VM

The current example is incorrect, if I understand correctly it has to be an array of orders, even with 1 order. There's no point in having an array of 1 and then another example with an array of 2, is there?

@dblock As current official document, the multi-term example is as below:

GET sample-index100/_search
{
  "size": 0, 
  "aggs": {
    "hot": {
      "multi_terms": {
        "terms": [{
          "field": "region" 
        },{
          "field": "host" 
        }],
        "order": {"max-cpu": "desc"}
      },
      "aggs": {
        "max-cpu": { "max": { "field": "cpu" } }
      }      
    }
  }
}

@Zhikai-VM wants to revise it as:

GET sample-index100/_search
{
  "size": 0, 
  "aggs": {
    "hot": {
      "multi_terms": {
        "terms": [{
          "field": "region" 
        },{
          "field": "host" 
        }],
        "order": [ {"max-cpu": "desc"}, {"max-mem": "asc"}]
      },
      "aggs": {
        "max-cpu": { "max": { "field": "cpu" } },
        "max-mem": { "max": { "field": "mem"}}
      }      
    }
  }
}

to keep the official document accordance with this PR: https://github.com/opensearch-project/OpenSearch/pull/13400

ankyhe avatar May 07 '24 05:05 ankyhe

Hi @dblock , what do you think about this? I prefer to use an array for the 'order' field. We can pass one order or multiple orders in this field.

Zhikai-VM avatar May 10 '24 03:05 Zhikai-VM

Hi @dblock and @bowenlan-amzn, any thoughts on this PR?

Zhikai-VM avatar May 14 '24 08:05 Zhikai-VM

This looks good to me, can we merge @hdhalter ?

dblock avatar May 14 '24 13:05 dblock

Thanks @dblock @bowenlan-amzn!

Zhikai-VM avatar May 14 '24 22:05 Zhikai-VM