|
10 | 10 | import org.elasticsearch.common.ParsingException; |
11 | 11 | import org.elasticsearch.common.io.stream.StreamInput; |
12 | 12 | import org.elasticsearch.common.io.stream.StreamOutput; |
| 13 | +import org.elasticsearch.common.logging.DeprecationLogger; |
13 | 14 | import org.elasticsearch.common.util.Comparators; |
14 | 15 | import org.elasticsearch.common.xcontent.XContent; |
15 | 16 | import org.elasticsearch.common.xcontent.XContentBuilder; |
16 | 17 | import org.elasticsearch.common.xcontent.XContentParser; |
| 18 | +import org.elasticsearch.core.RestApiVersion; |
17 | 19 | import org.elasticsearch.search.aggregations.Aggregator.BucketComparator; |
18 | 20 | import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket; |
19 | 21 | import org.elasticsearch.search.aggregations.support.AggregationPath; |
@@ -539,7 +541,7 @@ public static void writeHistogramOrder(BucketOrder order, StreamOutput out) thro |
539 | 541 | * Contains logic for parsing a {@link BucketOrder} from a {@link XContentParser}. |
540 | 542 | */ |
541 | 543 | public static class Parser { |
542 | | - |
| 544 | + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(Parser.class); |
543 | 545 | /** |
544 | 546 | * Parse a {@link BucketOrder} from {@link XContent}. |
545 | 547 | * |
@@ -573,6 +575,13 @@ public static BucketOrder parseOrderParam(XContentParser parser) throws IOExcept |
573 | 575 | throw new ParsingException(parser.getTokenLocation(), |
574 | 576 | "Must specify at least one field for [order]"); |
575 | 577 | } |
| 578 | + // _term and _time order deprecated in 6.0; replaced by _key |
| 579 | + if (parser.getRestApiVersion() == RestApiVersion.V_7 && |
| 580 | + ("_term".equals(orderKey) || "_time".equals(orderKey))) { |
| 581 | + deprecationLogger.compatibleApiWarning("_term_and_time_key_removal" , |
| 582 | + "Deprecated aggregation order key [{}] used, replaced by [_key]", orderKey); |
| 583 | + return orderAsc ? KEY_ASC : KEY_DESC; |
| 584 | + } |
576 | 585 | switch (orderKey) { |
577 | 586 | case "_key": |
578 | 587 | return orderAsc ? KEY_ASC : KEY_DESC; |
|
0 commit comments