FAQ
Hi,


My highlight code is shown as following:


QueryScorer scorer = new QueryScorer(query);
Highlighter highlighter = new Highlighter(simpleHTMLFormatter, scorer);
highlighter.setTextFragmenter(new SimpleSpanFragmenter(scorer, 500));
String contents = doc.get("contents");
TokenStream tokenStream = TokenSources.getAnyTokenStream(searcher.getIndexReader(), topDocs.scoreDocs[i].doc, "contents", doc, analyzer);
String[] snippet = highlighter.getBestFragments(tokenStream, contents, 10);



snippet is the result contexts and then I will print out them on the screen.
But If I may search for a keyword at the last few paragraph and the essay is too long (1000-2000 words), it will return "document found" and snippet.length=0 (i.e. document is found but context is NOT found). Why???


How could I fix the problem?

Search Discussions

  • Gong Li at Mar 16, 2011 at 7:58 am
    Hi,

    My highlight code is shown as following:

    QueryScorer scorer = new QueryScorer(query);
    Highlighter highlighter = new Highlighter(simpleHTMLFormatter, scorer);
    highlighter.setTextFragmenter(new SimpleSpanFragmenter(scorer, 500));
    String contents = doc.get("contents");
    TokenStream tokenStream =
    TokenSources.getAnyTokenStream(searcher.getIndexReader(),
    topDocs.scoreDocs[i].doc, "contents", doc, analyzer);
    String[] snippet = highlighter.getBestFragments(tokenStream, contents,
    10);

    snippet is the result contexts and then I will print out them on the screen.
    But If I may search for a keyword at the last few paragraph and the essay is
    too long (1000-2000 words), it will return "document found" and
    snippet.length=0 (i.e. document is found but context is NOT found). Why???

    How could I fix the problem?
  • Ian Lea at Mar 16, 2011 at 9:29 pm
    I know nothing about highlighting but that 500 looks like a good place
    to start investigating.


    --
    Ian.

    On Tue, Mar 15, 2011 at 8:47 PM, Cescy wrote:
    Hi,


    My highlight code is shown as following:


    QueryScorer scorer = new QueryScorer(query);
    Highlighter highlighter = new Highlighter(simpleHTMLFormatter, scorer);
    highlighter.setTextFragmenter(new SimpleSpanFragmenter(scorer, 500));
    String contents = doc.get("contents");
    TokenStream tokenStream = TokenSources.getAnyTokenStream(searcher.getIndexReader(), topDocs.scoreDocs[i].doc, "contents", doc, analyzer);
    String[] snippet = highlighter.getBestFragments(tokenStream, contents, 10);



    snippet is the result contexts and then I will print out them on the screen.
    But If I may search for a keyword at the last few paragraph and the essay is too long (1000-2000 words), it will return "document found" and snippet.length=0 (i.e. document is found but context is NOT found). Why???


    How could I fix the problem?
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Pierre GOSSE at Mar 17, 2011 at 8:26 am
    500 is the max size of text fragments to be returned by highlight. It shouldn't be the problem here, as far as I understand highlight.

    Gong li, how is defined the field "contents" ? Is it the only field on which the search is made ?

    Pierre

    -----Message d'origine-----
    De : Ian Lea
    Envoyé : mercredi 16 mars 2011 22:29
    À : java-user@lucene.apache.org
    Objet : Re: About highlighter

    I know nothing about highlighting but that 500 looks like a good place
    to start investigating.


    --
    Ian.

    On Tue, Mar 15, 2011 at 8:47 PM, Cescy wrote:
    Hi,


    My highlight code is shown as following:


    QueryScorer scorer = new QueryScorer(query);
    Highlighter highlighter = new Highlighter(simpleHTMLFormatter, scorer);
    highlighter.setTextFragmenter(new SimpleSpanFragmenter(scorer, 500));
    String contents = doc.get("contents");
    TokenStream tokenStream = TokenSources.getAnyTokenStream(searcher.getIndexReader(), topDocs.scoreDocs[i].doc, "contents", doc, analyzer);
    String[] snippet = highlighter.getBestFragments(tokenStream, contents, 10);



    snippet is the result contexts and then I will print out them on the screen.
    But If I may search for a keyword at the last few paragraph and the essay is too long (1000-2000 words), it will return "document found" and snippet.length=0 (i.e. document is found but context is NOT found). Why???


    How could I fix the problem?
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org


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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedMar 15, '11 at 8:48p
activeMar 17, '11 at 8:26a
posts4
users3
websitelucene.apache.org

3 users in discussion

Gong Li: 2 posts Ian Lea: 1 post Pierre GOSSE: 1 post

People

Translate

site design / logo © 2022 Grokbase