I'm not sure you want a (public) setData() method at all, since it likely will break people observing existing queries, etc. But if you do, then should move the this.index = {} from the constructor to setData(). Should also add tests for setData(), like above.

I'm reopening this due to an edge case I just accidentally ran into last night.

With the new code changes, the remove function has side effects if you accidentally pass it a nonexistent id, or no id at all. It ends up removing an item anyway, because splice(undefined, 1) behaves like splice(0, 1).

This could be guarded against by checking typeof this.index[id] != "undefined" first.