You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Dave Seltzer <ds...@tveyes.com> on 2012/02/08 22:36:44 UTC

Working with MemoryIndex results

Hello,

I'm using a MemoryIndex in order to search a block of in-memory text using
a lucene query.
I'm able to search the text, produce a result, and excerpt a highlight
using the highlighter.

Right now I'm doing this:

MemoryIndex index = new MemoryIndex();
index.addField("content", fullText, LuceneAnalyzer);
If(index.search(query) > 0.0f)
{
	Highlighter highlighter = new Highlighter(new QueryScorer(query));
	highlighter.setTextFragmenter(new SimpleFragmenter(150));
	List<String> excerpts =
Arrays.asList(highlighter.getBestFragments(LuceneAnalyzer, "content",
fullText, 5));
	for(String excerpt : excerpts) {
		System.out.println(query.toString() + ": " + excerpt);
	}
}

I'd really like to be able to get the raw TextFragments from the
Highlighter, but I need a TokenStream in order to be able to call
highlighter.getBestTextFragments.
What's the best way to get a tokenstream from a block of text?

Thanks Much!

-Dave

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