incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [04/18] git commit: BLUR-341 fixed terms not working for numeric fields
Date Wed, 01 Jul 2015 19:29:20 GMT
BLUR-341 fixed terms not working for numeric fields

Signed-off-by: Aaron McCurry <amccurry@gmail.com>


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

Branch: refs/heads/blur-0.2.4-parcel
Commit: 4be05f7541d1f135e1c67edbde7c58154d2a6a2c
Parents: fb83a74
Author: gbarton <garrett.barton@gmail.com>
Authored: Sun Aug 10 15:17:08 2014 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Jun 22 10:09:58 2015 -0400

----------------------------------------------------------------------
 .../apache/blur/analysis/type/DateFieldTypeDefinition.java  | 8 ++++++++
 .../blur/analysis/type/DoubleFieldTypeDefinition.java       | 9 +++++++++
 .../java/org/apache/blur/analysis/type/ExampleType.java     | 6 ++++++
 .../blur/analysis/type/FieldLessFieldTypeDefinition.java    | 6 ++++++
 .../apache/blur/analysis/type/FloatFieldTypeDefinition.java | 9 +++++++++
 .../apache/blur/analysis/type/IntFieldTypeDefinition.java   | 9 +++++++++
 .../apache/blur/analysis/type/LongFieldTypeDefinition.java  | 9 +++++++++
 .../blur/analysis/type/StoredFieldTypeDefinition.java       | 6 ++++++
 .../blur/analysis/type/StringFieldTypeDefinition.java       | 5 +++++
 .../apache/blur/analysis/type/TextFieldTypeDefinition.java  | 6 ++++++
 .../SpatialPointVectorStrategyFieldTypeDefinition.java      | 7 +++++++
 11 files changed, 80 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4be05f75/blur-query/src/main/java/org/apache/blur/analysis/type/DateFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/DateFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/DateFieldTypeDefinition.java
index 5bb4bfb..695cdc3 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/DateFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/DateFieldTypeDefinition.java
@@ -35,6 +35,8 @@ import org.apache.lucene.search.NumericRangeQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.SortField.Type;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.NumericUtils;
 
 public class DateFieldTypeDefinition extends NumericFieldTypeDefinition {
 
@@ -128,4 +130,10 @@ public class DateFieldTypeDefinition extends NumericFieldTypeDefinition
{
     return new SortField(getFieldName(), Type.LONG);
   }
 
+  @Override
+  public String readTerm(BytesRef byteRef) {
+	  if(NumericUtils.getPrefixCodedLongShift(byteRef) == 0)
+		  return _simpleDateFormat.get().format(new Date(NumericUtils.getPrefixCodedLongShift(byteRef)));
+	  return null;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4be05f75/blur-query/src/main/java/org/apache/blur/analysis/type/DoubleFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/DoubleFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/DoubleFieldTypeDefinition.java
index 1df8378..c279dd1 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/DoubleFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/DoubleFieldTypeDefinition.java
@@ -27,6 +27,8 @@ import org.apache.lucene.search.NumericRangeQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.SortField.Type;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.NumericUtils;
 
 public class DoubleFieldTypeDefinition extends NumericFieldTypeDefinition {
 
@@ -103,4 +105,11 @@ public class DoubleFieldTypeDefinition extends NumericFieldTypeDefinition
{
     }
   }
 
+  @Override
+  public String readTerm(BytesRef byteRef) {
+	  if(NumericUtils.getPrefixCodedLongShift(byteRef) == 0)
+		  return NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(byteRef))+"";
+	  return null;
+  }
+  
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4be05f75/blur-query/src/main/java/org/apache/blur/analysis/type/ExampleType.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/ExampleType.java b/blur-query/src/main/java/org/apache/blur/analysis/type/ExampleType.java
index 715e898..ce885e7 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/ExampleType.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/ExampleType.java
@@ -28,6 +28,7 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.util.BytesRef;
 
 public class ExampleType extends CustomFieldTypeDefinition {
 
@@ -113,4 +114,9 @@ public class ExampleType extends CustomFieldTypeDefinition {
     throw new RuntimeException("Sort not supported.");
   }
 
+  @Override
+  public String readTerm(BytesRef byteRef) {
+	return byteRef.utf8ToString();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4be05f75/blur-query/src/main/java/org/apache/blur/analysis/type/FieldLessFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/FieldLessFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/FieldLessFieldTypeDefinition.java
index bfca80d..8ed6e2f 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/FieldLessFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/FieldLessFieldTypeDefinition.java
@@ -27,6 +27,7 @@ import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.search.SortField;
+import org.apache.lucene.util.BytesRef;
 
 public class FieldLessFieldTypeDefinition extends FieldTypeDefinition {
 
@@ -112,4 +113,9 @@ public class FieldLessFieldTypeDefinition extends FieldTypeDefinition
{
   public SortField getSortField(boolean reverse) {
     throw new RuntimeException("Sort not supported.");
   }
+  
+  @Override
+  public String readTerm(BytesRef byteRef) {
+	return byteRef.utf8ToString();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4be05f75/blur-query/src/main/java/org/apache/blur/analysis/type/FloatFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/FloatFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/FloatFieldTypeDefinition.java
index b583810..8cc7e4d 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/FloatFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/FloatFieldTypeDefinition.java
@@ -27,6 +27,8 @@ import org.apache.lucene.search.NumericRangeQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.SortField.Type;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.NumericUtils;
 
 public class FloatFieldTypeDefinition extends NumericFieldTypeDefinition {
 
@@ -102,4 +104,11 @@ public class FloatFieldTypeDefinition extends NumericFieldTypeDefinition
{
       return Float.parseFloat(number);
     }
   }
+  
+  @Override
+  public String readTerm(BytesRef byteRef) {
+	  if(NumericUtils.getPrefixCodedIntShift(byteRef) == 0)
+		  return NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(byteRef))+"";
+	  return null;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4be05f75/blur-query/src/main/java/org/apache/blur/analysis/type/IntFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/IntFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/IntFieldTypeDefinition.java
index f4bb0de..7740421 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/IntFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/IntFieldTypeDefinition.java
@@ -27,6 +27,8 @@ import org.apache.lucene.search.NumericRangeQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.SortField.Type;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.NumericUtils;
 
 public class IntFieldTypeDefinition extends NumericFieldTypeDefinition {
 
@@ -102,4 +104,11 @@ public class IntFieldTypeDefinition extends NumericFieldTypeDefinition
{
       return Integer.parseInt(number);
     }
   }
+
+  @Override
+  public String readTerm(BytesRef byteRef) {
+	  if(NumericUtils.getPrefixCodedIntShift(byteRef) == 0)
+		  return Integer.toString(NumericUtils.getPrefixCodedIntShift(byteRef));
+	  return null;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4be05f75/blur-query/src/main/java/org/apache/blur/analysis/type/LongFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/LongFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/LongFieldTypeDefinition.java
index 0a4faf6..00fd80f 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/LongFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/LongFieldTypeDefinition.java
@@ -27,6 +27,8 @@ import org.apache.lucene.search.NumericRangeQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.SortField.Type;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.NumericUtils;
 
 public class LongFieldTypeDefinition extends NumericFieldTypeDefinition {
 
@@ -103,4 +105,11 @@ public class LongFieldTypeDefinition extends NumericFieldTypeDefinition
{
     }
   }
 
+  @Override
+  public String readTerm(BytesRef byteRef) {
+	  if(NumericUtils.getPrefixCodedLongShift(byteRef) == 0)
+		  return Long.toString(NumericUtils.getPrefixCodedLongShift(byteRef));
+	  return null;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4be05f75/blur-query/src/main/java/org/apache/blur/analysis/type/StoredFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/StoredFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/StoredFieldTypeDefinition.java
index db2441a..87dab3c 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/StoredFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/StoredFieldTypeDefinition.java
@@ -27,6 +27,7 @@ import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.StoredField;
 import org.apache.lucene.search.SortField;
+import org.apache.lucene.util.BytesRef;
 
 public class StoredFieldTypeDefinition extends FieldTypeDefinition {
 
@@ -104,4 +105,9 @@ public class StoredFieldTypeDefinition extends FieldTypeDefinition {
   public SortField getSortField(boolean reverse) {
     throw new RuntimeException("Sort not supported.");
   }
+  
+  @Override
+  public String readTerm(BytesRef byteRef) {
+	return byteRef.utf8ToString();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4be05f75/blur-query/src/main/java/org/apache/blur/analysis/type/StringFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/StringFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/StringFieldTypeDefinition.java
index aff3f8c..eecf7e1 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/StringFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/StringFieldTypeDefinition.java
@@ -126,4 +126,9 @@ public class StringFieldTypeDefinition extends FieldTypeDefinition {
     }
     return new SortField(getFieldName(), Type.STRING);
   }
+
+  @Override
+  public String readTerm(BytesRef byteRef) {
+	return byteRef.utf8ToString();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4be05f75/blur-query/src/main/java/org/apache/blur/analysis/type/TextFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/TextFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/TextFieldTypeDefinition.java
index 049207b..63d9c3e 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/TextFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/TextFieldTypeDefinition.java
@@ -37,6 +37,7 @@ import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.search.SortField;
+import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.Version;
 
 public class TextFieldTypeDefinition extends FieldTypeDefinition {
@@ -183,4 +184,9 @@ public class TextFieldTypeDefinition extends FieldTypeDefinition {
   public SortField getSortField(boolean reverse) {
     throw new RuntimeException("Sort not supported.");
   }
+  
+  @Override
+  public String readTerm(BytesRef byteRef) {
+	return byteRef.utf8ToString();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4be05f75/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialPointVectorStrategyFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialPointVectorStrategyFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialPointVectorStrategyFieldTypeDefinition.java
index dc8c098..043998d 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialPointVectorStrategyFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialPointVectorStrategyFieldTypeDefinition.java
@@ -25,6 +25,7 @@ import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.spatial.query.SpatialOperation;
 import org.apache.lucene.spatial.vector.PointVectorStrategy;
+import org.apache.lucene.util.BytesRef;
 
 import com.spatial4j.core.context.SpatialContext;
 import com.spatial4j.core.shape.Point;
@@ -63,4 +64,10 @@ public class SpatialPointVectorStrategyFieldTypeDefinition extends BaseSpatialFi
   public Analyzer getAnalyzerForIndex(String fieldName) {
     return _keywordAnalyzer;
   }
+  
+  @Override
+  public String readTerm(BytesRef byteRef) {
+	return byteRef.utf8ToString();
+  }
+
 }


Mime
View raw message