Make get_corpus_from_query more flexible