Let's say we have a full-text database. The reasonable thing to do, for scalability, is to store only an index but not the content of documents.
The issue I'm facing is: I would like to deliver highlighted preview of the content when listing search results for a given query (just like Google does), but I find hard to choose one of the approaches over the other:
Approach I:
- Creating an index for the documents set.
- Storing the text content of the documents.
- After retrieving documents for a given search query, a highlighted preview is created using the previously stored content of documents.
Issue: storage.
Approach II:
- Creating an index for the documents set, without storing their text content.
- After retrieving documents for a given search query, a highlighted preview is created by dynamically (at query-time) reading the text content of the documents.
Issue: it may take a considerable amount of time to parse the text content of documents while the user is waiting.
So, are there any known approaches to this problem? Otherwise, which one do you think, relatively, costs less than the other?