javascript search algorithm for large text documents