Elasticsearch contains document like With mapping and If i do and I get org.elasticsearch.index.fielddata.ScriptDocValues$Strings type for both fields. How can i determine source field type? (I need get string length if field is simple string or size of array if field is array) Answer The correct painless expression to use is: