lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: Document as Paramter (Rephrased)
Date Sat, 12 Nov 2005 00:39:01 GMT

On 11 Nov 2005, at 12:54, bib_lucene bib wrote:
> My requirement is that I do a search, the results of the search are  
> displayed. I am displaying results by using getbestfragmets and  
> highlighting searched text.
> So basically the user can search and see what documents matched his  
> search with snippets of text shown in the result of search.
> Now the user needs to select one of the results and view the  
> document completely.
> What I did is along with indexing I stored the document in the ROOT  
> webapplication and gave a link to the file. This worked fine.
> However, now I need to display the full document with search terms  
> highlighted.
> As I understand now I can do this...
> 1. Read the whole document again and apply some css to highlight  
> terms.
> 2. Create a new Lucene Document -> Read the file -> Add file  
> Content to Document -> Use nullfragmenter -> Apply CSS -> Display  
> result.

There is no need to create a new Lucene Document just to highlight  
text.  The text you highlight does not have to be the text you  
indexed even.  The Highlighter takes a String to highlight and a  
Query to extract the terms to highlight from.

> Question is , is there a way I can just show the content from index  
> rather then parsing the document again, when the user wants to see  
> full document from search results page.

Well, the question really comes back to you.... where is the text you  
want to highlight?  You can store it in a Lucene index, in a  
database, on the filesystem, wherever.  Neither Lucene nor the  
Highlighter are related to that decision whatsoever.  So using a  
NullFragmenter, which I will commit to contrib/highlighter soon, use  
the Highlighter on the full text.

If you're still having issues, send us a (brief, please!) piece of  
code you're using to highlight.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message