private int findClosestInFieldBySemanticDistance(int i,int previousJ,int startSemanticDistance) {
        String term=query.getTerms()[i].getTerm();
        for (int distance=startSemanticDistance; distance<field.terms().size(); distance++) {
            int j=semanticDistanceToFieldIndex(distance,previousJ);
            if (term.equals(field.terms().get(j).value()))
                return distance;
        }
        return -1;
    }
Implements the preferred search order for finding a match to a query item - first
looking close in the right order, then close in the reverse order, then far in the right order
and lastly far in the reverse order.

@param startSemanticDistance is the semantic distance we must be larger than or equal to
@return the semantic distance of the next mathing j larger than startSemanticDistance, or -1 if
        there are no matches larger than startSemanticDistance
searchlib/src/main/java/com/yahoo/searchlib/ranking/features/fieldmatch/FieldMatchMetricsComputer.java