lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joel Halbert <j...@su3analytics.com>
Subject FastVectorHighlighter.getBestFragments returning null
Date Fri, 27 May 2011 10:57:28 GMT
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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message