Package org.sindice.siren.search.node

Examples of org.sindice.siren.search.node.NodeBooleanQuery


    this._assertSirenQuery(config, escaped2, "/[a-z]\\*[123]/");

    final HashMap<String, Analyzer> dtAnalyzers = new HashMap<String, Analyzer>();
    dtAnalyzers.put(XSDDatatype.XSD_STRING, new WhitespaceAnalyzer(LuceneTestCase.TEST_VERSION_CURRENT));
    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, dtAnalyzers);
    final NodeBooleanQuery complex = new NodeBooleanQuery();
    complex.add(new NodeRegexpQuery(new Term(df, "[a-z]\\/[123]")), NodeBooleanClause.Occur.MUST);
    complex.add(new NodeTermQuery(new Term(df, "/etc/init.d/")), Occur.MUST);
    complex.add(new NodeTermQuery(new Term(df, "/etc/init[.]d/lucene/")), Occur.SHOULD);
    this._assertSirenQuery(config, complex, "+/[a-z]\\/[123]/ +\"/etc/init.d/\" OR \"/etc\\/init\\[.\\]d/lucene/\" ");

    Query re = new NodeRegexpQuery(new Term(df, "http.*"));
    this._assertSirenQuery(config, re, "/http.*/");

    re = new NodeRegexpQuery(new Term(df, "http~0.5"));
    this._assertSirenQuery(config, re, "/http~0.5/");

    re = new NodeRegexpQuery(new Term(df, "boo"));
    this._assertSirenQuery(config, re, "/boo/");

    this._assertSirenQuery(config, new NodeTermQuery(new Term(df, "/boo/")), "\"/boo/\"");
    this._assertSirenQuery(config, new NodeTermQuery(new Term(df, "/boo/")), "\\/boo\\/");

    config.put(ConfigurationKeys.DEFAULT_OPERATOR, Operator.OR);
    final NodeBooleanQuery two = new NodeBooleanQuery();
    two.add(new NodeRegexpQuery(new Term(df, "foo")), Occur.SHOULD);
    two.add(new NodeRegexpQuery(new Term(df, "bar")), Occur.SHOULD);
    this._assertSirenQuery(config, two, "/foo/ /bar/");

    final NodeRegexpQuery regexpQueryexp = new NodeRegexpQuery(new Term(df, "[abc]?[0-9]"));
    this._assertSirenQuery(config, regexpQueryexp, "/[abc]?[0-9]/");
  }
View Full Code Here


  public static class NodeBooleanQueryBuilder extends NodeQueryBuilder {

    protected NodeBooleanQuery nbq;

    private NodeBooleanQueryBuilder(final BooleanBag[] clauses) {
      nbq = new NodeBooleanQuery();
      for (final BooleanBag bag : clauses) {
        for (final NodeBooleanClause clause : bag.toNodeBooleanClauses()) {
          nbq.add(clause);
        }
      }
View Full Code Here

  public NodeQuery build(final QueryNode queryNode)
  throws QueryNodeException {
    final NodeBooleanQueryNode booleanNode = (NodeBooleanQueryNode) queryNode;
    final List<QueryNode> children = booleanNode.getChildren();
    final NodeBooleanQuery bq = new NodeBooleanQuery();

    if (children == null) {
      return bq; // return empty boolean query
    }

    // If more than one child, wrap them into a NodeBooleanQuery
    if (children.size() > 1) {
      for (final QueryNode child : children) {
        final Object obj = child.getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
        if (obj != null) {
          if (obj instanceof NodeQuery) {
            final QueryNode mod;
            if (child instanceof DatatypeQueryNode) {
              mod = ((DatatypeQueryNode) child).getChild();
            } else {
              mod = child;
            }
            bq.add((NodeQuery) obj,
              NodeQueryBuilderUtil.getModifierValue(mod, NodeBooleanClause.Occur.SHOULD));
          }
          else {
            throw new QueryNodeException(new Error("Expected NodeQuery: got '" +
              obj.getClass().getCanonicalName() + "'"));
View Full Code Here

          QueryParserMessages.LUCENE_QUERY_CONVERSION_ERROR, queryNode
              .toQueryString(new EscapeQuerySyntaxImpl()), queryNode.getClass()
              .getName()));
    }

    return new NodeBooleanQuery();
  }
View Full Code Here

TOP

Related Classes of org.sindice.siren.search.node.NodeBooleanQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.