Package org.sindice.siren.analysis

Examples of org.sindice.siren.analysis.IntNumericAnalyzer


  public void testDatatypes1()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    // Set the default datatypes
    final Map<String, Analyzer> datatypes = new HashMap<String, Analyzer>();
    datatypes.put("xsd:int", new IntNumericAnalyzer(4));

    final Analyzer dateAnalyser = new Analyzer() {
      @Override
      protected TokenStreamComponents createComponents(final String fieldName,
                                                       final Reader reader) {
View Full Code Here


  public void testDatatypes2()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    // Set the default datatypes
    final Map<String, Analyzer> datatypes = new HashMap<String, Analyzer>();
    datatypes.put("xsd:int", new IntNumericAnalyzer(4));

    final Analyzer dateAnalyser = new Analyzer() {
      @Override
      protected TokenStreamComponents createComponents(final String fieldName,
                                                       final Reader reader) {
View Full Code Here

  public void testDatatypes3()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    // Set the default datatypes
    final Map<String, Analyzer> datatypes = new HashMap<String, Analyzer>();
    datatypes.put("xsd:int", new IntNumericAnalyzer(4));

    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, datatypes);

    // Test for custom datatypes
    final BooleanQuery bq1 = new BooleanQuery();
View Full Code Here

  public void testDatatypes4()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    // Set the default datatypes
    final Map<String, Analyzer> datatypes = new HashMap<String, Analyzer>();
    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
View Full Code Here

  public void testNumericDatatypeWrongPrecision()
  throws Exception {
    final KeywordQueryParser parser = new KeywordQueryParser();
    // Set the default datatypes
    final Map<String, Analyzer> datatypes = new HashMap<String, Analyzer>();
    datatypes.put("int", new IntNumericAnalyzer(4));
    parser.setDatatypeAnalyzers(datatypes);

    final NodeQuery rangeWrong = NodeNumericRangeQuery.newIntRange(SirenTestCase.DEFAULT_TEST_FIELD, 42, 12, 21, true, true);
    assertEquals(new LuceneProxyNodeQuery(rangeWrong), parser.parse("int([12 TO 21])", SirenTestCase.DEFAULT_TEST_FIELD));
  }
View Full Code Here

  @Test(expected=QueryNodeException.class)
  public void testNumericQuery1()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    final Map<String, Analyzer> datatypes = new HashMap<String, Analyzer>();
    datatypes.put("int", new IntNumericAnalyzer(4));
    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, datatypes);

    parse(config, "int([10 TO bla])");
  }
View Full Code Here

  @Test
  public void testNumericQuery2()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    final Map<String, Analyzer> datatypes = new HashMap<String, Analyzer>();
    datatypes.put("int4", new IntNumericAnalyzer(4));
    datatypes.put("float4", new FloatNumericAnalyzer(4));
    datatypes.put("long4", new LongNumericAnalyzer(4));
    datatypes.put("double4", new DoubleNumericAnalyzer(4));
    config.put(KeywordConfigurationKeys.DATATYPES_ANALYZERS, datatypes);
View Full Code Here

  @Test
  public void testNumericQuery3()
  throws Exception {
    final HashMap<ConfigurationKey, Object> config = new HashMap<ConfigurationKey, Object>();
    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);
View Full Code Here

    // Set the SIREn fields
    codec.addSirenFields("field8", "field4", "field2", "field" + Integer.MAX_VALUE,
      "ascfield8", "ascfield4", "ascfield2",
      "float8", "float4", "float2");
    // Set the datatype analyzers
    tupleAnalyzer.registerDatatype((XSDDatatype.XSD_INT+"8").toCharArray(), new IntNumericAnalyzer(8));
    tupleAnalyzer.registerDatatype((XSDDatatype.XSD_INT+"4").toCharArray(), new IntNumericAnalyzer(4));
    tupleAnalyzer.registerDatatype((XSDDatatype.XSD_INT+"2").toCharArray(), new IntNumericAnalyzer(2));
    tupleAnalyzer.registerDatatype((XSDDatatype.XSD_FLOAT+"8").toCharArray(), new FloatNumericAnalyzer(8));
    tupleAnalyzer.registerDatatype((XSDDatatype.XSD_FLOAT+"4").toCharArray(), new FloatNumericAnalyzer(4));
    tupleAnalyzer.registerDatatype((XSDDatatype.XSD_FLOAT+"2").toCharArray(), new FloatNumericAnalyzer(2));
    tupleAnalyzer.registerDatatype((XSDDatatype.XSD_INT+Integer.MAX_VALUE).toCharArray(), new IntNumericAnalyzer(Integer.MAX_VALUE));

    index.directory = newDirectory();
    index.writer = newRandomIndexWriter(index.directory, tupleAnalyzer, codec);
  }
View Full Code Here

   * container of the numeric configuration, i.e., type and precision step.
   */
  private void initAnalyzers() {
    switch (type) {
      case INTEGER:
        queryAnalyzer = analyzer = new IntNumericAnalyzer(precisionStep);
        break;

      case LONG:
        queryAnalyzer = analyzer = new LongNumericAnalyzer(precisionStep);
        break;
View Full Code Here

TOP

Related Classes of org.sindice.siren.analysis.IntNumericAnalyzer

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.