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-242
Date Tue, 01 Oct 2013 01:55:44 GMT
Updated Branches:
  refs/heads/master bbaf016bf -> 5e7edf81a


Fixed BLUR-242


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

Branch: refs/heads/master
Commit: 5e7edf81ad4a4be74945cf882e3c1f14f193cc37
Parents: bbaf016
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Sep 30 21:55:07 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Sep 30 21:55:41 2013 -0400

----------------------------------------------------------------------
 .../apache/blur/analysis/BaseFieldManager.java  | 22 +++++++++++++++++---
 .../blur/analysis/BaseFieldManagerTest.java     | 18 ++++++++--------
 .../blur/lucene/search/SuperParserTest.java     | 21 +++++++++++++++++++
 3 files changed, 49 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e7edf81/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 55c7d70..56e2e53 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
@@ -50,6 +50,7 @@ import org.apache.blur.utils.BlurConstants;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.AnalyzerWrapper;
+import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.TextField;
@@ -74,6 +75,7 @@ public abstract class BaseFieldManager extends FieldManager {
   private final boolean _strict;
   private final FieldTypeDefinition _fieldLessFieldTypeDefinition;
   private final Configuration _configuration;
+  private final KeywordAnalyzer _keywordAnalyzer = new KeywordAnalyzer();
 
   public static FieldType ID_TYPE;
   static {
@@ -120,6 +122,9 @@ public abstract class BaseFieldManager extends FieldManager {
     _baseAnalyzerForQuery = new AnalyzerWrapper() {
       @Override
       protected Analyzer getWrappedAnalyzer(String fieldName) {
+        if (isBuiltInField(fieldName)) {
+          return _keywordAnalyzer;
+        }
         FieldTypeDefinition fieldTypeDefinition;
         try {
           fieldTypeDefinition = getFieldTypeDefinition(fieldName);
@@ -160,6 +165,17 @@ public abstract class BaseFieldManager extends FieldManager {
     };
   }
 
+  protected boolean isBuiltInField(String fieldName) {
+    if (fieldName.equals(BlurConstants.ROW_ID)) {
+      return true;
+    } else if (fieldName.equals(BlurConstants.RECORD_ID)) {
+      return true;
+    } else if (fieldName.equals(BlurConstants.FAMILY)) {
+      return true;
+    }
+    return false;
+  }
+
   @Override
   public Set<String> getFieldNames() throws IOException {
     return new TreeSet<String>(_fieldNameToDefMap.keySet());
@@ -233,9 +249,9 @@ public abstract class BaseFieldManager extends FieldManager {
     String family = record.getFamily();
     String recordId = record.getRecordId();
 
-    validateNotNull(rowId, "rowId");
-    validateNotNull(family, "family");
-    validateNotNull(recordId, "recordId");
+    validateNotNull(rowId, BlurConstants.ROW_ID);
+    validateNotNull(family, BlurConstants.FAMILY);
+    validateNotNull(recordId, BlurConstants.RECORD_ID);
 
     fields.add(new Field(BlurConstants.FAMILY, family, ID_TYPE));
     fields.add(new Field(BlurConstants.ROW_ID, rowId, ID_TYPE));

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e7edf81/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java b/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java
index 9b1a39d..6038698 100644
--- a/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java
+++ b/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java
@@ -37,7 +37,7 @@ public class BaseFieldManagerTest {
   public static final String _fieldLessField = BlurConstants.SUPER;
 
   @Test
-  public void testFiledManager() throws IOException {
+  public void testFieldManager() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
     memoryFieldManager.addColumnDefinition("fam1", "col1", null, true, "text", null);
 
@@ -56,7 +56,7 @@ public class BaseFieldManagerTest {
   }
 
   @Test
-  public void testFiledManagerMultipleColumnsSameName() throws IOException {
+  public void testFieldManagerMultipleColumnsSameName() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
     memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", null);
 
@@ -77,7 +77,7 @@ public class BaseFieldManagerTest {
   }
 
   @Test
-  public void testFiledManagerMultipleColumnsDifferentNames() throws IOException {
+  public void testFieldManagerMultipleColumnsDifferentNames() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
     memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", null);
     memoryFieldManager.addColumnDefinition("fam1", "col2", null, true, "text", null);
@@ -98,7 +98,7 @@ public class BaseFieldManagerTest {
   }
 
   @Test
-  public void testFiledManagerMultipleColumnsDifferentNamesDifferentFamilies() throws IOException
{
+  public void testFieldManagerMultipleColumnsDifferentNamesDifferentFamilies() throws IOException
{
     BaseFieldManager memoryFieldManager = newFieldManager(true);
     memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", null);
     memoryFieldManager.addColumnDefinition("fam2", "col2", null, false, "text", null);
@@ -127,7 +127,7 @@ public class BaseFieldManagerTest {
   }
 
   @Test
-  public void testFiledManagerSubNameWithMainColumnNameNoParent() throws IOException {
+  public void testFieldManagerSubNameWithMainColumnNameNoParent() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
     try {
       memoryFieldManager.addColumnDefinition("fam1", "col1", "sub1", false, "text", null);
@@ -137,7 +137,7 @@ public class BaseFieldManagerTest {
   }
 
   @Test
-  public void testFiledManagerSubNameWithMainColumnNameNoFieldLess() throws IOException {
+  public void testFieldManagerSubNameWithMainColumnNameNoFieldLess() throws IOException {
     BaseFieldManager memoryFieldManager = newFieldManager(true);
     memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", null);
     try {
@@ -149,9 +149,9 @@ public class BaseFieldManagerTest {
 
   private List<Field> getFields(String family, String rowId, String recordId, Field...
fields) {
     List<Field> fieldLst = new ArrayList<Field>();
-    fieldLst.add(new Field("family", family, BaseFieldManager.ID_TYPE));
-    fieldLst.add(new Field("rowid", rowId, BaseFieldManager.ID_TYPE));
-    fieldLst.add(new Field("recordid", recordId, BaseFieldManager.ID_TYPE));
+    fieldLst.add(new Field(BlurConstants.FAMILY, family, BaseFieldManager.ID_TYPE));
+    fieldLst.add(new Field(BlurConstants.ROW_ID, rowId, BaseFieldManager.ID_TYPE));
+    fieldLst.add(new Field(BlurConstants.RECORD_ID, recordId, BaseFieldManager.ID_TYPE));
     for (Field field : fields) {
       fieldLst.add(field);
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5e7edf81/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 f6c13f2..253ea6f 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
@@ -431,6 +431,27 @@ public class SuperParserTest {
     Query q1 = sq(rq_e("a.id_date", t1, t2));
     assertQuery(q1, q);
   }
+  
+  @Test
+  public void test34() throws ParseException {
+    Query q = parseSq("rowid:123-456");
+    Query q1 = sq(tq("rowid", "123-456"));
+    assertQuery(q1, q);
+  }
+  
+  @Test
+  public void test35() throws ParseException {
+    Query q = parseSq("family:123-456");
+    Query q1 = sq(tq("family", "123-456"));
+    assertQuery(q1, q);
+  }
+  
+  @Test
+  public void test36() throws ParseException {
+    Query q = parseSq("recordid:123-456");
+    Query q1 = sq(tq("recordid", "123-456"));
+    assertQuery(q1, q);
+  }
 
   public static BooleanClause bc_m(Query q) {
     return new BooleanClause(q, Occur.MUST);


Mime
View raw message