String fieldName=DOMUtils.getAttributeWithInheritanceOrFail(e,"fieldName");
String text=DOMUtils.getNonBlankTextOrFail(e);
BooleanQuery bq=new BooleanQuery(DOMUtils.getAttribute(e,"disableCoord",false));
bq.setMinimumNumberShouldMatch(DOMUtils.getAttribute(e,"minimumNumberShouldMatch",0));
TokenStream ts = analyzer.tokenStream(fieldName, new StringReader(text));
try
{
Token token = ts.next();
Term term = null;
while (token != null)
{
if (term == null)
{
term = new Term(fieldName, token.termText());
} else
{
// create from previous to save fieldName.intern overhead
term = term.createTerm(token.termText());
}
bq.add(new BooleanClause(new TermQuery(term),BooleanClause.Occur.SHOULD));
token = ts.next();
}
}
catch (IOException ioe)
{
throw new RuntimeException("Error constructing terms from index:"
+ ioe);
}
bq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
return bq;