Code example for Ordering

Methods: greatestOf

    public void extract(RegexpQuery query, List<QueryTerm> terms,
                            List<Extractor<?>> extractors) {
        String regexp = parseOutRegexp(query.toString(""));
        String substr = Iterables.getFirst(byLengthOrdering.greatestOf(regexpSplitter.split(regexp), 1), "");
        terms.add(new QueryTerm(query.getField(), substr + ngramSuffix, QueryTerm.Type.WILDCARD));
     * The only way to extract a regexp from a RegexpQuery is by parsing it's 
     * toString(String) output.  Which is a bit rubbish, really... 
     * @param queryRepresentation the toString() representation of a RegexpQuery 
     * @return the regular expression for the query 
    public static String parseOutRegexp(String queryRepresentation) {
        int fieldSepPos = queryRepresentation.indexOf(":");
        int firstSlash = queryRepresentation.indexOf("/", fieldSepPos);
        int lastSlash = queryRepresentation.lastIndexOf("/");
        return queryRepresentation.substring(firstSlash + 1, lastSlash);
Contextual code suggestions in your IDE  Get Codota for Java