use an optimized version of the bulk_index call
flatten index/type temporary dict to one level
use a `collections.defaultdict` instead of `dict.setdefault`
micro-optimize `datetime.date.today` call out of the loop