incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Fixed BLUR-324
Date Mon, 23 Dec 2013 15:44:14 GMT
Updated Branches:
  refs/heads/master d3526b22e -> 3a9463915


Fixed BLUR-324


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

Branch: refs/heads/master
Commit: 3a9463915c7775ac02fe4647961098c2c6c51d66
Parents: d3526b2
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Dec 23 10:43:40 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Dec 23 10:44:15 2013 -0500

----------------------------------------------------------------------
 .../type/CustomFieldTypeDefinition.java         |   2 +-
 ...lPointVectorStrategyFieldTypeDefinition.java |  10 ++
 ...ntVectorStrategyFieldTypeDefinitionTest.java | 103 +++++++++++++++++++
 3 files changed, 114 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3a946391/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java
index 7e3ecf2..ff04e89 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/CustomFieldTypeDefinition.java
@@ -41,7 +41,7 @@ public abstract class CustomFieldTypeDefinition extends FieldTypeDefinition
{
    * @throws @{@link RuntimeException}.
    */
   @Override
-  public final Analyzer getAnalyzerForIndex(String fieldName) {
+  public Analyzer getAnalyzerForIndex(String fieldName) {
     throw new RuntimeException(NOT_SUPPORTED);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3a946391/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 ace14ee..dc8c098 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
@@ -21,6 +21,8 @@ import java.util.Collection;
 import java.util.Map;
 
 import org.apache.hadoop.conf.Configuration;
+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;
 
@@ -31,7 +33,10 @@ public class SpatialPointVectorStrategyFieldTypeDefinition extends BaseSpatialFi
 
   public static final String NAME = "geo-pointvector";
 
+  private final Analyzer _keywordAnalyzer = new KeywordAnalyzer();
+  
   private Collection<String> _alternateFieldNames;
+  
 
   @Override
   public String getName() {
@@ -53,4 +58,9 @@ public class SpatialPointVectorStrategyFieldTypeDefinition extends BaseSpatialFi
   public Collection<String> getAlternateFieldNames() {
     return _alternateFieldNames;
   }
+  
+  @Override
+  public Analyzer getAnalyzerForIndex(String fieldName) {
+    return _keywordAnalyzer;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3a946391/blur-query/src/test/java/org/apache/blur/analysis/type/spatial/SpatialPointVectorStrategyFieldTypeDefinitionTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/analysis/type/spatial/SpatialPointVectorStrategyFieldTypeDefinitionTest.java
b/blur-query/src/test/java/org/apache/blur/analysis/type/spatial/SpatialPointVectorStrategyFieldTypeDefinitionTest.java
new file mode 100644
index 0000000..336d026
--- /dev/null
+++ b/blur-query/src/test/java/org/apache/blur/analysis/type/spatial/SpatialPointVectorStrategyFieldTypeDefinitionTest.java
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.analysis.type.spatial;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.blur.analysis.BaseFieldManager;
+import org.apache.blur.analysis.FieldTypeDefinition;
+import org.apache.blur.analysis.NoStopWordStandardAnalyzer;
+import org.apache.blur.lucene.search.SuperParser;
+import org.apache.blur.thrift.generated.Column;
+import org.apache.blur.thrift.generated.Record;
+import org.apache.blur.thrift.generated.ScoreType;
+import org.apache.blur.utils.BlurConstants;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryparser.classic.ParseException;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
+import org.junit.Test;
+
+public class SpatialPointVectorStrategyFieldTypeDefinitionTest {
+
+  @Test
+  public void testPointVector() throws IOException, ParseException {
+    BaseFieldManager fieldManager = getFieldManager(new NoStopWordStandardAnalyzer());
+    fieldManager.addColumnDefinitionGisPointVector("fam", "geo");
+
+    Record record = new Record();
+    record.setFamily("fam");
+    record.setRecordId("1234");
+    record.addToColumns(new Column("geo", "77.4011984,39.040444"));
+
+    List<Field> fields = fieldManager.getFields("1234", record);
+
+    IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_43, fieldManager.getAnalyzerForIndex());
+    Directory dir = new RAMDirectory();
+    IndexWriter writer = new IndexWriter(dir, conf);
+    writer.addDocument(fields);
+    writer.close();
+
+    DirectoryReader reader = DirectoryReader.open(dir);
+    IndexSearcher searcher = new IndexSearcher(reader);
+
+    SuperParser parser = new SuperParser(Version.LUCENE_43, fieldManager, true, null, ScoreType.SUPER,
new Term(
+        BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE));
+
+    Query query = parser.parse("fam.geo:\"Intersects(Circle(77.4011984,39.040444 d=10.0m))\"");
+
+    TopDocs topDocs = searcher.search(query, 10);
+
+    assertEquals(1, topDocs.totalHits);
+
+  }
+
+  private BaseFieldManager getFieldManager(Analyzer a) throws IOException {
+    BaseFieldManager fieldManager = new BaseFieldManager(BlurConstants.SUPER, a, new Configuration())
{
+      @Override
+      protected boolean tryToStore(FieldTypeDefinition fieldTypeDefinition, String fieldName)
{
+        return true;
+      }
+
+      @Override
+      protected void tryToLoad(String fieldName) {
+
+      }
+
+      @Override
+      protected List<String> getFieldNamesToLoad() throws IOException {
+        return new ArrayList<String>();
+      }
+    };
+    return fieldManager;
+  }
+
+}


Mime
View raw message