Example usage for org.apache.lucene.queryparser.xml DOMUtils getNonBlankTextOrFail

List of usage examples for org.apache.lucene.queryparser.xml DOMUtils getNonBlankTextOrFail

Introduction

In this page you can find the example usage for org.apache.lucene.queryparser.xml DOMUtils getNonBlankTextOrFail.

Prototype

public static String getNonBlankTextOrFail(Element e) throws ParserException 

Source Link

Usage

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));
}