Write a function that powers the retrieval stage of a small retrieval-augmented generation pipeline. You are given a list of documents, each with an id and raw text, plus a user query. Implement: (1) fixed-size chunking with overlap, (2) a simple embedding function interface that maps text to vectors, (3) cosine-similarity top-k retrieval over chunks, and (4) a lightweight re-ranking step that boosts chunks containing exact query terms. Return the top 5 chunks with their document ids and scores, and analyze the time complexity and one failure mode of this retriever.