*
* @see org.apache.lucene.xmlparser.FilterBuilder#process(org.w3c.dom.Element)
*/
public Filter getFilter(Element e) throws ParserException
{
TermsFilter tf = new TermsFilter();
String text = DOMUtils.getNonBlankTextOrFail(e);
String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");
TokenStream ts = analyzer.tokenStream(fieldName, new StringReader(text));
try
{
final Token reusableToken = new Token();
Term term = null;
for (Token nextToken = ts.next(reusableToken); nextToken != null; nextToken = ts.next(reusableToken)) {
if (term == null)
{
term = new Term(fieldName, nextToken.term());
} else
{
// create from previous to save fieldName.intern overhead
term = term.createTerm(nextToken.term());
}
tf.addTerm(term);
}
}
catch (IOException ioe)
{
throw new RuntimeException("Error constructing terms from index:"