Erick Erickson wrote: > > So why not assign a string to "text" and try it again? Or show us the code > where you expect the text variable to get a value..... > > Erick > >
I`m sorry that was a miss from my side. I've tried to put the simple code into SearchFiles, between Hits hits = searcher.search(query); and String path = doc.get("path"); Here the code: Highlighter highlighter = new Highlighter(new QueryScorer(query)); if (repeat > 0) { // repeat & time as benchmark Date start = new Date(); for (int i = 0; i < repeat; i++) { hits = searcher.search(query); } Date end = new Date(); System.out.println("Time: "+(end.getTime()-start.getTime())+"ms"); } System.out.println(hits.length() + " total matching documents"); final int HITS_PER_PAGE = 10; for (int start = 0; start < hits.length(); start += HITS_PER_PAGE) { int end = Math.min(hits.length(), start + HITS_PER_PAGE); for (int i = start; i < end; i++) { if (raw) { // output raw format System.out.println("doc="+hits.id(i)+" score="+hits.score(i)); continue; } Document doc = hits.doc(i); String text = hits.doc(i).get(field); //String field = "contents"; TokenStream tokenStream = analyzer.tokenStream(field, new StringReader(text)); // Get 3 best fragments and seperate with a "..." String result = highlighter.getBestFragments(tokenStream, text, 3, "..."); String path = doc.get("path"); if (path != null) { System.out.println((i+1) + ". " + path);System.out.println("\t"+result); String title = doc.get("title"); if (title != null) { System.out.println(" Title: " + doc.get("title")); } } else { System.out.println((i+1) + ". " + "No path for this document"); } } The bolded text was added by me. I hope, i have made the changes in the right file :) -- View this message in context: http://www.nabble.com/Newbie-Search-Question-tf2667479.html#a7513261 Sent from the Lucene - Java Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]