From Matching to Generation: A Survey on Generative Information Retrieval