Suppose you search on Google with a query like this:
"term1 term2" term3 term4
For this query Google should return only results that include literally exactly term1 term2 and results that are about term3 and term4.
My question is what datastructures or algorithms support this functionality? It seems to me like asking if a document contains an exact string is an O(N) operation and N is way too large for Google to be doing this. How could Google filter documents that have an exact match to quoted queries quickly?
Put another way, not specific to Google, how would you go about implementing the exact string match on potentially massive numbers of documents.