Backport fix in _build_index_spec() from upstream to support creating indexes on keys in DictFields