Displaying relevant text with Search results

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Displaying relevant text with Search results

Kadlabalu, Hareesh
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?

 

Thanks

-Hareesh

 

Reply | Threaded
Open this post in threaded view
|

RE: Displaying relevant text with Search results

Pasha Bizhan-2
Hi,

> From: Kadlabalu, Hareesh [mailto:[hidden email]]

> 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?

You need the Highlighter package.
http://svn.apache.org/viewcvs.cgi/lucene/java/trunk/contrib/highlighter/src/
java/org/apache/lucene/search/highlight/package.html?view=markup

http://svn.apache.org/viewcvs.cgi/lucene/java/trunk/contrib/highlighter/

Pasha Bizhan


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Displaying relevant text with Search results

Erik Hatcher
In reply to this post by Kadlabalu, Hareesh

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: [hidden email]
For additional commands, e-mail: [hidden email]