public static String httpEncode(String s) {
        if (s == null) return null;
        String encoded = URLEncoder.encode(s, StandardCharsets.UTF_8);
        encoded = encoded.replaceAll("%3F", "?");
        encoded = encoded.replaceAll("%3D", "=");
        encoded = encoded.replaceAll("%26", "&");
        return encoded;
    }
Url encode the given string, except the characters =?&, such that queries with paths and parameters can
be written as a single string.
container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java