While working on the [Change Point Detection prototype](https://github.com/elastic/kibana/pull/144093) in Kibana, we've realised that 
 the [response body](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-change-point-aggregation.html#change-point-agg-response) format of the `change_point` agg doesn't allow performing the following operations on the ES side, which might be quite heavy for the client-side computing, especially for the high-cardinality data. 

- Filtering by `p_value` threshold 
- Ascending sorting by `p_value`
- Filtering by the change point `type`

Currently, this is handled client-side after paging over all buckets with the `composite` agg.


<details>
  <summary>Example of the agg request</summary>

  ```json
{
  "index": "kibana_sample_data_ecommerce",
  "size": 0,
  "body": {
    "query": {
      "bool": {
        "filter": [
          {
            "range": {
              "order_date": {
                "from": "2022-10-20T00:04:19.000Z",
                "to": "2022-11-18T23:45:36.000Z"
              }
            }
          }
        ]
      }
    },
    "aggregations": {
      "groupings": {
        "composite": {
          "size": 10,
          "after": {
            "splitFieldTerm": "9"
          },
          "sources": [
            {
              "splitFieldTerm": {
                "terms": {
                  "field": "customer_id"
                }
              }
            }
          ]
        },
        "aggregations": {
          "over_time": {
            "date_histogram": {
              "field": "order_date",
              "fixed_interval": "1d"
            },
            "aggs": {
              "function_value": {
                "max": {
                  "field": "products.price"
                }
              }
            }
          },
          "change_point_request": {
            "change_point": {
              "buckets_path": "over_time>function_value"
            }
          }
        }
      }
    }
  }
}
  ```
</details>

Preferably, it should be possible to extend the agg request with the [bucket_selector](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-pipeline-bucket-selector-aggregation.html) that filter out undefined `p_value` and only surface change points of particular `type`.

And sorting results by `p_value` with the [bucket_sort](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-pipeline-bucket-sort-aggregation.html).


cc @benwtrent @tveasey 

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/InternalChangePointAggregation.java
if (bucket != null) {
            out.writeBoolean(true);
            bucket.writeTo(out);
        } else {
            out.writeBoolean(false);
        }
        out.writeNamedWriteable(changeType);
    }
    @Override
    public InternalAggregation reduce(List<InternalAggregation> aggregations, AggregationReduceContext reduceContext) {
        throw new UnsupportedOperationException("Reducing a change_point aggregation is not supported");
    }
    @Override
    protected boolean mustReduceOnSingleInternalAgg() {
        return false;
    }
    @Override
    public Object getProperty(List<String> path) {
        return null;
    }
    @Override
    public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
        if (bucket != null) {
            builder.field("bucket", bucket);
        }
        NamedXContentObjectHelper.writeNamedObject(builder, params, "type", changeType);
        return builder;
    }
}