For small texts, you can call tokenstream of Analyzer directly. That way you
don't have to crate an index.


http://lucene.apache.org/java/3_0_3/api/core/org/apache/lucene/analysis/Analyzer.html
http://lucene.apache.org/java/3_0_3/api/core/org/apache/lucene/analysis/TokenStream.html

Analyzer analyzer =  // create your analyzer.

TokenSteam ts = analyzer.tokenStream(fieldName, new
StringReader(fieldValue));

TermAttribute termAtt = ts.addAttribute(TermAttribute.class);
OffsetAttribute offsetAtt = ts.addAttribute(OffsetAttribute.class);
PositionIncrementAttribute posAtt =
ts.addAttribute(PositionIncrementAttribute.class);

while(ts.incrementToken())
{
  System.out.println(offset + "\t" + termAtt.term()  + "\t" +
posAtt.getPositionIncrement());
}


Hope that helps.



On Wed, Dec 22, 2010 at 9:28 PM, Lahiru Samarakoon <lahir...@gmail.com>wrote:

> Hi Ian,
>
> Luke works for me.
>
> Thanks,
> Lahiru.
>



-- 
---
Thanks & Regards
Umesh Prasad

Reply via email to