private Item buildRange(String key, Inspector value) {
        Map<Integer, Inspector> children = childMap(value);
        Inspector annotations = getAnnotations(value);

        boolean[] equals = {false};

        String field;
        Inspector boundInspector;
        if (children.get(0).type() == STRING){
            field = children.get(0).asString();
            boundInspector = children.get(1);
        } else {
            field = children.get(1).asString();
            boundInspector = children.get(0);
        }
        Number[] bounds = {null, null};
        String[] operators = {null, null};
        boundInspector.traverse((ObjectTraverser) (operator, bound) -> {
            if (bound.type() == STRING) {
                throw new IllegalArgumentException("Expected a numeric argument to range, but got the string '" + bound.asString() + "'");
            }
            if (operator.equals("=")) {
                bounds[0] = (bound.type() == DOUBLE) ? (Number) bound.asDouble() : (Number) bound.asLong();
                operators[0] = operator;
                equals[0] = true;
            }
            if (operator.equals(">=") || operator.equals(">")){
                bounds[0] = (bound.type() == DOUBLE) ? (Number) bound.asDouble() : (Number) bound.asLong();
                operators[0] = operator;
            } else if (operator.equals("<=") || operator.equals("<")){
                bounds[1] = (bound.type() == DOUBLE) ? (Number) bound.asDouble() : (Number) bound.asLong();
                operators[1] = operator;
            }

        });
        IntItem range = null;
        if (equals[0]) {
            range = new IntItem(bounds[0].toString(), field);
        }
        else if (operators[0] == null || operators[1] == null) {
            int index = (operators[0] == null) ? 1 : 0;
            range = switch (operators[index]) {
                case ">=" -> buildGreaterThanOrEquals(field, bounds[index].toString());
                case ">" -> buildGreaterThan(field, bounds[index].toString());
                case "<" -> buildLessThan(field, bounds[index].toString());
                case "<=" -> buildLessThanOrEquals(field, bounds[index].toString());
                default -> range;
            };
        }
        else {
            range = instantiateRangeItem(bounds[0], bounds[1], field, operators[0].equals(">"), operators[1].equals("<"));
        }

        return leafStyleSettings(annotations, range);
    }
Translates a list of grouping requests on JSON form to a list in the grouping language form
container-search/src/main/java/com/yahoo/search/query/SelectParser.java