def tag_index(idx):
    """Return a mapping of tag names to index items.
    """
    tagidx = dict()
    for i in idx:
        for t in i.tags:
            if t not in tagidx:
                tagidx[t] = set()
            tagidx[t].add(i)
    return tagidx