Search for the longest string in a document