@Test
    public void testWeightedOccurrence() {
        assertMetrics("weightedOccurrence:0","a!200","x");
        assertMetrics("weightedOccurrence:1","a!200","a");
        assertMetrics("weightedOccurrence:0","a!200 a a","x");
        assertMetrics("weightedOccurrence:1","a!200 a a","a");
        assertMetrics("weightedOccurrence:1","a a a","a a a");
        assertMetrics("weightedOccurrence:1","a!200 a a","a a a a");
        assertMetrics("weightedOccurrence:0.3571","a!200","x x x a x x a x a x x x a a");
        assertMetrics("weightedOccurrence:1","a!200","a a a a a a a a a a a a a a");
        assertMetrics("weightedOccurrence:0.5","a b","a b b a a a a a b a a b a a");

        assertMetrics("weightedOccurrence:0.5714","a!200 b","a b b a a a a a b a a b a a");
        assertMetrics("weightedOccurrence:0.6753","a!1000 b","a b b a a a a a b a a b a a");  // Should be higher
        assertMetrics("weightedOccurrence:0.4286","a b!200","a b b a a a a a b a a b a a"); // Should be lower
        assertMetrics("weightedOccurrence:0.3061","a b!2000","a b b a a a a a b a a b a a"); // Should be even lower

        assertMetrics("weightedOccurrence:0.30","a b",    "a a b b b b x x x x");
        assertMetrics("weightedOccurrence:0.3333","a b!200","a a b b b b x x x x"); // More frequent is more important - higher
        assertMetrics("weightedOccurrence:0.2667","a!200 b","a a b b b b x x x x"); // Less frequent is more important - lower
        assertMetrics("weightedOccurrence:0.2667","a b!50", "a a b b b b x x x x"); // Same relative

        assertMetrics("weightedOccurrence:0","a!0 b!0", "a a b b b b x x x x");

        // tests going beyond the occurrence limit
        FieldMatchMetricsParameters parameters=new FieldMatchMetricsParameters();
        parameters.setMaxOccurrences(10);
        parameters.freeze();
        FieldMatchMetricsComputer c=new FieldMatchMetricsComputer(parameters);
        assertMetrics("weightedOccurrence:0.6","a b","a a a a a a a a a a b b",false,c);
        assertMetrics("weightedOccurrence:0.6","a b","a a a a a a a a a a a b b",false,c); // Starting to cut off
        assertMetrics("weightedOccurrence: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("weightedOccurrence: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("weightedOccurrence: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

        assertMetrics("weightedOccurrence:0.7333","a!200 b","a a a a a a a a a a b b",false,c);
        assertMetrics("weightedOccurrence:0.4667","a b!200","a a a a a a a a a a b b",false,c);
        assertMetrics("weightedOccurrence:0.7333","a!200 b","a a a a a a a a a a a b b",false,c); // Starting to cut off
        assertMetrics("weightedOccurrence:0.7333","a!200 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("weightedOccurrence:1",     "a!200 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("weightedOccurrence:1",     "a!200 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