search: factor out resultQueue code
Created by: keegancsmith
The result queue code being interspersed with the aggregation code makes it difficult to understand what is responsible for aggregation vs re-ordering. This commit pulls the queue related parts into its own structure. Additionally by having functions per responsibility of resultQueue I believe it makes the code easier to grok.