You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by khirb7 <kh...@gmail.com> on 2008/04/10 16:41:21 UTC

Highlighting/getBestFragment

I have done deep search and I found that lucene provide this that methode  :
getBestFragments
highlighter.getBestFragments(tokenStream, text, maxNumFragment, "...");

so with this methode we can precise to lucene to return   maxNumFragment
fragment (with highligted word)of fragsize characters, but there is no
maxFragSize parameter in solr. this would be useful in my case if I want to
highlight not only the first occurrence of a searched word but up to 1
occurrence of the same word in the highlighted text.

so is it possible to add this option to solr? how and where?

cheers


-- 
View this message in context: http://www.nabble.com/Highlighting-getBestFragment-tp16608862p16608862.html
Sent from the Solr - Dev mailing list archive at Nabble.com.


Re: Highlighting/getBestFragment

Posted by khirb7 <kh...@gmail.com>.


Mike Klaas wrote:
> 
> 
> On 10-Apr-08, at 7:41 AM, khirb7 wrote:
>>
>> I have done deep search and I found that lucene provide this that  
>> methode  :
>> getBestFragments
>> highlighter.getBestFragments(tokenStream, text, maxNumFragment,  
>> "...");
>>
>> so with this methode we can precise to lucene to return    
>> maxNumFragment
>> fragment (with highligted word)of fragsize characters, but there is no
>> maxFragSize parameter in solr. this would be useful in my case if I  
>> want to
>> highlight not only the first occurrence of a searched word but up to 1
>> occurrence of the same word in the highlighted text.
> 
> I'm not sure I understand exactly what you want the parameter to do.
> 
> see http://wiki.apache.org/solr/HighlightingParameters
> 
> use:
> hl.fragsize=<size> to set the desired fragment size, and
> hl.snippets=<number> to set the number of returned snippets/fragments.
> 
> -Mike
> 
> 
thank you for your response,

I think that I wasn't enough clear in my last post, (I have already read
http://wiki.apache.org/solr/HighlightingParameters before asking my question
last time)this is what I want to do:
now solr give in response one fragment and  I know 
hl.fragsize=<size> to set the desired fragment size, and
hl.snippets=<number> to set the number of returned snippets/fragments. but
hl.snippets is useful if we deal with multi-valuated field  (for instance
the feature field in the solr schema example) but in my case I have a single
field myText  which type is text   in each document so here
hl.snippets=<number>  has no sense, either used or not the highlighted
result is the same.

here is what I want to do.
lucene provide overloaded  methodes getBestFragment(....)  to return
fragments :
I think that solr classes use this methode 
highlighter.getBestFragment(tokenStream, text)
which return one fragment containing the first occurence of the searched
wordhighlighted , but I dont want only the first occurrence but the N(2th or
3th.....) th one's
and I want to replace the previous methode by 

String result =
    highlighter.getBestFragments(tokenStream, text, 5, "..."); 
here we have maxNumFragment=5  the the five best fragment
so I want to know and where I must modify in Solr to do that:
which class and how.
or in solrconfig.xml  but i found this difficult may be I have to create my
Handler

I am waitin your suggestion how to deal with that.


 

 

-- 
View this message in context: http://www.nabble.com/Highlighting-getBestFragment-tp16608862p16656982.html
Sent from the Solr - Dev mailing list archive at Nabble.com.


Re: Highlighting/getBestFragment

Posted by Mike Klaas <mi...@gmail.com>.
On 10-Apr-08, at 7:41 AM, khirb7 wrote:
>
> I have done deep search and I found that lucene provide this that  
> methode  :
> getBestFragments
> highlighter.getBestFragments(tokenStream, text, maxNumFragment,  
> "...");
>
> so with this methode we can precise to lucene to return    
> maxNumFragment
> fragment (with highligted word)of fragsize characters, but there is no
> maxFragSize parameter in solr. this would be useful in my case if I  
> want to
> highlight not only the first occurrence of a searched word but up to 1
> occurrence of the same word in the highlighted text.

I'm not sure I understand exactly what you want the parameter to do.

see http://wiki.apache.org/solr/HighlightingParameters

use:
hl.fragsize=<size> to set the desired fragment size, and
hl.snippets=<number> to set the number of returned snippets/fragments.

-Mike