incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/2] git commit: Fixing issue with trying to use geohash literal in the recursive prefix tree strategy field def.
Date Fri, 26 Dec 2014 22:35:14 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master 89cfdb8d4 -> a9fd70527


Fixing issue with trying to use geohash literal in the recursive prefix tree strategy field
def.


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

Branch: refs/heads/master
Commit: 3d502bfd58bf3d34e7344912f9b31ff4e06ba989
Parents: 89cfdb8
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Fri Dec 26 10:43:36 2014 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Fri Dec 26 10:43:36 2014 -0500

----------------------------------------------------------------------
 .../spatial/BaseSpatialFieldTypeDefinition.java |  3 +++
 ...vePrefixTreeStrategyFieldTypeDefinition.java | 23 ++++++++++++++++++++
 ...ryPrefixTreeStrategyFieldTypeDefinition.java |  3 ---
 3 files changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3d502bfd/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/BaseSpatialFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/BaseSpatialFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/BaseSpatialFieldTypeDefinition.java
index bf29132..1dcc1f5 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/BaseSpatialFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/BaseSpatialFieldTypeDefinition.java
@@ -37,6 +37,9 @@ import com.spatial4j.core.shape.Shape;
 
 public abstract class BaseSpatialFieldTypeDefinition extends CustomFieldTypeDefinition {
 
+  public static final String QUAD = "Quad(";
+  public static final String END = ")";
+  public static final String GEO_HASH = "GeoHash(";
   public static final String GEOHASH_PREFIX_TREE = "GeohashPrefixTree";
   public static final String QUAD_PREFIX_TREE = "QuadPrefixTree";
   public static final String SPATIAL_PREFIX_TREE = "spatialPrefixTree";

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3d502bfd/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.java
index d1c02ce..c43664a 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialRecursivePrefixTreeStrategyFieldTypeDefinition.java
@@ -22,6 +22,11 @@ import org.apache.blur.analysis.type.spatial.lucene.RecursivePrefixTreeStrategy;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
+import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
 import org.apache.lucene.spatial.query.SpatialOperation;
 
 import com.spatial4j.core.context.SpatialContext;
@@ -60,4 +65,22 @@ public class SpatialRecursivePrefixTreeStrategyFieldTypeDefinition extends
BaseS
     addSupportedOperations(SpatialOperation.Contains);
   }
 
+  @Override
+  public Query getCustomQuery(String text) {
+    if (_grid instanceof GeohashPrefixTree) {
+      if (text.startsWith(GEO_HASH)) {
+        int start = text.indexOf(GEO_HASH) + GEO_HASH.length();
+        int end = text.indexOf(END, start);
+        return new TermQuery(new Term(getFieldName(), text.substring(start, end)));
+      }
+    } else if (_grid instanceof QuadPrefixTree) {
+      if (text.startsWith(QUAD)) {
+        int start = text.indexOf(QUAD) + QUAD.length();
+        int end = text.indexOf(END, start);
+        return new TermQuery(new Term(getFieldName(), text.substring(start, end)));
+      }
+    }
+    return super.getCustomQuery(text);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3d502bfd/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition.java
index 8d6d189..933821c 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/spatial/SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition.java
@@ -34,9 +34,6 @@ import com.spatial4j.core.shape.Point;
 
 public class SpatialTermQueryPrefixTreeStrategyFieldTypeDefinition extends BaseSpatialFieldTypeDefinition
{
 
-  private static final String QUAD = "Quad(";
-  private static final String END = ")";
-  private static final String GEO_HASH = "GeoHash(";
   private static final String DOC_VALUE = "docValue";
   public static final String NAME = "geo-termprefix";
   private static final Analyzer _keyword = new KeywordAnalyzer();


Mime
View raw message