int semanticDistanceToFieldIndex(int semanticDistance,int zeroJ) {
        if (semanticDistance == -1) return -1;
        int firstSegmentLength = Math.min(parameters.getProximityLimit(),field.terms().size() - zeroJ);
        int secondSegmentLength = Math.min(parameters.getProximityLimit(), zeroJ);
        if (semanticDistance < firstSegmentLength)
            return zeroJ + semanticDistance;
        else if (semanticDistance < firstSegmentLength+secondSegmentLength)
            return zeroJ - semanticDistance - 1 + firstSegmentLength;
        else if (semanticDistance < field.terms().size() - zeroJ+secondSegmentLength)
            return zeroJ + semanticDistance - secondSegmentLength;
        else
            return field.terms().size() - semanticDistance - 1;
    }
Returns the field index (j) from a starting point zeroJ and the distance form zeroJ in the
semantic distance space

@return the field index, or -1 (undefined) if the semanticDistance is -1
searchlib/src/main/java/com/yahoo/searchlib/ranking/features/fieldmatch/FieldMatchMetricsComputer.java