Optimize thread search using matched docid sets.