incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [8/9] Still broken, but needed to check in the changes I have made thus far.
Date Tue, 02 Jul 2013 23:18:02 GMT
http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4ebe74ef/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 69e74c6..bbfb688 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
@@ -18,15 +18,14 @@ package org.apache.blur.analysis.type;
  */
 import java.util.Map;
 
-import org.apache.blur.analysis.FieldTypeDefinition;
 import org.apache.blur.thrift.generated.Column;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.LongField;
+import org.apache.lucene.search.NumericRangeQuery;
+import org.apache.lucene.search.Query;
 
-public class LongFieldTypeDefinition extends FieldTypeDefinition {
+public class LongFieldTypeDefinition extends NumericFieldTypeDefinition {
 
   public static final String NAME = "long";
   private FieldType _typeStored;
@@ -41,12 +40,12 @@ public class LongFieldTypeDefinition extends FieldTypeDefinition {
   public void configure(Map<String, String> properties) {
     String precisionStepStr = properties.get(NUMERIC_PRECISION_STEP);
     if (precisionStepStr != null) {
-      int precisionStep = Integer.parseInt(precisionStepStr);
+      _precisionStep = Integer.parseInt(precisionStepStr);
       _typeStored = new FieldType(LongField.TYPE_STORED);
-      _typeStored.setNumericPrecisionStep(precisionStep);
+      _typeStored.setNumericPrecisionStep(_precisionStep);
       _typeStored.freeze();
       _typeNotStored = new FieldType(LongField.TYPE_NOT_STORED);
-      _typeNotStored.setNumericPrecisionStep(precisionStep);
+      _typeNotStored.setNumericPrecisionStep(_precisionStep);
       _typeNotStored.freeze();
     } else {
       _typeStored = LongField.TYPE_STORED;
@@ -78,14 +77,10 @@ public class LongFieldTypeDefinition extends FieldTypeDefinition {
   }
 
   @Override
-  public Analyzer getAnalyzerForIndex() {
-    // shouldn't be used ever
-    return new KeywordAnalyzer();
-  }
-
-  @Override
-  public Analyzer getAnalyzerForQuery() {
-    return new KeywordAnalyzer();
+  public Query getNewRangeQuery(String field, String part1, String part2, boolean startInclusive,
boolean endInclusive) {
+    long p1 = Long.parseLong(part1);
+    long p2 = Long.parseLong(part2);
+    return NumericRangeQuery.newLongRange(field, _precisionStep, p1, p2, startInclusive,
endInclusive);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4ebe74ef/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
new file mode 100644
index 0000000..86f9417
--- /dev/null
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/NumericFieldTypeDefinition.java
@@ -0,0 +1,65 @@
+package org.apache.blur.analysis.type;
+
+/**
+ * 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.
+ */
+import org.apache.blur.analysis.FieldTypeDefinition;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.core.KeywordAnalyzer;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.util.NumericUtils;
+
+public abstract class NumericFieldTypeDefinition extends FieldTypeDefinition {
+  
+  protected static final String NUMERIC_PRECISION_STEP = "numericPrecisionStep";
+  
+  protected int _precisionStep = NumericUtils.PRECISION_STEP_DEFAULT;
+
+  @Override
+  public final Analyzer getAnalyzerForIndex() {
+    // shouldn't be used ever
+    return new KeywordAnalyzer();
+  }
+
+  @Override
+  public final Analyzer getAnalyzerForQuery() {
+    return new KeywordAnalyzer();
+  }
+
+  @Override
+  public final boolean checkSupportForFuzzyQuery() {
+    return false;
+  }
+
+  @Override
+  public final boolean checkSupportForWildcardQuery() {
+    return false;
+  }
+
+  @Override
+  public final boolean checkSupportForPrefixQuery() {
+    return false;
+  }
+
+  @Override
+  public final boolean isNumeric() {
+    return true;
+  }
+
+  public abstract Query getNewRangeQuery(String field, String part1, String part2, boolean
startInclusive,
+      boolean endInclusive);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4ebe74ef/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 de0b8d8..a77e4bd 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
@@ -74,4 +74,24 @@ public class StoredFieldTypeDefinition extends FieldTypeDefinition {
     return new KeywordAnalyzer();
   }
 
+  @Override
+  public boolean checkSupportForFuzzyQuery() {
+    return false;
+  }
+
+  @Override
+  public boolean checkSupportForWildcardQuery() {
+    return false;
+  }
+
+  @Override
+  public boolean checkSupportForPrefixQuery() {
+    return false;
+  }
+
+  @Override
+  public boolean isNumeric() {
+    return false;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4ebe74ef/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 6422304..9ac7c8f 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
@@ -75,4 +75,24 @@ public class StringFieldTypeDefinition extends FieldTypeDefinition {
     return new KeywordAnalyzer();
   }
 
+  @Override
+  public boolean checkSupportForFuzzyQuery() {
+    return false;
+  }
+
+  @Override
+  public boolean checkSupportForWildcardQuery() {
+    return false;
+  }
+
+  @Override
+  public boolean checkSupportForPrefixQuery() {
+    return false;
+  }
+
+  @Override
+  public boolean isNumeric() {
+    return false;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4ebe74ef/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 eb05007..914ceb2 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
@@ -86,4 +86,24 @@ public class TextFieldTypeDefinition extends FieldTypeDefinition {
     return new NoStopWordStandardAnalyzer();
   }
 
+  @Override
+  public boolean checkSupportForFuzzyQuery() {
+    return true;
+  }
+
+  @Override
+  public boolean checkSupportForWildcardQuery() {
+    return true;
+  }
+
+  @Override
+  public boolean checkSupportForPrefixQuery() {
+    return true;
+  }
+
+  @Override
+  public boolean isNumeric() {
+    return false;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4ebe74ef/blur-query/src/main/java/org/apache/blur/lucene/search/BlurQueryParser.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/lucene/search/BlurQueryParser.java b/blur-query/src/main/java/org/apache/blur/lucene/search/BlurQueryParser.java
index 5e5022f..26762a6 100644
--- a/blur-query/src/main/java/org/apache/blur/lucene/search/BlurQueryParser.java
+++ b/blur-query/src/main/java/org/apache/blur/lucene/search/BlurQueryParser.java
@@ -20,8 +20,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.blur.analysis.BlurAnalyzer;
-import org.apache.blur.analysis.BlurAnalyzer.TYPE;
+import org.apache.blur.analysis.FieldManager;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.queryparser.classic.QueryParser;
 import org.apache.lucene.search.MatchAllDocsQuery;
@@ -35,20 +34,20 @@ public class BlurQueryParser extends QueryParser {
   public static final String SUPER = "super";
 
   protected final Map<Query, String> _fieldNames;
-  protected final BlurAnalyzer _blurAnalyzer;
+  protected final FieldManager _fieldManager;
 
-  public BlurQueryParser(Version matchVersion, String f, BlurAnalyzer a, Map<Query, String>
fieldNames) {
-    super(matchVersion, f, a);
-    _blurAnalyzer = a;
+  public BlurQueryParser(Version matchVersion, String f, Map<Query, String> fieldNames,
FieldManager fieldManager) {
+    super(matchVersion, f, fieldManager.getAnalyzerForQuery());
     _fieldNames = fieldNames == null ? new HashMap<Query, String>() : fieldNames;
+    _fieldManager = fieldManager;
   }
 
   @Override
   protected Query newFuzzyQuery(Term term, float minimumSimilarity, int prefixLength) {
     String field = term.field();
-    TYPE type = _blurAnalyzer.getTypeLookup(field);
-    if (type != TYPE.TEXT) {
-      throw new RuntimeException("Field [" + field + "] is type [" + type + "] which does
not support fuzzy queries.");
+    if (!_fieldManager.checkSupportForFuzzyQuery(field)) {
+      throw new RuntimeException("Field [" + field + "] is type [" + _fieldManager.getFieldTypeDefinition(field)
+          + "] which does not support fuzzy queries.");
     }
     return addField(super.newFuzzyQuery(term, minimumSimilarity, prefixLength), term.field());
   }
@@ -61,7 +60,6 @@ public class BlurQueryParser extends QueryParser {
   @Override
   protected MultiPhraseQuery newMultiPhraseQuery() {
     return new MultiPhraseQuery() {
-
       @Override
       public void add(Term[] terms, int position) {
         super.add(terms, position);
@@ -87,16 +85,16 @@ public class BlurQueryParser extends QueryParser {
   @Override
   protected Query newPrefixQuery(Term prefix) {
     String field = prefix.field();
-    TYPE type = _blurAnalyzer.getTypeLookup(field);
-    if (type != TYPE.TEXT) {
-      throw new RuntimeException("Field [" + field + "] is type [" + type + "] which does
not support prefix queries.");
+    if (!_fieldManager.checkSupportForPrefixQuery(field)) {
+      throw new RuntimeException("Field [" + field + "] is type [" + _fieldManager.getFieldTypeDefinition(field)
+          + "] which does not support prefix queries.");
     }
     return addField(super.newPrefixQuery(prefix), field);
   }
 
   @Override
   protected Query newRangeQuery(String field, String part1, String part2, boolean startInclusive,
boolean endInclusive) {
-    Query q = _blurAnalyzer.getNewRangeQuery(field, part1, part2, startInclusive, endInclusive);
+    Query q = _fieldManager.getNewRangeQuery(field, part1, part2, startInclusive, endInclusive);
     if (q != null) {
       return addField(q, field);
     }
@@ -106,7 +104,7 @@ public class BlurQueryParser extends QueryParser {
   @Override
   protected Query newTermQuery(Term term) {
     String field = term.field();
-    Query q = _blurAnalyzer.getNewRangeQuery(field, term.text(), term.text(), true, true);
+    Query q = _fieldManager.getTermQueryIfNumeric(field, term.text());
     if (q != null) {
       return addField(q, field);
     }
@@ -119,9 +117,8 @@ public class BlurQueryParser extends QueryParser {
       return new MatchAllDocsQuery();
     }
     String field = t.field();
-    TYPE type = _blurAnalyzer.getTypeLookup(field);
-    if (type != TYPE.TEXT) {
-      throw new RuntimeException("Field [" + field + "] is type [" + type
+    if (!_fieldManager.checkSupportForWildcardQuery(field)) {
+      throw new RuntimeException("Field [" + field + "] is type [" + _fieldManager.getFieldTypeDefinition(field)
           + "] which does not support wildcard queries.");
     }
     return addField(super.newWildcardQuery(t), t.field());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4ebe74ef/blur-query/src/main/java/org/apache/blur/lucene/search/SuperParser.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/lucene/search/SuperParser.java b/blur-query/src/main/java/org/apache/blur/lucene/search/SuperParser.java
index 77622af..2c5c742 100644
--- a/blur-query/src/main/java/org/apache/blur/lucene/search/SuperParser.java
+++ b/blur-query/src/main/java/org/apache/blur/lucene/search/SuperParser.java
@@ -21,7 +21,7 @@ import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.blur.analysis.BlurAnalyzer;
+import org.apache.blur.analysis.FieldManager;
 import org.apache.blur.thrift.generated.ScoreType;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.queryparser.classic.ParseException;
@@ -47,9 +47,9 @@ public class SuperParser extends BlurQueryParser {
   private final Version _matchVersion;
   private final Term _defaultPrimeDocTerm;
 
-  public SuperParser(Version matchVersion, BlurAnalyzer a, boolean superSearch, Filter queryFilter,
+  public SuperParser(Version matchVersion, FieldManager fieldManager, boolean superSearch,
Filter queryFilter,
       ScoreType scoreType, Term defaultPrimeDocTerm) {
-    super(matchVersion, SUPER, a, null);
+    super(matchVersion, SUPER, null, fieldManager);
     _matchVersion = matchVersion;
     _superSearch = superSearch;
     _queryFilter = queryFilter;
@@ -155,7 +155,7 @@ public class SuperParser extends BlurQueryParser {
   }
 
   private QueryParser getNewParser() {
-    return new BlurQueryParser(_matchVersion, SUPER, _blurAnalyzer,_fieldNames);
+    return new BlurQueryParser(_matchVersion, SUPER, _fieldNames,_fieldManager);
   }
 
   private Occur getOccur(String occurString) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4ebe74ef/blur-query/src/test/java/org/apache/blur/analysis/BaseFiledManagerTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/analysis/BaseFiledManagerTest.java b/blur-query/src/test/java/org/apache/blur/analysis/BaseFiledManagerTest.java
index c6559a4..95193aa 100644
--- a/blur-query/src/test/java/org/apache/blur/analysis/BaseFiledManagerTest.java
+++ b/blur-query/src/test/java/org/apache/blur/analysis/BaseFiledManagerTest.java
@@ -27,6 +27,7 @@ import org.apache.blur.analysis.type.TextFieldTypeDefinition;
 import org.apache.blur.thrift.generated.Column;
 import org.apache.blur.thrift.generated.Record;
 import org.apache.blur.utils.BlurConstants;
+import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.Field.Store;
 import org.apache.lucene.document.StringField;
@@ -171,7 +172,7 @@ public class BaseFiledManagerTest {
   }
 
   private BaseFieldManager newBaseFieldManager() {
-    return new BaseFieldManager() {
+    return new BaseFieldManager(new KeywordAnalyzer()) {
       @Override
       protected void tryToStore(String fieldName, boolean fieldLessIndexing, String fieldType,
Map<String, String> props) {
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4ebe74ef/blur-query/src/test/java/org/apache/blur/analysis/BlurAnalyzerTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/analysis/BlurAnalyzerTest.java b/blur-query/src/test/java/org/apache/blur/analysis/BlurAnalyzerTest.java
index 36970b1..48e9c6c 100644
--- a/blur-query/src/test/java/org/apache/blur/analysis/BlurAnalyzerTest.java
+++ b/blur-query/src/test/java/org/apache/blur/analysis/BlurAnalyzerTest.java
@@ -17,143 +17,127 @@ package org.apache.blur.analysis;
  * limitations under the License.
  */
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.apache.blur.thrift.generated.AlternateColumnDefinition;
-import org.apache.blur.thrift.generated.AnalyzerDefinition;
-import org.apache.blur.thrift.generated.ColumnDefinition;
-import org.apache.blur.thrift.generated.ColumnFamilyDefinition;
-import org.junit.Test;
 
 public class BlurAnalyzerTest {
 
-  private static final String STANDARD = "org.apache.lucene.analysis.standard.StandardAnalyzer";
-
-  @Test
-  public void testToAndFromJSONDef1() throws IOException {
-    BlurAnalyzer analyzer = new BlurAnalyzer(getDef1());
-    String json = analyzer.toJSON();
-    BlurAnalyzer analyzer2 = BlurAnalyzer.create(json);
-    assertEquals(analyzer.getAnalyzerDefinition(), analyzer2.getAnalyzerDefinition());
-  }
-
-  @Test
-  public void testStoringOfFieldDef1() throws IOException {
-    BlurAnalyzer analyzer = new BlurAnalyzer(getDef1());
-    assertFalse(analyzer.getFieldType("b.c.sub1").stored());
-    assertTrue(analyzer.getFieldType("b.c").stored());
-  }
-
-  @Test
-  public void testGetSubFieldsDef1() throws IOException {
-    BlurAnalyzer analyzer = new BlurAnalyzer(getDef1());
-    assertNull(analyzer.getSubIndexNames("b.d"));
-    Set<String> subIndexNames = analyzer.getSubIndexNames("b.c");
-    TreeSet<String> set = new TreeSet<String>();
-    set.add("b.c.sub1");
-    set.add("b.c.sub2");
-    assertEquals(set, subIndexNames);
-  }
-
-  @Test
-  public void testFullTextFieldsDef1() throws IOException {
-    BlurAnalyzer analyzer = new BlurAnalyzer(getDef1());
-    assertTrue(analyzer.isFullTextField("a.b"));
-    assertFalse(analyzer.isFullTextField("a.d"));
-  }
-
-  @Test
-  public void testToAndFromJSONDef2() throws IOException {
-    BlurAnalyzer analyzer = new BlurAnalyzer(getDef2());
-    String json = analyzer.toJSON();
-    BlurAnalyzer analyzer2 = BlurAnalyzer.create(json);
-    assertEquals(analyzer.getAnalyzerDefinition(), analyzer2.getAnalyzerDefinition());
-  }
-
-  @Test
-  public void testStoringOfFieldDef2() throws IOException {
-    BlurAnalyzer analyzer = new BlurAnalyzer(getDef2());
-    assertTrue(analyzer.getFieldType("a.b").stored());
-    assertTrue(analyzer.getFieldType("b.c").stored());
-  }
-
-  @Test
-  public void testGetSubFieldsDef2() throws IOException {
-    BlurAnalyzer analyzer = new BlurAnalyzer(getDef2());
-    assertNull(analyzer.getSubIndexNames("b.d"));
-  }
-
-  @Test
-  public void testFullTextFieldsDef2() throws IOException {
-    BlurAnalyzer analyzer = new BlurAnalyzer(getDef2());
-    assertTrue(analyzer.isFullTextField("a.b"));
-    assertFalse(analyzer.isFullTextField("d.a"));
-  }
-  
-  @Test
-  public void testFullTextFieldsDefault() throws IOException {
-    BlurAnalyzer analyzer = new BlurAnalyzer();
-    assertTrue(analyzer.isFullTextField("a.b"));
-    assertTrue(analyzer.isFullTextField("d.a"));
-  }
-
-  private AnalyzerDefinition getDef1() {
-
-    AnalyzerDefinition analyzerDefinition = new AnalyzerDefinition().setDefaultDefinition(
-        new ColumnDefinition(STANDARD, false, null)).setFullTextAnalyzerClassName(STANDARD);
-    Map<String, ColumnFamilyDefinition> colFamDefs = new HashMap<String, ColumnFamilyDefinition>();
-
-    ColumnFamilyDefinition aColFamDef;
-    Map<String, ColumnDefinition> aColDef;
-    Map<String, ColumnDefinition> bColDef;
-    Map<String, ColumnDefinition> cColDef;
-    Map<String, AlternateColumnDefinition> alternates;
-    ColumnFamilyDefinition bColFamDef;
-    ColumnFamilyDefinition cColFamDef;
-    
-    aColFamDef = new ColumnFamilyDefinition();
-    
-    aColDef = new HashMap<String, ColumnDefinition>();
-    aColDef.put("b", new ColumnDefinition(STANDARD, true, null));
-    aColFamDef.setColumnDefinitions(aColDef);
-    colFamDefs.put("a", aColFamDef);
-    
-    bColDef = new HashMap<String, ColumnDefinition>();
-
-    alternates = new HashMap<String, AlternateColumnDefinition>();
-    alternates.put("sub1", new AlternateColumnDefinition(STANDARD));
-    alternates.put("sub2", new AlternateColumnDefinition(STANDARD));
-    bColDef.put("c", new ColumnDefinition(STANDARD, true, alternates));
-
-    bColFamDef = new ColumnFamilyDefinition();
-    bColFamDef.setColumnDefinitions(bColDef);
-    colFamDefs.put("b", bColFamDef);
-    
-    cColFamDef = new ColumnFamilyDefinition();
-    cColDef = new HashMap<String, ColumnDefinition>();
-    cColDef.put("cint", new ColumnDefinition(BlurAnalyzer.TYPE.INTEGER.name(), true, null));
-    cColFamDef.setColumnDefinitions(cColDef);
-    
-    colFamDefs.put("c", cColFamDef);
-
-    analyzerDefinition.setColumnFamilyDefinitions(colFamDefs);
-    return analyzerDefinition;
-  }
-
-  private AnalyzerDefinition getDef2() {
-    AnalyzerDefinition analyzerDefinition = new AnalyzerDefinition().setDefaultDefinition(
-        new ColumnDefinition(STANDARD, false, null)).setFullTextAnalyzerClassName(STANDARD);
-    analyzerDefinition.putToColumnFamilyDefinitions("a",
-        new ColumnFamilyDefinition().setDefaultDefinition(new ColumnDefinition(STANDARD,
true, null)));
-    return analyzerDefinition;
-  }
+//  private static final String STANDARD = "org.apache.lucene.analysis.standard.StandardAnalyzer";
+//
+//  @Test
+//  public void testToAndFromJSONDef1() throws IOException {
+//    BlurAnalyzer analyzer = new BlurAnalyzer(getDef1());
+//    String json = analyzer.toJSON();
+//    BlurAnalyzer analyzer2 = BlurAnalyzer.create(json);
+//    assertEquals(analyzer.getAnalyzerDefinition(), analyzer2.getAnalyzerDefinition());
+//  }
+//
+//  @Test
+//  public void testStoringOfFieldDef1() throws IOException {
+//    BlurAnalyzer analyzer = new BlurAnalyzer(getDef1());
+//    assertFalse(analyzer.getFieldType("b.c.sub1").stored());
+//    assertTrue(analyzer.getFieldType("b.c").stored());
+//  }
+//
+//  @Test
+//  public void testGetSubFieldsDef1() throws IOException {
+//    BlurAnalyzer analyzer = new BlurAnalyzer(getDef1());
+//    assertNull(analyzer.getSubIndexNames("b.d"));
+//    Set<String> subIndexNames = analyzer.getSubIndexNames("b.c");
+//    TreeSet<String> set = new TreeSet<String>();
+//    set.add("b.c.sub1");
+//    set.add("b.c.sub2");
+//    assertEquals(set, subIndexNames);
+//  }
+//
+//  @Test
+//  public void testFullTextFieldsDef1() throws IOException {
+//    BlurAnalyzer analyzer = new BlurAnalyzer(getDef1());
+//    assertTrue(analyzer.isFullTextField("a.b"));
+//    assertFalse(analyzer.isFullTextField("a.d"));
+//  }
+//
+//  @Test
+//  public void testToAndFromJSONDef2() throws IOException {
+//    BlurAnalyzer analyzer = new BlurAnalyzer(getDef2());
+//    String json = analyzer.toJSON();
+//    BlurAnalyzer analyzer2 = BlurAnalyzer.create(json);
+//    assertEquals(analyzer.getAnalyzerDefinition(), analyzer2.getAnalyzerDefinition());
+//  }
+//
+//  @Test
+//  public void testStoringOfFieldDef2() throws IOException {
+//    BlurAnalyzer analyzer = new BlurAnalyzer(getDef2());
+//    assertTrue(analyzer.getFieldType("a.b").stored());
+//    assertTrue(analyzer.getFieldType("b.c").stored());
+//  }
+//
+//  @Test
+//  public void testGetSubFieldsDef2() throws IOException {
+//    BlurAnalyzer analyzer = new BlurAnalyzer(getDef2());
+//    assertNull(analyzer.getSubIndexNames("b.d"));
+//  }
+//
+//  @Test
+//  public void testFullTextFieldsDef2() throws IOException {
+//    BlurAnalyzer analyzer = new BlurAnalyzer(getDef2());
+//    assertTrue(analyzer.isFullTextField("a.b"));
+//    assertFalse(analyzer.isFullTextField("d.a"));
+//  }
+//  
+//  @Test
+//  public void testFullTextFieldsDefault() throws IOException {
+//    BlurAnalyzer analyzer = new BlurAnalyzer();
+//    assertTrue(analyzer.isFullTextField("a.b"));
+//    assertTrue(analyzer.isFullTextField("d.a"));
+//  }
+//
+//  private AnalyzerDefinition getDef1() {
+//
+//    AnalyzerDefinition analyzerDefinition = new AnalyzerDefinition().setDefaultDefinition(
+//        new ColumnDefinition(STANDARD, false, null)).setFullTextAnalyzerClassName(STANDARD);
+//    Map<String, ColumnFamilyDefinition> colFamDefs = new HashMap<String, ColumnFamilyDefinition>();
+//
+//    ColumnFamilyDefinition aColFamDef;
+//    Map<String, ColumnDefinition> aColDef;
+//    Map<String, ColumnDefinition> bColDef;
+//    Map<String, ColumnDefinition> cColDef;
+//    Map<String, AlternateColumnDefinition> alternates;
+//    ColumnFamilyDefinition bColFamDef;
+//    ColumnFamilyDefinition cColFamDef;
+//    
+//    aColFamDef = new ColumnFamilyDefinition();
+//    
+//    aColDef = new HashMap<String, ColumnDefinition>();
+//    aColDef.put("b", new ColumnDefinition(STANDARD, true, null));
+//    aColFamDef.setColumnDefinitions(aColDef);
+//    colFamDefs.put("a", aColFamDef);
+//    
+//    bColDef = new HashMap<String, ColumnDefinition>();
+//
+//    alternates = new HashMap<String, AlternateColumnDefinition>();
+//    alternates.put("sub1", new AlternateColumnDefinition(STANDARD));
+//    alternates.put("sub2", new AlternateColumnDefinition(STANDARD));
+//    bColDef.put("c", new ColumnDefinition(STANDARD, true, alternates));
+//
+//    bColFamDef = new ColumnFamilyDefinition();
+//    bColFamDef.setColumnDefinitions(bColDef);
+//    colFamDefs.put("b", bColFamDef);
+//    
+//    cColFamDef = new ColumnFamilyDefinition();
+//    cColDef = new HashMap<String, ColumnDefinition>();
+//    cColDef.put("cint", new ColumnDefinition(BlurAnalyzer.TYPE.INTEGER.name(), true, null));
+//    cColFamDef.setColumnDefinitions(cColDef);
+//    
+//    colFamDefs.put("c", cColFamDef);
+//
+//    analyzerDefinition.setColumnFamilyDefinitions(colFamDefs);
+//    return analyzerDefinition;
+//  }
+//
+//  private AnalyzerDefinition getDef2() {
+//    AnalyzerDefinition analyzerDefinition = new AnalyzerDefinition().setDefaultDefinition(
+//        new ColumnDefinition(STANDARD, false, null)).setFullTextAnalyzerClassName(STANDARD);
+//    analyzerDefinition.putToColumnFamilyDefinitions("a",
+//        new ColumnFamilyDefinition().setDefaultDefinition(new ColumnDefinition(STANDARD,
true, null)));
+//    return analyzerDefinition;
+//  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4ebe74ef/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 43c5bb9..fab4851 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
@@ -5,13 +5,12 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 import java.util.List;
+import java.util.Map;
 
-import org.apache.blur.analysis.BlurAnalyzer;
+import org.apache.blur.analysis.BaseFieldManager;
 import org.apache.blur.analysis.NoStopWordStandardAnalyzer;
-import org.apache.blur.thrift.generated.AnalyzerDefinition;
-import org.apache.blur.thrift.generated.ColumnDefinition;
-import org.apache.blur.thrift.generated.ColumnFamilyDefinition;
 import org.apache.blur.thrift.generated.ScoreType;
+import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.queryparser.classic.ParseException;
@@ -29,20 +28,36 @@ import org.junit.Test;
 public class SuperParserTest {
 
   private SuperParser parser;
-  private BlurAnalyzer analyzer;
+  private BaseFieldManager _fieldManager;
 
   @Before
   public void setup() {
-    AnalyzerDefinition ad = new AnalyzerDefinition();
-    ad.setDefaultDefinition(new ColumnDefinition(NoStopWordStandardAnalyzer.class.getName(),
true, null));
-    ColumnFamilyDefinition cfDef = new ColumnFamilyDefinition();
-    cfDef.putToColumnDefinitions("id_l", new ColumnDefinition("long", false, null));
-    cfDef.putToColumnDefinitions("id_d", new ColumnDefinition("double", false, null));
-    cfDef.putToColumnDefinitions("id_f", new ColumnDefinition("float", false, null));
-    cfDef.putToColumnDefinitions("id_i", new ColumnDefinition("integer", false, null));
-    ad.putToColumnFamilyDefinitions("a", cfDef);
-    analyzer = new BlurAnalyzer(ad);
-    parser = new SuperParser(LUCENE_VERSION, analyzer, true, null, ScoreType.SUPER, new Term("_primedoc_"));
+//    AnalyzerDefinition ad = new AnalyzerDefinition();
+//    ad.setDefaultDefinition(new ColumnDefinition(NoStopWordStandardAnalyzer.class.getName(),
true, null));
+//    ColumnFamilyDefinition cfDef = new ColumnFamilyDefinition();
+//    cfDef.putToColumnDefinitions("id_l", new ColumnDefinition("long", false, null));
+//    cfDef.putToColumnDefinitions("id_d", new ColumnDefinition("double", false, null));
+//    cfDef.putToColumnDefinitions("id_f", new ColumnDefinition("float", false, null));
+//    cfDef.putToColumnDefinitions("id_i", new ColumnDefinition("integer", false, null));
+//    ad.putToColumnFamilyDefinitions("a", cfDef);
+
+    _fieldManager = getFieldManager(new NoStopWordStandardAnalyzer());
+    parser = new SuperParser(LUCENE_VERSION, _fieldManager, true, null, ScoreType.SUPER,
new Term("_primedoc_"));
+  }
+
+  private BaseFieldManager getFieldManager(Analyzer a) {
+    BaseFieldManager fieldManager = new BaseFieldManager(a) {
+      @Override
+      protected void tryToStore(String fieldName, boolean fieldLessIndexing, String fieldType,
Map<String, String> props) {
+        
+      }
+    };
+    
+    fieldManager.addColumnDefinitionInt("a", "id_i");
+    fieldManager.addColumnDefinitionDouble("a", "id_d");
+    fieldManager.addColumnDefinitionFloat("a", "id_f");
+    fieldManager.addColumnDefinitionLong("a", "id_l");
+    return fieldManager;
   }
 
   @Test
@@ -108,7 +123,7 @@ public class SuperParserTest {
 
   @Test
   public void test5() throws ParseException {
-    parser = new SuperParser(LUCENE_VERSION, new BlurAnalyzer(new WhitespaceAnalyzer(LUCENE_VERSION)),
true, null,
+    parser = new SuperParser(LUCENE_VERSION, getFieldManager(new WhitespaceAnalyzer(LUCENE_VERSION)),
true, null,
         ScoreType.SUPER, new Term("_primedoc_"));
     Query query = parser.parse("super:<a.a:a a.d:{e TO f} a.b:b a.test:hello\\<>
- super:<g.c:c g.d:d>");
 
@@ -135,7 +150,8 @@ public class SuperParserTest {
 
   @Test
   public void test6() throws ParseException {
-    SuperParser parser = new SuperParser(LUCENE_VERSION, analyzer, true, null, ScoreType.SUPER,
new Term("_primedoc_"));
+    //analyzer
+    SuperParser parser = new SuperParser(LUCENE_VERSION, _fieldManager, true, null, ScoreType.SUPER,
new Term("_primedoc_"));
     try {
       parser.parse("super : <a:a d:{e TO d} b:b super:<test:hello\\<>> super:<c:c
d:d>");
       fail();
@@ -391,7 +407,7 @@ public class SuperParserTest {
   }
 
   private Query parseSq(String qstr) throws ParseException {
-    SuperParser superParser = new SuperParser(LUCENE_VERSION, analyzer, true, null, ScoreType.SUPER,
new Term(
+    SuperParser superParser = new SuperParser(LUCENE_VERSION, _fieldManager, true, null,
ScoreType.SUPER, new Term(
         "_primedoc_"));
     return superParser.parse(qstr);
   }


Mime
View raw message