Examples of parseMath()


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

    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);
   
    String a = fmt.format(p.parseMath(""));
View Full Code Here

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

    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);
   
    String a = fmt.format(p.parseMath(""));
    assertEquals("State of DateMathParser changed", e, a);
View Full Code Here

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

    String e = fmt.format(p.parseMath(""));
   
    Date trash = p.parseMath("+7YEARS");
    trash = p.parseMath("/MONTH");
    trash = p.parseMath("-5DAYS+20MINUTES");
    Thread.currentThread().sleep(5);
   
    String a = fmt.format(p.parseMath(""));
    assertEquals("State of DateMathParser changed", e, a);
  }
View Full Code Here

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

    Date trash = p.parseMath("+7YEARS");
    trash = p.parseMath("/MONTH");
    trash = p.parseMath("-5DAYS+20MINUTES");
    Thread.currentThread().sleep(5);
   
    String a = fmt.format(p.parseMath(""));
    assertEquals("State of DateMathParser changed", e, a);
  }
   
  public void testParseMath() throws Exception {
View Full Code Here

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

    badCommands.put("/4", 1);
    badCommands.put("?SECONDS", 0);

    for (String command : badCommands.keySet()) {
      try {
        Date out = p.parseMath(command);
        fail("Didn't generate ParseException for: " + command);
      } catch (ParseException e) {
        assertEquals("Wrong pos for: " + command + " => " + e.getMessage(),
                     badCommands.get(command).intValue(), e.getErrorOffset());
View Full Code Here

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

        // delete anything too old, regardless of other policies
        try {
          if (maxCommitAge != null) {
            if (maxCommitAgeTimeStamp==-1) {
              DateMathParser dmp = new DateMathParser(DateField.UTC, Locale.US);
              maxCommitAgeTimeStamp = dmp.parseMath(maxCommitAge).getTime();
            }
            if (commit.getTimestamp() < maxCommitAgeTimeStamp) {
              commit.delete();
              continue;
            }
View Full Code Here

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

    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    format.setTimeZone(TimeZone.getTimeZone("UTC"));
    DateMathParser dmp = new DateMathParser(TimeZone.getDefault(), Locale.getDefault());

    String s = vri.replaceTokens("${dataimporter.functions.formatDate('NOW/DAY','yyyy-MM-dd HH:mm')}");
    Assert.assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(dmp.parseMath("/DAY")), s);
  }

  @Test
  public void testDefaultNamespace() {
    VariableResolverImpl vri = new VariableResolverImpl();
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')}");
    Assert.assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm")
            .format(dmp.parseMath("/DAY")), s);
    Assert.assertEquals("Hello World", resolver
            .replaceTokens("${dataimporter.functions.test('TEST')}"));
  }

  public static class E extends Evaluator{
View Full Code Here

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

    assertU(delQ("*:*"));
    DateMathParser dmp = new DateMathParser(DateField.UTC, Locale.US);
    String largestDate = "";
    for (int i = 0; i < 10; i++) {
      // 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), "tdate", d));
      if (i == 9) largestDate = d;
    }
    assertU(commit());
    assertQ("Range filter must match only 10 documents", req("q", "*:*", "fq", "tdate:[* TO *]"), "//*[@numFound='10']");
 
View Full Code Here

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

    assertU(delQ("*:*"));
    DateMathParser dmp = new DateMathParser(DateField.UTC, Locale.US);
    String largestDate = "";
    for (int i = 0; i < 10; i++) {
      // 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), "tdate", d));
      if (i == 9) largestDate = d;
    }
    assertU(commit());
    assertQ("Range filter must match only 10 documents", req("q", "*:*", "fq", "tdate:[* TO *]"), "//*[@numFound='10']");
 
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.