Issue #2244885 by alexpott: Add method to count number of entities with a particular field.