improve search query peak memory usage

This commit improves query peak memory usage, and as a good side effect
query response time, on a search query by using an iterator to load the
scores instead of loading all into memory.