@VisibleForTesting
    Pair<String, SearchQueryOperator> extractOperator(String value, SearchQueryOperator defaultOperator) {
        if (value.length() >= 3) {
            final String substring2 = value.substring(0, 2);

            switch (substring2) {
                case ">=":
                    return Pair.of(value.substring(2).trim(), SearchQueryOperators.GREATER_EQUALS);
                case "<=":
                    return Pair.of(value.substring(2).trim(), SearchQueryOperators.LESS_EQUALS);
                case "=~":
                    return Pair.of(value.substring(2).trim(), SearchQueryOperators.REGEXP);
            }
        }

        if (value.length() >= 2) {
            final String substring1 = value.substring(0, 1);
            switch (substring1) {
                case ">":
                    return Pair.of(value.substring(1).trim(), SearchQueryOperators.GREATER);
                case "<":
                    return Pair.of(value.substring(1).trim(), SearchQueryOperators.LESS);
                case "=":
                    return Pair.of(value.substring(1).trim(), SearchQueryOperators.EQUALS);
            }
        }

        return Pair.of(value, defaultOperator);
    }
@Test
    void extractOperator() {
        final SearchQueryParser parser = new SearchQueryParser("defaultfield",
                ImmutableMap.of(
                        "id", SearchQueryField.create("real_id"),
                        "date", SearchQueryField.create("created_at", SearchQueryField.Type.DATE),
                        "int", SearchQueryField.create("int", SearchQueryField.Type.INT))
        );

        final SearchQueryOperator defaultOp = SearchQueryOperators.REGEXP;

        checkQuery(parser, "", SearchQueryField.Type.STRING, "", defaultOp);
        checkQuery(parser, "h", SearchQueryField.Type.STRING, "h", defaultOp);
        checkQuery(parser, "he", SearchQueryField.Type.STRING, "he", defaultOp);
        checkQuery(parser, "hel", SearchQueryField.Type.STRING, "hel", defaultOp);
        checkQuery(parser, "hello", SearchQueryField.Type.STRING, "hello", defaultOp);
        checkQuery(parser, "=~ hello", SearchQueryField.Type.STRING, "hello", SearchQueryOperators.REGEXP);
        checkQuery(parser, "=  hello", SearchQueryField.Type.STRING, "hello", SearchQueryOperators.EQUALS);

        checkQuery(parser, ">=2017-03-23", SearchQueryField.Type.DATE, "2017-03-23", SearchQueryOperators.GREATER_EQUALS);
        checkQuery(parser, ">= 2017-03-23", SearchQueryField.Type.DATE, "2017-03-23", SearchQueryOperators.GREATER_EQUALS);
        checkQuery(parser, "<=2017-03-23", SearchQueryField.Type.DATE, "2017-03-23", SearchQueryOperators.LESS_EQUALS);
        checkQuery(parser, "<=  2017-03-23", SearchQueryField.Type.DATE, "2017-03-23", SearchQueryOperators.LESS_EQUALS);
        checkQuery(parser, ">2017-03-23", SearchQueryField.Type.DATE, "2017-03-23", SearchQueryOperators.GREATER);
        checkQuery(parser, ">    2017-03-23", SearchQueryField.Type.DATE, "2017-03-23", SearchQueryOperators.GREATER);
        checkQuery(parser, "<2017-03-23", SearchQueryField.Type.DATE, "2017-03-23", SearchQueryOperators.LESS);
        checkQuery(parser, "< 2017-03-23", SearchQueryField.Type.DATE, "2017-03-23", SearchQueryOperators.LESS);
        checkQuery(parser, "2017-03-23", SearchQueryField.Type.DATE, "2017-03-23", SearchQueryOperators.EQUALS);

        checkQuery(parser, ">=1", SearchQueryField.Type.INT, "1", SearchQueryOperators.GREATER_EQUALS);
        checkQuery(parser, "<=1", SearchQueryField.Type.INT, "1", SearchQueryOperators.LESS_EQUALS);
        checkQuery(parser, ">1", SearchQueryField.Type.INT, "1", SearchQueryOperators.GREATER);
        checkQuery(parser, "<1", SearchQueryField.Type.INT, "1", SearchQueryOperators.LESS);
        checkQuery(parser, "=1", SearchQueryField.Type.INT, "1", SearchQueryOperators.EQUALS);
        checkQuery(parser, "1", SearchQueryField.Type.INT, "1", SearchQueryOperators.EQUALS);

        checkQuery(parser, ">=1", SearchQueryField.Type.LONG, "1", SearchQueryOperators.GREATER_EQUALS);
        checkQuery(parser, "<=1", SearchQueryField.Type.LONG, "1", SearchQueryOperators.LESS_EQUALS);
        checkQuery(parser, ">1", SearchQueryField.Type.LONG, "1", SearchQueryOperators.GREATER);
        checkQuery(parser, "<1", SearchQueryField.Type.LONG, "1", SearchQueryOperators.LESS);
        checkQuery(parser, "=1", SearchQueryField.Type.LONG, "1", SearchQueryOperators.EQUALS);
        checkQuery(parser, "1", SearchQueryField.Type.LONG, "1", SearchQueryOperators.EQUALS);
    }