Painless scripting field question

The problem is that it failed in some shards, not all of the shards. So it works for this simple documents set does not mean it will work for large number of documents.

I got the error from kibana side:
Courier Fetch: 5 of 50 shards failed.

The error is happening on the elasticsearch side in this file:
./core/src/main/java/org/elasticsearch/search/lookup/LeafDocLookup.java

    @Override
    public ScriptDocValues<?> get(Object key) {
        // assume its a string...
        String fieldName = key.toString();
        ScriptDocValues<?> scriptValues = localCacheFieldData.get(fieldName);
        if (scriptValues == null) {
            final MappedFieldType fieldType = mapperService.fullName(fieldName);
            if (fieldType == null) {
                throw new IllegalArgumentException("No field found for [" + fieldName + "] in mapping with types " + Arrays.toString(types));
            }   

The fieldType is null. I do not understand the internals of the elastic search, the question is when the mapperService is populated for the shard. Is it shared across the shards or it is per shard thing?

Thanks