Hello Mohammad,

 

the new queryscorer is able to rewrite the highlighting queries itself. You 
have to allow it while creating it:

 

    // Create token stream from the text you want to be highlighted. fieldName 
is name of the field that is being highlighted

    // only the relevant part of the query is used.

    StringReader reader( text );

    CachingTokenFilter tokenStream( analyzer.tokenStream( fieldName, &reader ), 
true );

    

    // set bAutoRewriteQueries=true to allow rewriting highlighting queries and 
if you use only standard query objects

   // use the default extractor

    SpanHighlightScorer spanScorer( true );

 

    // initialize the query scorer with the ORIGINAL query – NOT  REWRITTEN 
one. This query 

    // should contain the WildCardQuery, not the ConstantScoreQuery!

    spanScorer.init( query, fieldName, &tokenStream );

 

    // reset the token stream as it has been used by the scorer and we will 
need it in the highlighter too

    tokenStream.reset();

 

    // Using the hilghlighter is the same as with the basis Highlight scorer:

    // Instantiate it with formatter and scorer, set fragmenter and call one of 
its methos, ie. getBestFragments

    SimpleFragmenter fragmenter( fragmentSize );

    Highlighter highlighter( &formatter, &spanScorer ); 

    highlighter.setTextFragmenter( &fragmenter );

    TCHAR * hilited = highlighter.getBestFragments( &tokenStream, text, 
maxFragments, _T( "..." ));

 

The query will be rewritten within the call spanScorer.init(…) Typically, your 
documents do not contain as many different words

that would match your wildcard query as the whole index and so the probability 
that your query matches more than MAX CLAUSE

different words is much less. 

 

Is it possible that your wildcard matches more than MAX CLAUSE different word 
in one document?

 

Jiri

 

 

From: muhammad ismael [mailto:m.ismae...@gmail.com] 
Sent: Monday, January 10, 2011 4:21 PM
To: clucene-developers@lists.sourceforge.net
Subject: Re: [CLucene-dev] CLucene-developers Digest, Vol 57, Issue 9

 

Hello Jiri,

I am sorry , it seems that i should read more in GIT. I got the 
SpanHighlightScorer but how can i use it to highlight terms without warring 
about the maxClauseCount ?

thank you

Mohammad Ismael

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
CLucene-developers mailing list
CLucene-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/clucene-developers

Reply via email to