Example usage for org.springframework.data.solr.core.query Node hasSiblings

List of usage examples for org.springframework.data.solr.core.query Node hasSiblings

Introduction

In this page you can find the example usage for org.springframework.data.solr.core.query Node hasSiblings.

Prototype

public boolean hasSiblings() 

Source Link

Usage

From source file:org.springframework.data.solr.core.QueryParserBase.java

public String createQueryStringFromNode(Node node, int position) {

    StringBuilder query = new StringBuilder();
    if (position > 0) {
        query.append(node.isOr() ? " OR " : " AND ");
    }//from  w  w w  .  ja  v  a 2 s .co m

    if (node.hasSiblings()) {
        if (node.isNegating()) {
            query.append("-");
        }
        if (!node.isRoot() || (node.isRoot() && node.isNegating())) {
            query.append('(');
        }

        int i = 0;
        for (Node nested : node.getSiblings()) {
            query.append(createQueryStringFromNode(nested, i++));
        }

        if (!node.isRoot() || (node.isRoot() && node.isNegating())) {
            query.append(')');
        }
    } else {
        query.append(createQueryFragmentForCriteria((Criteria) node));
    }
    return query.toString();
}