Is there a way to get a text summary of an indexed document with Lucene (a.k.a. a “snippet” or “fragment”) to display along with the search result?
You need to store the documents’ summary in the index (use Field.Store.YES when creating that field) and then use the Highlighter from the contrib area (distributed with Lucene since version 1.9 as “lucene-highlighter-(version).jar”). It’s important to use a rewritten query as the input for the highlighter, i.e. call rewrite() on the query. Otherwise simple queries will work but prefix queries etc will not be highlighted. For Lucene < 1.9, you can also get the "highlighter-dev.jar" from http://www.lucenebook.com/LuceneInAction.zip. See http://www.gossamer-threads.com/lists/lucene/java-user/31595 for a discussion of this.
Related Questions
- Is there a way to get a text summary of an indexed document with CLucene (a.k.a. a "snippet" or "fragment") to display along with the search result?
- Is there a way to get a text summary of an indexed document with Lucene (a.k.a. a "snippet" or "fragment") to display along with the search result?
- How can I customize screens to change the display in Account Summary & Draft Summary?