lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markharw00d <markharw...@yahoo.co.uk>
Subject Re: highlight problem
Date Thu, 05 May 2005 19:07:13 GMT
All looks OK with that bit.
At the risk of sounding obvious - are you mistaking the results from 
multiple documents as the highlighted content from just one document?
eg the end of your "for" loop looks like this:
       System.out.print(result);
   }
and you assume the printed display is from just one document?

That would explain why a different search produces different results - 
you are seeing more documents.



yinjin@indiana.edu wrote:

>Hi, Mark,
>
>Sorry for the confusing. The complete code is here:
>===============================================
>Analyzer analyzer = new StandardAnalyzer();
>      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
>      String line = in.readLine();
>
>      if (line.length() == -1)
>        return;
>
>      Query query = QueryParser.parse(line, "contents", analyzer);
>      Hits hits = searcher.search(query);
>      Highlighter highlighter =new Highlighter(new QueryScorer(query));
>
>      String ids = "";
>      for (int i = 0; i < hits.length(); i++) {
>        Document doc = hits.doc(i);
>        String text = doc.get("contents");
>        String result = "";
>
>        if(text != null ){
>          TokenStream tokenStream = analyzer.tokenStream("contents",
>              new StringReader(text));
>          // Get 3 best fragments and seperate with a "..."                    
>                                                  
>          result = highlighter.getBestFragments(tokenStream,
>              text, 3, "...");
>        }
>
>===============================================
>Quoting mark harwood <markharw00d@yahoo.co.uk>:
>
>  
>
>>As much as you have shown of the example output is
>>roughly what I would expect - using the default
>>simpleFragmenter you get roughly 100 character sized
>>fragments and you have shown 3 fragments sized 97, 100
>>and 105 chars long separated by "...".
>>
>>    
>>
>>>Of course the result is far more than this.
>>>      
>>>
>>So are you saying you had even more fragments in the
>>"getBestFragments" return string separated by your
>>choice of "..." separator?
>>
>>I also notice the text contains no markup - have you
>>removed that from the example? 
>>
>>Cheers
>>Mark
>>
>>
>>
>>
>>
>>
>>		
>>___________________________________________________________ 
>>How much free photo storage do you get? Store your holiday 
>>snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
>>
>>---------------------------------------------------------------------
>>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
>
>
>  
>



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


Mime
View raw message