Beginner |
 |
Joined: Wed Aug 06, 2014 10:53 am Posts: 30
|
I solved my problem. I created a singleton for the my CustomAnalyzer object. I get the value for the document using this utility function: <code> public static List<String> tokenizeString(Analyzer analyzer, String string) { List<String> result = new ArrayList<String>(); try { TokenStream stream = analyzer.tokenStream(null, new StringReader(string)); stream.reset(); while (stream.incrementToken()) { result.add(stream.getAttribute(CharTermAttribute.class).toString()); } stream.end(); stream.close(); } catch (IOException e) { // not thrown b/c we're using a string reader... throw new RuntimeException(e); } return result; } </code>
|
|