Examples of parseMath()


Examples of org.apache.solr.util.DateMathParser.parseMath()

    DateMathParser dmp = new DateMathParser(DateField.UTC, Locale.US);

    for (int i = 0; i < 10; i++) {
      long l = Integer.MAX_VALUE + i*1L;
      // index 10 days starting with today
      String d = format.format(i == 0 ? dmp.parseMath("/DAY") : dmp.parseMath("/DAY+" + i + "DAYS"));
      assertU(adoc("id", String.valueOf(i), "tint", String.valueOf(i),
              "tlong", String.valueOf(l),
              "tfloat", String.valueOf(i * i * 31.11f),
              "tdouble", String.valueOf(i * 2.33d),
              "tdate", d));
View Full Code Here

Examples of org.apache.solr.util.DateMathParser.parseMath()

              "tdouble", String.valueOf(i * 2.33d),
              "tdate", d));
    }
    for (int i = 0; i < 5; i++) {
      long l = Integer.MAX_VALUE + i*1L;
      String d = format.format(i == 0 ? dmp.parseMath("/DAY") : dmp.parseMath("/DAY+" + i + "DAYS"));
      assertU(adoc("id", String.valueOf((i+1)*10), "tint", String.valueOf(i),
              "tlong", String.valueOf(l),
              "tfloat", String.valueOf(i * i * 31.11f),
              "tdouble", String.valueOf(i * 2.33d),
              "tdate", d));
View Full Code Here

Examples of org.apache.solr.util.DateMathParser.parseMath()

              "tdouble", String.valueOf(i * 2.33d),
              "tdate", d));
    }
    for (int i = 0; i < 5; i++) {
      long l = Integer.MAX_VALUE + i*1L;
      String d = format.format(i == 0 ? dmp.parseMath("/DAY") : dmp.parseMath("/DAY+" + i + "DAYS"));
      assertU(adoc("id", String.valueOf((i+1)*10), "tint", String.valueOf(i),
              "tlong", String.valueOf(l),
              "tfloat", String.valueOf(i * i * 31.11f),
              "tdouble", String.valueOf(i * 2.33d),
              "tdate", d));
View Full Code Here

Examples of org.apache.solr.util.DateMathParser.parseMath()

    testFacetField(req, "tfloat", String.valueOf(31.11f), "2");
    testFacetField(req, "tfloat", String.valueOf(5*5*31.11f), "1");
    testFacetField(req, "tdouble", String.valueOf(2.33d), "2");
    testFacetField(req, "tdouble", String.valueOf(5*2.33d), "1");

    testFacetDate(req, "tdate", format.format(dmp.parseMath("/DAY")), "4");
    testFacetDate(req, "tdate", format.format(dmp.parseMath("/DAY+5DAYS")), "2");
  }

  private void checkPrecisionSteps(String fieldType) {
    FieldType type = h.getCore().getSchema().getFieldType(fieldType);
View Full Code Here

Examples of org.apache.solr.util.DateMathParser.parseMath()

    testFacetField(req, "tfloat", String.valueOf(5*5*31.11f), "1");
    testFacetField(req, "tdouble", String.valueOf(2.33d), "2");
    testFacetField(req, "tdouble", String.valueOf(5*2.33d), "1");

    testFacetDate(req, "tdate", format.format(dmp.parseMath("/DAY")), "4");
    testFacetDate(req, "tdate", format.format(dmp.parseMath("/DAY+5DAYS")), "2");
  }

  private void checkPrecisionSteps(String fieldType) {
    FieldType type = h.getCore().getSchema().getFieldType(fieldType);
    if (type instanceof TrieField) {
View Full Code Here

Examples of org.apache.solr.util.DateMathParser.parseMath()

      format.setTimeZone(TimeZone.getTimeZone("UTC"));
      resetEvaluatorBagDateMathParser();
      DateMathParser dmp = new DateMathParser(TimeZone.getDefault(), Locale.getDefault());

      String s = vri.replaceTokens("${dataimporter.functions.formatDate('NOW/DAY','yyyy-MM-dd HH:mm')}");
      assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(dmp.parseMath("/DAY")), s);
    } finally {
      Context.CURRENT_CONTEXT.remove();
    }
  }
View Full Code Here

Examples of org.apache.solr.util.DateMathParser.parseMath()

      resolver.addNamespace("dataimporter.functions", EvaluatorBag
              .getFunctionsNamespace(l,null));
      String s = resolver
              .replaceTokens("${dataimporter.functions.formatDate('NOW/DAY','yyyy-MM-dd HH:mm')}");
      assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm")
              .format(dmp.parseMath("/DAY")), s);
      assertEquals("Hello World", resolver
              .replaceTokens("${dataimporter.functions.test('TEST')}"));
    } finally {
      Context.CURRENT_CONTEXT.remove();
    }
View Full Code Here

Examples of org.apache.solr.util.DateMathParser.parseMath()

    if (null == math || math.equals("")) {
      return p.getNow();
    }
   
    try {
      return p.parseMath(math);
    } catch (ParseException e) {
      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
                               "Invalid Date Math String:'" +val+'\'',e);
    }
  }
View Full Code Here

Examples of org.apache.solr.util.DateMathParser.parseMath()

    if (null == math || math.equals("")) {
      return p.getNow();
    }

    try {
      return p.parseMath(math);
    } catch (ParseException e) {
      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
                               "Invalid Date Math String:'" +val+'\'',e);
    }
  }
View Full Code Here

Examples of org.apache.solr.util.DateMathParser.parseMath()

  public void testParseStatelessness() throws Exception {

    DateMathParser p = new DateMathParser(UTC, Locale.US);
    p.setNow(parser.parse("2001-07-04T12:08:56.235"));

    String e = fmt.format(p.parseMath(""));
   
    Date trash = p.parseMath("+7YEARS");
    trash = p.parseMath("/MONTH");
    trash = p.parseMath("-5DAYS+20MINUTES");
    Thread.currentThread().sleep(5);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.