List of usage examples for org.apache.lucene.queryparser.xml DOMUtils getNonBlankTextOrFail
public static String getNonBlankTextOrFail(Element e) throws ParserException
From source file:org.apache.solr.search.ChooseOneWordQueryBuilder.java
License:Apache License
public Query implGetQuery(Element e, boolean span) throws ParserException { Term term = null;/*from w w w .j av a 2 s . c om*/ final String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName"); for (Node node = e.getFirstChild(); node != null; node = node.getNextSibling()) { if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("Word")) { final String word = DOMUtils.getNonBlankTextOrFail((Element) node); final Term t = new Term(fieldName, word); if (term == null || term.text().length() < t.text().length()) { term = t; } } } return (span ? new SpanTermQuery(term) : new TermQuery(term)); }