private void implementGramMatch(Schema schema, SDField field, boolean validate) {
        if (validate && field.doesAttributing() && ! field.doesIndexing())
            throw new IllegalArgumentException("gram matching is not supported with attributes, use 'index' in indexing");

        int n = field.getMatching().getGramSize().orElse(DEFAULT_GRAM_SIZE);
        if (validate && n == 0)
            throw new IllegalArgumentException("Illegal gram size in " + field + ": Must be at least 1");
        field.getNormalizing().inferCodepoint();
        field.setStemming(Stemming.NONE); // not compatible with stemming and normalizing
        field.addQueryCommand("ngram " + n);
        field.setIndexingScript(schema.getName(), (ScriptExpression)new MyProvider(schema, n).convert(field.getIndexingScript()));
    }
The implementation of "gram" matching - splitting the incoming text and the queries into
n-grams for matching. This will also validate the gram settings.

@author bratseth
config-model/src/main/java/com/yahoo/schema/processing/NGramMatch.java