incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: These should have been on the last commit.
Date Tue, 27 Aug 2013 01:26:12 GMT
Updated Branches:
  refs/heads/master bb8913604 -> d098640a1


These should have been on the last commit.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/d098640a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/d098640a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/d098640a

Branch: refs/heads/master
Commit: d098640a16ad93e86f0c1bf49595eabad54c593d
Parents: bb89136
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Aug 26 21:25:53 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Aug 26 21:25:53 2013 -0400

----------------------------------------------------------------------
 .../apache/blur/analysis/BaseFieldManager.java  |  8 ++++
 .../blur/lucene/search/SuperParserTest.java     | 42 ++++++++++++++++++++
 2 files changed, 50 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d098640a/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java b/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
index 92779ac..62c900e 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
@@ -28,6 +28,7 @@ import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
+import org.apache.blur.analysis.type.DateFieldTypeDefinition;
 import org.apache.blur.analysis.type.DoubleFieldTypeDefinition;
 import org.apache.blur.analysis.type.FieldLessFieldTypeDefinition;
 import org.apache.blur.analysis.type.FloatFieldTypeDefinition;
@@ -101,6 +102,7 @@ public abstract class BaseFieldManager extends FieldManager {
     registerType(LongFieldTypeDefinition.class);
     registerType(DoubleFieldTypeDefinition.class);
     registerType(FloatFieldTypeDefinition.class);
+    registerType(DateFieldTypeDefinition.class);
     registerType(SpatialPointVectorStrategyFieldTypeDefinition.class);
     registerType(SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition.class);
     registerType(SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.class);
@@ -445,6 +447,12 @@ public abstract class BaseFieldManager extends FieldManager {
         props);
   }
 
+  public void addColumnDefinitionDate(String family, String columnName, String format) throws
IOException {
+    Map<String, String> props = new HashMap<String, String>();
+    props.put(DateFieldTypeDefinition.DATE_FORMAT, format);
+    addColumnDefinition(family, columnName, null, false, DateFieldTypeDefinition.NAME, props);
+  }
+
   public void addColumnDefinitionInt(String family, String columnName) throws IOException
{
     addColumnDefinition(family, columnName, null, false, IntFieldTypeDefinition.NAME, null);
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d098640a/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java b/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java
index 9ec2784..738fd8c 100644
--- a/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java
+++ b/blur-query/src/test/java/org/apache/blur/lucene/search/SuperParserTest.java
@@ -6,8 +6,11 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.blur.analysis.BaseFieldManager;
 import org.apache.blur.analysis.FieldTypeDefinition;
@@ -73,6 +76,7 @@ public class SuperParserTest {
     fieldManager.addColumnDefinitionDouble("a", "id_d");
     fieldManager.addColumnDefinitionFloat("a", "id_f");
     fieldManager.addColumnDefinitionLong("a", "id_l");
+    fieldManager.addColumnDefinitionDate("a", "id_date","yyyy-MM-dd");
     fieldManager.addColumnDefinitionGisRecursivePrefixTree("a", "id_gis");
     return fieldManager;
   }
@@ -376,6 +380,40 @@ public class SuperParserTest {
     boolean equals = q1.equals(q);
     assertTrue(equals);
   }
+  
+  @Test
+  public void test31() throws ParseException, java.text.ParseException {
+    Query q = parseSq("a.id_date:2013-09-13");
+    Date date = new SimpleDateFormat("yyyy-MM-dd").parse("2013-09-13");
+    long time = date.getTime();
+    long converted = TimeUnit.SECONDS.convert(time, TimeUnit.MILLISECONDS);
+    Query q1 = sq(rq_i("a.id_date", converted, converted));
+    assertQuery(q1, q);
+  }
+  
+  @Test
+  public void test32() throws ParseException, java.text.ParseException {
+    Query q = parseSq("a.id_date:[2013-09-13 TO 2013-11-13]");
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+    Date d1 = simpleDateFormat.parse("2013-09-13");
+    Date d2 = simpleDateFormat.parse("2013-11-13");
+    long t1 = TimeUnit.SECONDS.convert(d1.getTime(), TimeUnit.MILLISECONDS);
+    long t2 = TimeUnit.SECONDS.convert(d2.getTime(), TimeUnit.MILLISECONDS);
+    Query q1 = sq(rq_i("a.id_date", t1, t2));
+    assertQuery(q1, q);
+  }
+  
+  @Test
+  public void test33() throws ParseException, java.text.ParseException {
+    Query q = parseSq("a.id_date:{2013-09-13 TO 2013-11-13}");
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+    Date d1 = simpleDateFormat.parse("2013-09-13");
+    Date d2 = simpleDateFormat.parse("2013-11-13");
+    long t1 = TimeUnit.SECONDS.convert(d1.getTime(), TimeUnit.MILLISECONDS);
+    long t2 = TimeUnit.SECONDS.convert(d2.getTime(), TimeUnit.MILLISECONDS);
+    Query q1 = sq(rq_e("a.id_date", t1, t2));
+    assertQuery(q1, q);
+  }
 
   public static BooleanClause bc_m(Query q) {
     return new BooleanClause(q, Occur.MUST);
@@ -466,6 +504,10 @@ public class SuperParserTest {
   private Query rq_i(String field, long min, long max) {
     return NumericRangeQuery.newLongRange(field, min, max, true, true);
   }
+  
+  private Query rq_e(String field, long min, long max) {
+    return NumericRangeQuery.newLongRange(field, min, max, false, false);
+  }
 
   private BooleanQuery bq(BooleanClause... bcs) {
     BooleanQuery bq = new BooleanQuery();


Mime
View raw message