# bag of words in an online configuration, for classification / clustering

I have a set of image documents. I extract text keywords from this images using OCR to represent each image as a bag of words (a vector where each value is the number of occurrence of a word in the document). Then I can apply a classification or clustering algorithm on the obtained dataset.

However, this vector representation as bag of words is possible only if I have the entire set of documents (to be able to have the entire vocabulary, i.e. all words). How can I do that (i.e. extract my bag of words) if I'm in an online configuration (using an online clustering) where the documents are available one by one (for a data stream) and each document should be processed as soon as it is available ?