When parsing `AggregationPath` strings, if we hit an error, we throw `AggregationExecutionException`, which is a 500 class error.  But 500 class errors usually mean that retrying the request might improve the situation, where in this case we want to indicate that the user should not retry with the same request (they need to fix the path expression).  
server/src/main/java/org/elasticsearch/search/aggregations/support/AggregationPath.java
*                                              In this case, the order will be based on the avg value of {@code agg3}.
 *     </li>
 *     <li>
 *         {@code agg1["foo"]._count} - where agg1 is multi-bucket, and the path expects a bucket "foo".
 *                                      This would extract the doc_count for that specific bucket.
 *     </li>
 * </ul>
 *
 */
public class AggregationPath {
    private static final String AGG_DELIM = ">";
    public static AggregationPath parse(String path) {
        String[] elements = Strings.tokenizeToStringArray(path, AGG_DELIM);
        List<PathElement> tokens = new ArrayList<>(elements.length);
        String[] tuple = new String[2];
        for (int i = 0; i < elements.length; i++) {
            String element = elements[i];
            if (i == elements.length - 1) {
                int keyIndex = element.lastIndexOf('[');
                int metricIndex = element.lastIndexOf('.');
                if (keyIndex >= 0) {
                    if (keyIndex == 0 || keyIndex > element.length() - 3) {
                        throw new AggregationExecutionException("Invalid path element [" + element + "] in path [" + path + "]");
                    }
                    int endKeyIndex = element.lastIndexOf(']');
                    if (endKeyIndex < keyIndex) {
                        throw new AggregationExecutionException("Invalid path element [" + element + "] in path [" + path + "]");
                    }
                    if (metricIndex < 0 && endKeyIndex != element.length() - 1) {
                        throw new AggregationExecutionException("Invalid path element [" + element + "] in path [" + path + "]");