List of usage examples for org.apache.lucene.document Field tokenStream
TokenStream tokenStream
To view the source code for org.apache.lucene.document Field tokenStream.
Click Source Link
From source file:edu.utsa.sifter.DocMaker.java
License:Apache License
public static boolean addBodyField(final Document doc, final String body, final Analyzer analyzer, boolean testEmpty) throws IOException { final Field f = new Field("body", body, BodyOptions); if (testEmpty) { // System.out.println("testing if doc has empty body"); final TokenStream toks = f.tokenStream(analyzer); toks.reset();//www.ja v a 2 s . c o m if (!toks.incrementToken()) { // System.out.println("empty body, won't index"); toks.close(); return false; } } doc.add(new Field("body", body, BodyOptions)); doc.add(new LongField("body-len", body.length(), Field.Store.YES)); return true; }