lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre GOSSE <pierre.go...@arisem.com>
Subject RE: FastVectorHighlighter.getBestFragments returning null
Date Fri, 27 May 2011 11:56:27 GMT
Hi,

Maybe is it related to :
https://issues.apache.org/jira/browse/LUCENE-3087

Pierre

-----Message d'origine-----
De : Joel Halbert [mailto:joel@su3analytics.com] 
Envoyé : vendredi 27 mai 2011 12:57
À : lucene users
Objet : FastVectorHighlighter.getBestFragments returning null

Hi,

I'm using Lucene 3.0.3. I'm extracting snippets using
FastVectorHighlighter, for some snippets (I think always when searching
for exact matches, quoted) the fragment is null.

Code looks like:


			query = QueryParser.escape(query);
			if (exact) {
				query = "\""+query+"\"";
			}
                        BooleanQuery allQ = new BooleanQuery();
			Query bodyQ = new QueryParser(Version.LUCENE_30, BODY, analyser).parse(query);
			termQ.add(new BooleanClause(bodyQ, Occur.SHOULD));
                        // add more queries
                        allQ.add(new BooleanClause(termQ, Occur.MUST));
                        
			TopDocs res = is.search(allQ, null, upperRange);	
			FastVectorHighlighter highlighter = new FastVectorHighlighter(true, true);
			
			for (int i = in.getLowerRange(); i < Math.min(res.totalHits, upperRange); i++) {

                           	String[] bodyFrags =
						highlighter.getBestFragments(highlighter.getFieldQuery(bodyQ),
						is.getIndexReader(), res.scoreDocs[i].doc, BODY, 120, 2);
                
                                // bodyFrags is null
                    }


I do get a hit, and the content with the exact match is coming from the
BODY field, but I cann't seem to get the fragment out.

Any clues,

Thanks

- Joel
Mime
View raw message