1. A method comprising: receiving a continuous stream of primary events corresponding to search queries submitted by one or more users, each received primary event being associated with a corresponding primary event key identifying a particular search query; storing the received primary events in a short term memory; generating, by a processor, an index map that tracks primary event keys of any received primary events currently stored in the short term memory; after a time T has passed, storing the received primary events in a long term memory; receiving a secondary event corresponding to an advertisement selected by one of the one or more users, the secondary event being associated with a particular primary key; and using the index map to determine whether the particular primary event key is included in the short term memory.