On Jun 13, 2005, at 10:58 AM, Kadlabalu, Hareesh wrote:

Hi,

I have a simple index with one default field that is stored and indexed. I want to display the query results along with some relevant text from the default field, the way search is implemented at http:// www.lucenebook.com/
<http://www.lucenebook.com/> .



For example, searching for 'wonderful'
(http://www.lucenebook.com/search?query=Wonderful
<http://www.lucenebook.com/search?query=Wonderful> ) generates results that
have highlighting on relevant words in the result.



One way to implement this would be get documents from search result and physically parse the contents of the default field for the occurrence of the search word or one of its synonyms (Wonderful: wonder, wonderfully.. ). Then display a few words before and after a match for contextual information.

However, in order to really do it correctly, one needs to get to the 'best' part field's text where the density of searched word(s) is highest. This could be a very expensive process. Does Lucene give any help is achieving
this?

The Highlighter (under contrib in the Lucene Subversion repository) does a bit of finding the best fragments - you can customize this aspect of it. Check the source code and test cases for more details on how to customize this sort of thing.

    Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to