Package org.sindice.siren.search.node

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


    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, datatypes);

    // Test for custom datatypes
    final BooleanQuery bq1 = new BooleanQuery();
    final NodePrimitiveQuery range1 = NodeNumericRangeQuery
        .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 12, 21, true, true);
    range1.setDatatype("xsd:int");
    bq1.add(new LuceneProxyNodeQuery(range1), BooleanClause.Occur.MUST);
    final Query npq = npq("12", "oct", "2012").setDatatype("xsd:date")
                       .getLuceneProxyQuery();
    bq1.add(npq, BooleanClause.Occur.MUST);
    this._assertSirenQuery(config, bq1, "xsd:int([12 TO 21]) xsd:date(\"12 Oct 2012\")");
View Full Code Here


    // Test for custom datatypes
    final BooleanQuery bq1 = new BooleanQuery();

    final BooleanQuery bq2 = new BooleanQuery();
    final NodePrimitiveQuery range1 = NodeNumericRangeQuery
        .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 12, 21, true, true);
    range1.setDatatype("xsd:int");
    bq2.add(new LuceneProxyNodeQuery(range1), BooleanClause.Occur.MUST);
    final NodePrimitiveQuery range2 = NodeNumericRangeQuery
        .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 12, 12, true, true);
    range2.setDatatype("xsd:int");
    bq2.add(new LuceneProxyNodeQuery(range2), BooleanClause.Occur.MUST);

    bq1.add(bq2, BooleanClause.Occur.MUST);
    final Query npq = npq("12", "oct", "2012").setDatatype("xsd:date")
    .getLuceneProxyQuery();
View Full Code Here

    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, datatypes);

    // Test for custom datatypes
    final BooleanQuery bq1 = new BooleanQuery();
    final NodePrimitiveQuery range1To10 = NodeNumericRangeQuery
        .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 1, 10, true, true);
    range1To10.setDatatype("xsd:int");
    final NodePrimitiveQuery range20To40 = NodeNumericRangeQuery
        .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 20, 40, true, true);
    range20To40.setDatatype("xsd:int");
    bq1.add(new LuceneProxyNodeQuery(range1To10), BooleanClause.Occur.SHOULD);
    bq1.add(new LuceneProxyNodeQuery(range20To40), BooleanClause.Occur.SHOULD);

    final BooleanQuery bq2 = new BooleanQuery();
    final NodePrimitiveQuery range10To15 = NodeNumericRangeQuery
        .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 10, 15, true, true);
    range10To15.setDatatype("xsd:int");
    final NodePrimitiveQuery range50To55 = NodeNumericRangeQuery
        .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 50, 55, true, true);
    range50To55.setDatatype("xsd:int");
    bq2.add(new LuceneProxyNodeQuery(range10To15), BooleanClause.Occur.SHOULD);
    bq2.add(new LuceneProxyNodeQuery(range50To55), BooleanClause.Occur.SHOULD);

    final BooleanQuery bq3 = new BooleanQuery();
    bq3.add(bq1, BooleanClause.Occur.MUST);
View Full Code Here

    datatypes.put("xsd:int", new IntNumericAnalyzer(4));
    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, datatypes);

    // Test for custom datatypes
    final BooleanQuery bq1 = new BooleanQuery();
    final NodePrimitiveQuery range1 = NodeNumericRangeQuery
        .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 1, 1, true, true);
    range1.setDatatype("xsd:int");
    bq1.add(new LuceneProxyNodeQuery(range1), BooleanClause.Occur.MUST);
    final NodePrimitiveQuery range2 = NodeNumericRangeQuery
      .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 2, 2, true, true);
    range2.setDatatype("xsd:int");
    bq1.add(new LuceneProxyNodeQuery(range2), BooleanClause.Occur.MUST_NOT);

    this._assertSirenQuery(config, bq1, "+xsd:int(1) -xsd:int(2)");
    this._assertSirenQuery(config, bq1, "xsd:int(+1 -2)");
  }
View Full Code Here

  }

  private void assertOpenRange(final HashMap<ConfigurationKey, Object> config,
                               final String datatype)
  throws Exception {
    final NodePrimitiveQuery openLeft;
    final NodePrimitiveQuery openRight;

    if (datatype.equals("int4")) {
      openLeft = NodeNumericRangeQuery
          .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, null, 10, true, true);
      openLeft.setDatatype(datatype);
      openRight = NodeNumericRangeQuery
          .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 10, null, true, true);
      openRight.setDatatype(datatype);
    } else if (datatype.equals("float4")) {
      openLeft = NodeNumericRangeQuery
          .newFloatRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, null, 10f, true, true);
      openLeft.setDatatype(datatype);
      openRight = NodeNumericRangeQuery
          .newFloatRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 10f, null, true, true);
      openRight.setDatatype(datatype);
    } else if (datatype.equals("long4")) {
      openLeft = NodeNumericRangeQuery
          .newLongRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, null, 10l, true, true);
      openLeft.setDatatype(datatype);
      openRight = NodeNumericRangeQuery
          .newLongRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 10l, null, true, true);
      openRight.setDatatype(datatype);
    } else {
      openLeft = NodeNumericRangeQuery
          .newDoubleRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, null, 10d, true, true);
      openLeft.setDatatype(datatype);
      openRight = NodeNumericRangeQuery
          .newDoubleRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 10d, null, true, true);
      openRight.setDatatype(datatype);
    }

    this._assertSirenQuery(config, new LuceneProxyNodeQuery(openLeft), datatype + "([* TO 10])");
    this._assertSirenQuery(config, new LuceneProxyNodeQuery(openRight), datatype + "([10 TO *])");
  }
View Full Code Here

    final Map<String, Analyzer> datatypes = new HashMap<String, Analyzer>();
    datatypes.put("int", new IntNumericAnalyzer(4));
    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, datatypes);
    config.put(ConfigurationKeys.DEFAULT_OPERATOR, Operator.OR);

    final NodePrimitiveQuery r1 = NodeNumericRangeQuery
        .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 50, 100, true, true);
    r1.setDatatype("int");
    final NodePrimitiveQuery r2 = NodeNumericRangeQuery
        .newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 100, 500, true, true);
    r2.setDatatype("int");
    final BooleanQuery bq = new BooleanQuery();
    bq.add(new LuceneProxyNodeQuery(r1), BooleanClause.Occur.SHOULD);
    bq.add(new LuceneProxyNodeQuery(r2), BooleanClause.Occur.SHOULD);

    this._assertSirenQuery(config, bq, "int([50 TO 100] OR [100 TO 500])");
View Full Code Here

    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    final Map<String, Analyzer> datatypes = new HashMap<String, Analyzer>();
    datatypes.put("float", new FloatNumericAnalyzer(4));
    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, datatypes);

    final NodePrimitiveQuery q = NodeNumericRangeQuery
        .newFloatRange(SirenTestCase.DEFAULT_TEST_FIELD, 4, 50.5f, 1000.34f, true, true);
    q.setDatatype("float");
    this._assertSirenQuery(config, new LuceneProxyNodeQuery(q), "float([50.5 TO 1000.34])");
  }
View Full Code Here

TOP

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

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.