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 Sascha Janz <Sa...@gmx.net> on 2016/06/02 10:41:05 UTC
highlighter with query over more than one word
we use highlighter to get textfragments for our hit list.
the code is straight forward like this
Analyzer analyzer = new StandardAnalyzer(;
QueryParser parser = new QueryParser( "content", analyzer);
Highlighter highlighter = new Highlighter(new QueryScorer(parser.parse(pQuery)));
Fragmenter fragmenter = new SimpleFragmenter(fragmentsize);
highlighter.setTextFragmenter(fragmenter);
TokenStream stream = analyzer.tokenStream("content", new StringReader(value));
String text = highlighter.getBestFragments(stream , value, 3);
in most cases this gives us good results.
but sometime when we do a query over multiple words. we get only highlighted fragments for one word.
e.g. a query with "aalen ringen" does only become highlighted fragments with "ringen", although the word "aalen" is also in the content.
any tips for getting better results?
regards
Sascha
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: highlighter with query over more than one word
Posted by David Smiley <da...@gmail.com>.
It would help tremendously if you can give a specific code example showing
the problem.
On Thu, Jun 2, 2016 at 6:41 AM Sascha Janz <Sa...@gmx.net> wrote:
>
> we use highlighter to get textfragments for our hit list.
>
> the code is straight forward like this
>
> Analyzer analyzer = new StandardAnalyzer(;
> QueryParser parser = new QueryParser( "content", analyzer);
> Highlighter highlighter = new Highlighter(new
> QueryScorer(parser.parse(pQuery)));
> Fragmenter fragmenter = new SimpleFragmenter(fragmentsize);
> highlighter.setTextFragmenter(fragmenter);
> TokenStream stream = analyzer.tokenStream("content", new
> StringReader(value));
> String text = highlighter.getBestFragments(stream , value, 3);
>
> in most cases this gives us good results.
>
> but sometime when we do a query over multiple words. we get only
> highlighted fragments for one word.
>
> e.g. a query with "aalen ringen" does only become highlighted fragments
> with "ringen", although the word "aalen" is also in the content.
>
> any tips for getting better results?
>
> regards
> Sascha
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
> --
Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker
LinkedIn: http://linkedin.com/in/davidwsmiley | Book:
http://www.solrenterprisesearchserver.com