You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Leos Literak <li...@seznam.cz> on 2007/04/15 18:41:02 UTC

highlighter highlights another term

Hi,

I have following code:

query = query.rewrite(indexReader);
searcher = new IndexSearcher(indexReader);
hits = searcher.search(query);
String text = doc.get("TITLE") + " " + doc.get("CONTENT");
tokenStream = analyzer.tokenStream("CONTENT", new StringReader(text));
fragment = highlighter.getBestFragments(tokenStream, text, 3, "...");

This works fine for most queries except when there are multiple fields
in query. Eg. "mplayer type:article", then fragments contains the word 
"article" highlighted. But I searched for text "mplayer" in documents
with type "article". Am I doing something wrong or is it bug?

Thanks

Leos


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: highlighter highlights another term

Posted by Leos Literak <li...@seznam.cz>.
markharw00d wrote:
> See the Junit test example for field-sensitive highlighting.
> If you pass a fieldname to the QueryScorer constructor it only considers 
> query terms for that field - the default without is all fields

Thanks for hint, it works :-)


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: highlighter highlights another term

Posted by markharw00d <ma...@yahoo.co.uk>.
See the Junit test example for field-sensitive highlighting.
If you pass a fieldname to the QueryScorer constructor it only considers 
query terms for that field - the default without is all fields

Cheers
Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org