From java-user-return-52025-apmail-lucene-java-user-archive=lucene.apache.org@lucene.apache.org Wed Feb 8 21:37:16 2012 Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3EB9C9FB7 for ; Wed, 8 Feb 2012 21:37:16 +0000 (UTC) Received: (qmail 726 invoked by uid 500); 8 Feb 2012 21:37:14 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 595 invoked by uid 500); 8 Feb 2012 21:37:13 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 587 invoked by uid 99); 8 Feb 2012 21:37:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Feb 2012 21:37:12 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.213.48] (HELO mail-yw0-f48.google.com) (209.85.213.48) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Feb 2012 21:37:06 +0000 Received: by yhjj52 with SMTP id j52so678597yhj.35 for ; Wed, 08 Feb 2012 13:36:45 -0800 (PST) Received: by 10.182.160.65 with SMTP id xi1mr27453813obb.40.1328737005394; Wed, 08 Feb 2012 13:36:45 -0800 (PST) From: Dave Seltzer MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AczmqcD45Z9sqCE9TYetghX1wTky0Q== Date: Wed, 8 Feb 2012 16:36:44 -0500 Message-ID: <0d195aa4cd7ba9343575912ab5bb9624@mail.gmail.com> Subject: Working with MemoryIndex results To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 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 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