This is pretty good, but it's open to a DOS attack. I don't think there's anything stopping somebody from sending us a truly disgusting query with 10,000 terms. Can you put a limit on the length of the query and have it just do nothing if there are too many parts?