@Test
    public void testOccurrence() {
        assertMetrics("occurrence:0","a","x");
        assertMetrics("occurrence:1","a","a");
        assertMetrics("occurrence:0","a a a","x");
        assertMetrics("occurrence:1","a a a","a");
        assertMetrics("occurrence:1","a a a","a a a");
        assertMetrics("occurrence:1","a a a","a a a a");
        assertMetrics("occurrence:0.3571","a","x x x a x x a x a x x x a a");
        assertMetrics("occurrence:1","a","a a a a a a a a a a a a a a");
        assertMetrics("occurrence:1","a b","a b b a a a a a b a a b a a");

        // tests going beyond the occurrence limit
        FieldMatchMetricsParameters parameters=new FieldMatchMetricsParameters();
        parameters.setMaxOccurrences(10);
        parameters.freeze();
        FieldMatchMetricsComputer c=new FieldMatchMetricsComputer(parameters);
        assertMetrics("occurrence:1",     "a b","a a a a a a a a a a b b",false,c);
        assertMetrics("occurrence:0.9231","a b","a a a a a a a a a a a b b",false,c); // Starting to cut off
        assertMetrics("occurrence:0.6",   "a b","a a a a a a a a a a a a a a a a a a a a a b b",false,c); // Way beyond cutoff for a
        assertMetrics("occurrence:1",     "a b","a a a a a a a a a a b b b b b b b b b b",false,c); // Exactly no cutoff
        assertMetrics("occurrence:1",     "a b","a a a a a a a a a a a b b b b b b b b b b b",false,c); // Field is too large to consider field length
    }
Calculated the same way as weight
searchlib/src/test/java/com/yahoo/searchlib/ranking/features/fieldmatch/test/FieldMatchMetricsTestCase.java