lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sim...@apache.org
Subject svn commit: r1088606 [5/5] - in /lucene/dev/branches/realtime_search: ./ dev-tools/eclipse/ dev-tools/idea/solr/ dev-tools/maven/ dev-tools/maven/solr/ dev-tools/maven/solr/contrib/analysis-extras/ dev-tools/maven/solr/contrib/clustering/ dev-tools/mav...
Date Mon, 04 Apr 2011 13:03:48 GMT
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/IndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/IndexSchema.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/IndexSchema.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/IndexSchema.java Mon Apr  4 13:03:42 2011
@@ -20,7 +20,9 @@ package org.apache.solr.schema;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.document.Fieldable;
+import org.apache.lucene.search.DefaultSimilarity;
 import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Similarity;
 import org.apache.lucene.search.SimilarityProvider;
 import org.apache.lucene.queryParser.QueryParser;
 import org.apache.lucene.util.Version;
@@ -28,6 +30,7 @@ import org.apache.solr.common.ResourceLo
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.DOMUtil;
+import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.SystemIdResolver;
 import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.Config;
@@ -37,6 +40,7 @@ import org.apache.solr.analysis.TokenFil
 import org.apache.solr.analysis.TokenizerChain;
 import org.apache.solr.analysis.TokenizerFactory;
 import org.apache.solr.search.SolrQueryParser;
+import org.apache.solr.search.SolrSimilarityProvider;
 import org.apache.solr.util.plugin.AbstractPluginLoader;
 import org.apache.solr.util.plugin.SolrCoreAware;
 import org.w3c.dom.*;
@@ -185,19 +189,22 @@ public final class IndexSchema {
    */
   public Collection<SchemaField> getRequiredFields() { return requiredFields; }
 
-  private SimilarityFactory similarityFactory;
+  private SimilarityProviderFactory similarityProviderFactory;
 
   /**
-   * Returns the Similarity used for this index
+   * Returns the SimilarityProvider used for this index
    */
-  public SimilarityProvider getSimilarityProvider() { return similarityFactory.getSimilarityProvider(); }
+  public SimilarityProvider getSimilarityProvider() { return similarityProviderFactory.getSimilarityProvider(this); }
 
   /**
-   * Returns the SimilarityFactory used for this index
+   * Returns the SimilarityProviderFactory used for this index
    */
-  public SimilarityFactory getSimilarityFactory() { return similarityFactory; }
-
+  public SimilarityProviderFactory getSimilarityProviderFactory() { return similarityProviderFactory; }
 
+  private Similarity fallbackSimilarity;
+  
+  /** fallback similarity, in the case a field doesnt specify */
+  public Similarity getFallbackSimilarity() { return fallbackSimilarity; }
 
   /**
    * Returns the Analyzer used when indexing documents for this index
@@ -387,6 +394,11 @@ public final class IndexSchema {
           expression = "./analyzer[not(@type)] | ./analyzer[@type='index']";
           anode = (Node)xpath.evaluate(expression, node, XPathConstants.NODE);
           Analyzer analyzer = readAnalyzer(anode);
+          
+          // a custom similarity[Factory]
+          expression = "./similarity";
+          anode = (Node)xpath.evaluate(expression, node, XPathConstants.NODE);
+          Similarity similarity = readSimilarity(anode);
 
           if (queryAnalyzer==null) queryAnalyzer=analyzer;
           if (analyzer==null) analyzer=queryAnalyzer;
@@ -394,6 +406,9 @@ public final class IndexSchema {
             ft.setAnalyzer(analyzer);
             ft.setQueryAnalyzer(queryAnalyzer);
           }
+          if (similarity!=null) {
+            ft.setSimilarity(similarity);
+          }
           if (ft instanceof SchemaAware){
             schemaAware.add((SchemaAware) ft);
           }
@@ -491,36 +506,31 @@ public final class IndexSchema {
     // stuff it in a normal array for faster access
     dynamicFields = dFields.toArray(new DynamicField[dFields.size()]);
 
-
     Node node = (Node) xpath.evaluate("/schema/similarity", document, XPathConstants.NODE);
+    Similarity similarity = readSimilarity(node);
+    fallbackSimilarity = similarity == null ? new DefaultSimilarity() : similarity;
+
+    node = (Node) xpath.evaluate("/schema/similarityProvider", document, XPathConstants.NODE);
     if (node==null) {
-      similarityFactory = new SimilarityFactory() {
+      final SolrSimilarityProvider provider = new SolrSimilarityProvider(this);
+      similarityProviderFactory = new SimilarityProviderFactory() {
         @Override
-        public SimilarityProvider getSimilarityProvider() {
-          return IndexSearcher.getDefaultSimilarityProvider();
+        public SolrSimilarityProvider getSimilarityProvider(IndexSchema schema) {
+          return provider;
         }
       };
-      log.debug("using default similarity");
+      log.debug("using default similarityProvider");
     } else {
       final Object obj = loader.newInstance(((Element) node).getAttribute("class"));
-      if (obj instanceof SimilarityFactory) {
-        // configure a factory, get a similarity back
-        SolrParams params = SolrParams.toSolrParams(DOMUtil.childNodesToNamedList(node));
-        similarityFactory = (SimilarityFactory)obj;
-        similarityFactory.init(params);
-      } else {
-        // just like always, assume it's a SimilarityProvider and get a ClassCastException - reasonable error handling
-        similarityFactory = new SimilarityFactory() {
-          @Override
-          public SimilarityProvider getSimilarityProvider() {
-            return (SimilarityProvider) obj;
-          }
-        };
-      }
-      if (similarityFactory instanceof SchemaAware){
-        schemaAware.add((SchemaAware) similarityFactory);
+      // just like always, assume it's a SimilarityProviderFactory and get a ClassCastException - reasonable error handling
+      // configure a factory, get a similarity back
+      NamedList<?> args = DOMUtil.childNodesToNamedList(node);
+      similarityProviderFactory = (SimilarityProviderFactory)obj;
+      similarityProviderFactory.init(args);
+      if (similarityProviderFactory instanceof SchemaAware){
+        schemaAware.add((SchemaAware) similarityProviderFactory);
       }
-      log.debug("using similarity factory" + similarityFactory.getClass().getName());
+      log.debug("using similarityProvider factory" + similarityProviderFactory.getClass().getName());
     }
 
     node = (Node) xpath.evaluate("/schema/defaultSearchField/text()", document, XPathConstants.NODE);
@@ -750,6 +760,30 @@ public final class IndexSchema {
     return newArr;
   }
 
+  private Similarity readSimilarity(Node node) throws XPathExpressionException {
+    if (node==null) {
+      return null;
+    } else {
+      SimilarityFactory similarityFactory;
+      final Object obj = loader.newInstance(((Element) node).getAttribute("class"));
+      if (obj instanceof SimilarityFactory) {
+        // configure a factory, get a similarity back
+        SolrParams params = SolrParams.toSolrParams(DOMUtil.childNodesToNamedList(node));
+        similarityFactory = (SimilarityFactory)obj;
+        similarityFactory.init(params);
+      } else {
+        // just like always, assume it's a Similarity and get a ClassCastException - reasonable error handling
+        similarityFactory = new SimilarityFactory() {
+          @Override
+          public Similarity getSimilarity() {
+            return (Similarity) obj;
+          }
+        };
+      }
+      return similarityFactory.getSimilarity();
+    }
+  }
+
   //
   // <analyzer><tokenizer class="...."/><tokenizer class="...." arg="....">
   //

Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/SimilarityFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/SimilarityFactory.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/SimilarityFactory.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/SimilarityFactory.java Mon Apr  4 13:03:42 2011
@@ -16,7 +16,7 @@ package org.apache.solr.schema;
  * limitations under the License.
  */
 
-import org.apache.lucene.search.SimilarityProvider;
+import org.apache.lucene.search.Similarity;
 import org.apache.solr.common.params.SolrParams;
 
 public abstract class SimilarityFactory {
@@ -25,5 +25,5 @@ public abstract class SimilarityFactory 
   public void init(SolrParams params) { this.params = params; }
   public SolrParams getParams() { return params; }
 
-  public abstract SimilarityProvider getSimilarityProvider();
+  public abstract Similarity getSimilarity();
 }

Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/TrieDateField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/TrieDateField.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/TrieDateField.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/TrieDateField.java Mon Apr  4 13:03:42 2011
@@ -68,7 +68,7 @@ public class TrieDateField extends DateF
   public Date toObject(Fieldable f) {
     byte[] arr = f.getBinaryValue();
     if (arr==null) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,TrieField.badFieldString(f));
-    return new Date(TrieField.toLong(arr));
+    return new Date(TrieFieldHelper.toLong(arr));
   }
 
   @Override
@@ -107,7 +107,7 @@ public class TrieDateField extends DateF
       return;
     }
 
-    writer.writeDate(name,new Date(TrieField.toLong(arr)));
+    writer.writeDate(name,new Date(TrieFieldHelper.toLong(arr)));
   }
 
   @Override
@@ -146,7 +146,7 @@ public class TrieDateField extends DateF
   public String toExternal(Fieldable f) {
     byte[] arr = f.getBinaryValue();
     if (arr==null) return TrieField.badFieldString(f);
-     return super.toExternal(new Date(TrieField.toLong(arr)));
+     return super.toExternal(new Date(TrieFieldHelper.toLong(arr)));
   }
 
   @Override
@@ -187,7 +187,7 @@ public class TrieDateField extends DateF
       ? ((Date)value).getTime() 
       : super.parseMath(null, value.toString()).getTime();
       
-    if (stored) arr = TrieField.toArr(time);
+    if (stored) arr = TrieFieldHelper.toArr(time);
     if (indexed) ts = new NumericTokenStream(ps).setLongValue(time);
 
     Field f;

Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/TrieField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/TrieField.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/TrieField.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/schema/TrieField.java Mon Apr  4 13:03:42 2011
@@ -17,7 +17,6 @@
 package org.apache.solr.schema;
 
 import org.apache.lucene.document.Fieldable;
-import org.apache.lucene.document.Field;
 import org.apache.lucene.search.*;
 import org.apache.lucene.search.cache.CachedArrayCreator;
 import org.apache.lucene.search.cache.DoubleValuesCreator;
@@ -26,8 +25,6 @@ import org.apache.lucene.search.cache.In
 import org.apache.lucene.search.cache.LongValuesCreator;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.NumericUtils;
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.NumericTokenStream;
 import org.apache.noggit.CharArr;
 import org.apache.solr.analysis.*;
 import org.apache.solr.common.SolrException;
@@ -68,6 +65,7 @@ public class TrieField extends FieldType
   protected TrieTypes type;
   protected Object missingValue;
 
+  
   /**
    * Used for handling date types following the same semantics as DateField
    */
@@ -107,15 +105,15 @@ public class TrieField extends FieldType
     if (arr==null) return badFieldString(f);
     switch (type) {
       case INTEGER:
-        return toInt(arr);
+        return TrieFieldHelper.toInt(arr);
       case FLOAT:
-        return toFloat(arr);
+        return TrieFieldHelper.toFloat(arr);
       case LONG:
-        return toLong(arr);
+        return TrieFieldHelper.toLong(arr);
       case DOUBLE:
-        return toDouble(arr);
+        return TrieFieldHelper.toDouble(arr);
       case DATE:
-        return new Date(toLong(arr));
+        return new Date(TrieFieldHelper.toLong(arr));
       default:
         throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + f.name());
     }
@@ -207,19 +205,19 @@ public class TrieField extends FieldType
     }
     switch (type) {
       case INTEGER:
-        writer.writeInt(name,toInt(arr));
+        writer.writeInt(name,TrieFieldHelper.toInt(arr));
         break;
       case FLOAT:
-        writer.writeFloat(name,toFloat(arr));
+        writer.writeFloat(name,TrieFieldHelper.toFloat(arr));
         break;
       case LONG:
-        writer.writeLong(name,toLong(arr));
+        writer.writeLong(name,TrieFieldHelper.toLong(arr));
         break;
       case DOUBLE:
-        writer.writeDouble(name,toDouble(arr));
+        writer.writeDouble(name,TrieFieldHelper.toDouble(arr));
         break;
       case DATE:
-        writer.writeDate(name,new Date(toLong(arr)));
+        writer.writeDate(name,new Date(TrieFieldHelper.toLong(arr)));
         break;
       default:
         throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + f.name());
@@ -293,55 +291,6 @@ public class TrieField extends FieldType
   }
 
 
-  static int toInt(byte[] arr) {
-    return (arr[0]<<24) | ((arr[1]&0xff)<<16) | ((arr[2]&0xff)<<8) | (arr[3]&0xff);
-  }
-  
-  static long toLong(byte[] arr) {
-    int high = (arr[0]<<24) | ((arr[1]&0xff)<<16) | ((arr[2]&0xff)<<8) | (arr[3]&0xff);
-    int low = (arr[4]<<24) | ((arr[5]&0xff)<<16) | ((arr[6]&0xff)<<8) | (arr[7]&0xff);
-    return (((long)high)<<32) | (low&0x0ffffffffL);
-  }
-
-  static float toFloat(byte[] arr) {
-    return Float.intBitsToFloat(toInt(arr));
-  }
-
-  static double toDouble(byte[] arr) {
-    return Double.longBitsToDouble(toLong(arr));
-  }
-
-  static byte[] toArr(int val) {
-    byte[] arr = new byte[4];
-    arr[0] = (byte)(val>>>24);
-    arr[1] = (byte)(val>>>16);
-    arr[2] = (byte)(val>>>8);
-    arr[3] = (byte)(val);
-    return arr;
-  }
-
-  static byte[] toArr(long val) {
-    byte[] arr = new byte[8];
-    arr[0] = (byte)(val>>>56);
-    arr[1] = (byte)(val>>>48);
-    arr[2] = (byte)(val>>>40);
-    arr[3] = (byte)(val>>>32);
-    arr[4] = (byte)(val>>>24);
-    arr[5] = (byte)(val>>>16);
-    arr[6] = (byte)(val>>>8);
-    arr[7] = (byte)(val);
-    return arr;
-  }
-
-  static byte[] toArr(float val) {
-    return toArr(Float.floatToRawIntBits(val));
-  }
-
-  static byte[] toArr(double val) {
-    return toArr(Double.doubleToRawLongBits(val));
-  }
-
-
   @Override
   public String storedToReadable(Fieldable f) {
     return toExternal(f);
@@ -396,15 +345,15 @@ public class TrieField extends FieldType
     if (arr==null) return badFieldString(f);
     switch (type) {
       case INTEGER:
-        return Integer.toString(toInt(arr));
+        return Integer.toString(TrieFieldHelper.toInt(arr));
       case FLOAT:
-        return Float.toString(toFloat(arr));
+        return Float.toString(TrieFieldHelper.toFloat(arr));
       case LONG:
-        return Long.toString(toLong(arr));
+        return Long.toString(TrieFieldHelper.toLong(arr));
       case DOUBLE:
-        return Double.toString(toDouble(arr));
+        return Double.toString(TrieFieldHelper.toDouble(arr));
       case DATE:
-        return dateField.formatDate(new Date(toLong(arr)));
+        return dateField.formatDate(new Date(TrieFieldHelper.toLong(arr)));
       default:
         throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + f.name());
     }
@@ -483,75 +432,53 @@ public class TrieField extends FieldType
 
   @Override
   public Fieldable createField(SchemaField field, Object value, float boost) {
-    boolean indexed = field.indexed();
-    boolean stored = field.stored();
-
-    if (!indexed && !stored) {
+    TrieFieldHelper.FieldInfo info = new TrieFieldHelper.FieldInfo();
+    info.index = field.indexed();
+    info.store = field.stored();
+    info.precisionStep = precisionStep;
+    info.omitNorms = field.omitNorms();
+    info.omitTF = field.omitTf();
+    
+    if (!info.index && !info.store) {
       if (log.isTraceEnabled())
         log.trace("Ignoring unindexed/unstored field: " + field);
       return null;
     }
 
-    int ps = precisionStep;
-
-    byte[] arr=null;
-    TokenStream ts=null;
-    // String indexedVal = indexed && precisionStep==0 ? readableToIndexed(externalVal) : null;
-
     switch (type) {
       case INTEGER:
         int i = (value instanceof Number)
           ? ((Number)value).intValue()
           : Integer.parseInt(value.toString());
-        if (stored) arr = toArr(i);
-        if (indexed) ts = new NumericTokenStream(ps).setIntValue(i);
-        break;
+        return TrieFieldHelper.createIntField(field.getName(), i, info, boost);
+
       case FLOAT:
         float f = (value instanceof Number)
           ? ((Number)value).floatValue()
           : Float.parseFloat(value.toString());
-        if (stored) arr = toArr(f);
-        if (indexed) ts = new NumericTokenStream(ps).setFloatValue(f);
-        break;
+        return TrieFieldHelper.createFloatField(field.getName(), f, info, boost);
+        
       case LONG:
         long l = (value instanceof Number)
           ? ((Number)value).longValue()
           : Long.parseLong(value.toString());
-        if (stored) arr = toArr(l);
-        if (indexed) ts = new NumericTokenStream(ps).setLongValue(l);
-        break;
+        return TrieFieldHelper.createLongField(field.getName(), l, info, boost);
+          
       case DOUBLE:
         double d = (value instanceof Number)
           ? ((Number)value).doubleValue()
           : Double.parseDouble(value.toString());
-        if (stored) arr = toArr(d);
-        if (indexed) ts = new NumericTokenStream(ps).setDoubleValue(d);
-        break;
+        return TrieFieldHelper.createDoubleField(field.getName(), d, info, boost);
+        
       case DATE:
-        long time = (value instanceof Date)
-          ? ((Date)value).getTime()
-          : dateField.parseMath(null, value.toString()).getTime();
-        if (stored) arr = toArr(time);
-        if (indexed) ts = new NumericTokenStream(ps).setLongValue(time);
-        break;
+        Date date = (value instanceof Date)
+          ? ((Date)value)
+          : dateField.parseMath(null, value.toString());
+        return TrieFieldHelper.createDateField(field.getName(), date, info, boost);
+        
       default:
         throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
     }
-
-    Field f;
-    if (stored) {
-      f = new Field(field.getName(), arr);
-      if (indexed) f.setTokenStream(ts);
-    } else {
-      f = new Field(field.getName(), ts);
-    }
-
-    // term vectors aren't supported
-
-    f.setOmitNorms(field.omitNorms());
-    f.setOmitTermFreqAndPositions(field.omitTf());
-    f.setBoost(boost);
-    return f;
   }
 
   public enum TrieTypes {

Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/ReturnFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/ReturnFields.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/ReturnFields.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/ReturnFields.java Mon Apr  4 13:03:42 2011
@@ -195,7 +195,7 @@ public class ReturnFields
 
         if (field == null) {
           // We didn't find a simple name, so let's see if it's a globbed field name.
-          // Globbing only works with recommended field names.
+          // Globbing only works with field names of the recommended form (roughly like java identifiers)
 
           field = sp.getGlobbedId(null);
           ch = sp.ch();
@@ -260,6 +260,18 @@ public class ReturnFields
           }
 
           if (key==null) {
+            SolrParams localParams = parser.getLocalParams();
+            if (localParams != null) {
+              key = localParams.get("key");
+            }
+            if (key == null) {
+              // use the function name itself as the field name
+              key = sp.val.substring(start, sp.pos);
+            }
+          }
+
+
+          if (key==null) {
             key = funcStr;
           }
           okFieldNames.add( key );
@@ -293,7 +305,7 @@ public class ReturnFields
   private void addField( String field, String key, DocTransformers augmenters, SolrQueryRequest req )
   {
     String disp = (key==null) ? field : key;
-    fields.add( field ); // need to put in the map to maintain order for things like CSVResponseWriter
+    fields.add(field); // need to put in the map to maintain order for things like CSVResponseWriter
     okFieldNames.add( field );
     okFieldNames.add( key );
     // a valid field name
@@ -315,7 +327,7 @@ public class ReturnFields
 
       TransformerFactory factory = req.getCore().getTransformerFactory( name );
       if( factory != null ) {
-        augmenters.addTransformer( factory.create(disp, args) );
+        augmenters.addTransformer( factory.create(disp, args, req) );
       }
       else {
         // unknown field?

Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/SolrQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/SolrQueryParser.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/SolrQueryParser.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/search/SolrQueryParser.java Mon Apr  4 13:03:42 2011
@@ -122,9 +122,9 @@ public class SolrQueryParser extends Que
     SchemaField sf = schema.getFieldOrNull(field);
     if (sf != null) {
       FieldType ft = sf.getType();
-      // delegate to type for everything except TextField
-      if (ft instanceof TextField) {
-        return super.getFieldQuery(field, queryText, quoted || ((TextField)ft).getAutoGeneratePhraseQueries());
+      // delegate to type for everything except tokenized fields
+      if (ft.isTokenized()) {
+        return super.getFieldQuery(field, queryText, quoted || (ft instanceof TextField && ((TextField)ft).getAutoGeneratePhraseQueries()));
       } else {
         return sf.getType().getFieldQuery(parser, sf, queryText);
       }

Modified: lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/index.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/index.xml?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/index.xml (original)
+++ lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/index.xml Mon Apr  4 13:03:42 2011
@@ -68,27 +68,32 @@ customization is required.
       <title>News</title>
             <section>
    <title>March 2011 - Solr 3.1 Released</title>
+  <p>The Lucene PMC is pleased to announce the release of <a href="http://www.apache.org/dyn/closer.cgi/lucene/solr">Apache Solr 3.1</a>!
+  </p> 
    <p>
-     Solr 3.1 has been released and is now available for public <a href="http://www.apache.org/dyn/closer.cgi/lucene/solr/">download</a>!
-     
-   New Solr 3.1 features include
+    Solr's version number was synced with Lucene following the Lucene/Solr merge, so Solr 3.1 contains Lucene 3.1.
+    Solr 3.1 is the first release after Solr 1.4.1.
+   </p>
+  <p>
+   Solr 3.1 release highlights include
  </p>
   <ul>
-    <li>Improved geospatial support</li>
-    <li>Sorting by function queries</li>
-    <li>Range faceting on all numeric fields</li>
-    <li>Example Velocity driven search UI at http://localhost:8983/solr/browse</li>
-    <li>A new termvector-based highlighter</li>
-    <li>Improved spellchecking capabilities</li>
-    <li>Improved integration with Apache Lucene</li>
-    <li>New autosuggest component</li>
-    <li>Distributed support for more components</li>
-    <li>JSON document indexing and CSV response format</li>
-    <li>Apache UIMA integration for metadata extraction</li>
-    <li>Many other Bugfixes, improvements and optimizations</li>
+    <li><a href="http://wiki.apache.org/solr/SimpleFacetParameters#Facet_by_Range">Numeric range facets</a> (similar to date faceting).</li>
+    <li>New <a href="http://wiki.apache.org/solr/SpatialSearch">spatial search</a>, including spatial filtering, boosting and sorting capabilities.</li>
+    <li>Example Velocity driven search UI at <a href="http://localhost:8983/solr/browse">http://localhost:8983/solr/browse</a></li>
+    <li>A new faster <a href="http://wiki.apache.org/solr/HighlightingParameters">termvector-based highlighter</a>.</li>
+    <li>Extended dismax (edismax) query parser with support for fielded queries, enhanced relevancy, and full lucene syntax support.</li>
+    <li>Distributed search support for the <a href="http://wiki.apache.org/solr/SpellCheckComponent">Spell check</a>
+ and <a href="http://wiki.apache.org/solr/TermsComponent">Terms</a> components.</li>
+    <li><a href="http://wiki.apache.org/solr/Suggester">Suggester</a>, a fast trie-based autocomplete component.</li>
+    <li>Sort results by any <a href="http://wiki.apache.org/solr/FunctionQuery#Sort_By_Function any function">function query</a>.</li>
+    <li><a href="http://wiki.apache.org/solr/UpdateJSON">JSON document indexing</a>.</li>
+    <li><a href="http://wiki.apache.org/solr/CSVResponseWriter">CSV response format</a></li>
+    <li><a href="http://wiki.apache.org/solr/SolrUIMA">Apache UIMA integration</a> for metadata extraction.</li>
+    <li>Tons of optimizations, bugfixes, and new analysis capabilities via <a href="http://lucene.apache.org/java/docs/index.html">Apache Lucene 3.1</a>.</li>
   </ul>
      
-	<p>See the <a href="http://svn.apache.org/repos/asf/lucene/dev/tags/lucene_solr_3_1/solr/CHANGES.txt">release notes</a> for more details.
+  <p>See the <a href="http://svn.apache.org/repos/asf/lucene/dev/tags/lucene_solr_3_1/solr/CHANGES.txt">release notes</a> for a more complete list of all the new features, improvements, and bugfixes.
  </p>
 
 </section>

Modified: lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/site.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/site.xml?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/site.xml (original)
+++ lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/site.xml Mon Apr  4 13:03:42 2011
@@ -42,12 +42,13 @@ See http://forrest.apache.org/docs/linki
   </about>
 
   <docs label="Documentation">
-    <features    label="Features"         href="features.html" />
-    <tutorial    label="Tutorial"         href="tutorial.html" />
-    <wiki        label="Docs (Wiki)" href="ext:wiki" />
-    <faq         label="FAQ"              href="ext:faq" />
-    <apidocs     label="All Javadoc"     href="api/index.html" />
-    <apidocs     label="SolrJ Javadoc"     href="api/solrj/index.html" />
+    <features    label="Features"                href="features.html" />
+    <tutorial    label="Tutorial"                href="tutorial.html" />
+    <wiki        label="Docs (Wiki)"             href="ext:wiki" />
+    <faq         label="FAQ"                     href="ext:faq" />
+    <apidocs     label="All Javadoc"             href="api/index.html" />
+    <apidocs     label="SolrJ Javadoc"           href="api/solrj/index.html" />
+    <apidocs     label="Test Framework Javadoc"  href="api/test-framework/index.html" />
   </docs>
 
   <resources label="Resources">

Modified: lucene/dev/branches/realtime_search/solr/src/test-files/solr/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test-files/solr/conf/schema.xml?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test-files/solr/conf/schema.xml (original)
+++ lucene/dev/branches/realtime_search/solr/src/test-files/solr/conf/schema.xml Mon Apr  4 13:03:42 2011
@@ -391,6 +391,32 @@
 
   <fieldType name="latLon" class="solr.LatLonType" subFieldType="double"/>
 
+  <!--  some per-field similarity examples -->
+  
+  <!--  specify a Similarity classname directly -->
+  <fieldType name="sim1" class="solr.TextField">
+    <analyzer>
+      <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+    </analyzer>
+    <similarity class="org.apache.lucene.misc.SweetSpotSimilarity"/>
+  </fieldType>
+
+  <!--  specify a Similarity factory -->  
+  <fieldType name="sim2" class="solr.TextField">
+    <analyzer>
+      <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+    </analyzer>
+    <similarity class="org.apache.solr.schema.CustomSimilarityFactory">
+      <str name="echo">is there an echo?</str>
+    </similarity>
+  </fieldType>
+  
+  <!-- don't specify any sim at all: get the default  -->
+  <fieldType name="sim3" class="solr.TextField">
+    <analyzer>
+      <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+    </analyzer>
+  </fieldType>
  </types>
 
 
@@ -496,6 +522,9 @@
    <field name="multiDefault" type="string" indexed="true" stored="true" default="muLti-Default" multiValued="true"/>
    <field name="intDefault" type="int" indexed="true" stored="true" default="42" multiValued="false"/>
 
+   <field name="sim1text" type="sim1" indexed="true" stored="true"/>
+   <field name="sim2text" type="sim2" indexed="true" stored="true"/>
+   <field name="sim3text" type="sim3" indexed="true" stored="true"/>
 
    <field name="tlong" type="tlong" indexed="true" stored="true" />
 
@@ -574,6 +603,10 @@
 
    <dynamicField name="*_mfacet" type="string" indexed="true" stored="false" multiValued="true" />
 
+   <!-- make sure custom sims work with dynamic fields -->
+   <dynamicField name="*_sim1" type="sim1" indexed="true" stored="true"/>
+   <dynamicField name="*_sim2" type="sim2" indexed="true" stored="true"/>
+   <dynamicField name="*_sim3" type="sim3" indexed="true" stored="true"/>
  </fields>
 
  <defaultSearchField>text</defaultSearchField>
@@ -607,12 +640,18 @@
    <!-- dynamic destination -->
    <copyField source="*_dynamic" dest="dynamic_*"/>
 
- <!-- Similarity is the scoring routine for each document vs a query.
-      A custom similarity may be specified here, but the default is fine
+ <!-- expert: SimilarityProvider contains scoring routines that are not field-specific,
+      such as coord() and queryNorm(). most scoring customization happens in the fieldtype.
+      A custom similarity provider may be specified here, but the default is fine
       for most applications.
  -->
- <similarity class="org.apache.solr.schema.CustomSimilarityFactory">
+ <similarityProvider class="org.apache.solr.schema.CustomSimilarityProviderFactory">
    <str name="echo">is there an echo?</str>
- </similarity>
+ </similarityProvider>
 
+ <!-- default similarity, unless otherwise specified by the fieldType
+  -->
+ <similarity class="org.apache.solr.schema.CustomSimilarityFactory">
+   <str name="echo">I am your default sim</str>
+ </similarity>
 </schema>

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java Mon Apr  4 13:03:42 2011
@@ -24,6 +24,7 @@ import org.apache.solr.client.solrj.requ
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.util.ExternalPaths;
 
 /**
  * Abstract base class for testing merge indexes command
@@ -37,7 +38,7 @@ public abstract class MergeIndexesExampl
 
   @Override
   public String getSolrHome() {
-    return SolrJettyTestBase.EXAMPLE_MULTICORE_HOME;
+    return ExternalPaths.EXAMPLE_MULTICORE_HOME;
   }
 
   @Override

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java Mon Apr  4 13:03:42 2011
@@ -25,6 +25,7 @@ import org.apache.solr.client.solrj.resp
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.util.ExternalPaths;
 
 
 /**
@@ -36,7 +37,7 @@ public abstract class MultiCoreExampleTe
   // protected static final CoreContainer cores = new CoreContainer();
   protected static CoreContainer cores;
 
-  @Override public String getSolrHome() { return SolrJettyTestBase.EXAMPLE_MULTICORE_HOME; }
+  @Override public String getSolrHome() { return ExternalPaths.EXAMPLE_MULTICORE_HOME; }
   
   @Override public String getSchemaFile()     { return getSolrHome()+"/core0/conf/schema.xml";     }
   @Override public String getSolrConfigFile() { return getSolrHome()+"/core0/conf/solrconfig.xml"; }

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java Mon Apr  4 13:03:42 2011
@@ -22,6 +22,7 @@ import org.apache.solr.client.solrj.Solr
 import org.apache.solr.client.solrj.impl.BinaryRequestWriter;
 import org.apache.solr.client.solrj.impl.BinaryResponseParser;
 import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
+import org.apache.solr.util.ExternalPaths;
 import org.junit.BeforeClass;
 
 
@@ -32,7 +33,7 @@ import org.junit.BeforeClass;
 public class SolrExampleBinaryTest extends SolrExampleTests {
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(EXAMPLE_HOME, null, null);
+    createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
   }
 
   @Override

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrJettyTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrJettyTestBase.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrJettyTestBase.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrJettyTestBase.java Mon Apr  4 13:03:42 2011
@@ -24,6 +24,7 @@ import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
+import org.apache.solr.util.ExternalPaths;
 import org.junit.AfterClass;
 
 abstract public class SolrJettyTestBase extends SolrTestCaseJ4 
@@ -32,7 +33,7 @@ abstract public class SolrJettyTestBase 
   // using configs in the test directory allows more flexibility to change "example"
   // without breaking configs.
 
-  public String getSolrHome() { return EXAMPLE_HOME; }
+  public String getSolrHome() { return ExternalPaths.EXAMPLE_HOME; }
 
   public static JettySolrRunner jetty;
   public static int port;

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java Mon Apr  4 13:03:42 2011
@@ -22,6 +22,7 @@ import org.apache.solr.client.solrj.impl
 import org.apache.solr.client.solrj.request.RequestWriter;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.util.ExternalPaths;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -38,7 +39,7 @@ public class TestBatchUpdate extends Sol
 
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(EXAMPLE_HOME, null, null);
+    createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
   }
 
   static final int numdocs = 1000;  

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java Mon Apr  4 13:03:42 2011
@@ -26,6 +26,7 @@ import org.apache.lucene.util.LuceneTest
 import org.apache.commons.io.IOUtils;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.SolrJettyTestBase;
+import org.apache.solr.util.ExternalPaths;
 import org.mortbay.jetty.Connector;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.bio.SocketConnector;
@@ -47,13 +48,13 @@ public class JettyWebappTest extends Luc
   public void setUp() throws Exception 
   {
     super.setUp();
-    System.setProperty("solr.solr.home", SolrJettyTestBase.EXAMPLE_HOME);
+    System.setProperty("solr.solr.home", ExternalPaths.EXAMPLE_HOME);
     
     File dataDir = new File(SolrTestCaseJ4.TEMP_DIR,
         getClass().getName() + "-" + System.currentTimeMillis());
     dataDir.mkdirs();
     System.setProperty("solr.data.dir", dataDir.getCanonicalPath());
-    String path = SolrJettyTestBase.WEBAPP_HOME;
+    String path = ExternalPaths.WEBAPP_HOME;
 
     server = new Server(port);
     // insecure: only use for tests!!!!

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java Mon Apr  4 13:03:42 2011
@@ -17,6 +17,7 @@
 package org.apache.solr.client.solrj.embedded;
 
 import org.apache.solr.client.solrj.LargeVolumeTestBase;
+import org.apache.solr.util.ExternalPaths;
 import org.junit.BeforeClass;
 
 /**
@@ -26,6 +27,6 @@ import org.junit.BeforeClass;
 public class LargeVolumeBinaryJettyTest extends LargeVolumeTestBase {
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(EXAMPLE_HOME, null, null);
+    createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
   }
 }

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeEmbeddedTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeEmbeddedTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeEmbeddedTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeEmbeddedTest.java Mon Apr  4 13:03:42 2011
@@ -18,11 +18,12 @@
 package org.apache.solr.client.solrj.embedded;
 
 import org.apache.solr.client.solrj.LargeVolumeTestBase;
+import org.apache.solr.util.ExternalPaths;
 import org.junit.BeforeClass;
 
 public class LargeVolumeEmbeddedTest extends LargeVolumeTestBase {
   @BeforeClass
   public static void beforeTest() throws Exception {
-    initCore(EXAMPLE_CONFIG, EXAMPLE_SCHEMA, EXAMPLE_HOME);
+    initCore(ExternalPaths.EXAMPLE_CONFIG, ExternalPaths.EXAMPLE_SCHEMA, ExternalPaths.EXAMPLE_HOME);
   }
 }

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java Mon Apr  4 13:03:42 2011
@@ -18,11 +18,12 @@
 package org.apache.solr.client.solrj.embedded;
 
 import org.apache.solr.client.solrj.LargeVolumeTestBase;
+import org.apache.solr.util.ExternalPaths;
 import org.junit.BeforeClass;
 
 public class LargeVolumeJettyTest extends LargeVolumeTestBase {
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(EXAMPLE_HOME, null, null);
+    createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
   }
 }

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java Mon Apr  4 13:03:42 2011
@@ -18,6 +18,7 @@
 package org.apache.solr.client.solrj.embedded;
 
 import org.apache.solr.client.solrj.SolrExampleTests;
+import org.apache.solr.util.ExternalPaths;
 import org.junit.BeforeClass;
 
 /**
@@ -30,6 +31,6 @@ public class SolrExampleEmbeddedTest ext
 
   @BeforeClass
   public static void beforeTest() throws Exception {
-    initCore(EXAMPLE_CONFIG, EXAMPLE_SCHEMA, EXAMPLE_HOME);
+    initCore(ExternalPaths.EXAMPLE_CONFIG, ExternalPaths.EXAMPLE_SCHEMA, ExternalPaths.EXAMPLE_HOME);
   }
 }

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java Mon Apr  4 13:03:42 2011
@@ -19,6 +19,7 @@ package org.apache.solr.client.solrj.emb
 
 import org.apache.solr.client.solrj.SolrExampleTests;
 import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
+import org.apache.solr.util.ExternalPaths;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -33,7 +34,7 @@ public class SolrExampleJettyTest extend
 
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(EXAMPLE_HOME, null, null);
+    createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
   }
 
   @Test

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java Mon Apr  4 13:03:42 2011
@@ -21,6 +21,7 @@ import org.apache.solr.client.solrj.Solr
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
 import org.apache.solr.client.solrj.impl.StreamingUpdateSolrServer;
+import org.apache.solr.util.ExternalPaths;
 import org.junit.BeforeClass;
 
 
@@ -32,7 +33,7 @@ import org.junit.BeforeClass;
 public class SolrExampleStreamingTest extends SolrExampleTests {
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(EXAMPLE_HOME, null, null);
+    createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
   }
 
   @Override

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java Mon Apr  4 13:03:42 2011
@@ -24,6 +24,7 @@ import org.apache.solr.client.solrj.Solr
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.client.solrj.request.QueryRequest;
 import org.apache.solr.client.solrj.response.TermsResponse.Term;
+import org.apache.solr.util.ExternalPaths;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -35,7 +36,7 @@ public class TermsResponseTest extends S
 
   @BeforeClass
   public static void beforeTest() throws Exception {
-    initCore(EXAMPLE_CONFIG, EXAMPLE_SCHEMA, EXAMPLE_HOME);
+    initCore(ExternalPaths.EXAMPLE_CONFIG, ExternalPaths.EXAMPLE_SCHEMA, ExternalPaths.EXAMPLE_HOME);
   }
   
   @Before

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java Mon Apr  4 13:03:42 2011
@@ -25,6 +25,7 @@ import org.apache.solr.client.solrj.resp
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.SpellingParams;
+import org.apache.solr.util.ExternalPaths;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -40,7 +41,7 @@ public class TestSpellCheckResponse exte
   @BeforeClass
   public static void beforeTest() throws Exception {
     // createJetty(EXAMPLE_HOME, null, null);
-    initCore(EXAMPLE_CONFIG, EXAMPLE_SCHEMA, EXAMPLE_HOME);
+    initCore(ExternalPaths.EXAMPLE_CONFIG, ExternalPaths.EXAMPLE_SCHEMA, ExternalPaths.EXAMPLE_HOME);
     // initCore("solrconfig.xml", "schema.xml", null);
   }
   

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java Mon Apr  4 13:03:42 2011
@@ -60,7 +60,7 @@ public class BasicDistributedZkTest exte
   
   @BeforeClass
   public static void beforeClass() throws Exception {
-    System.setProperty("solr.solr.home", SolrTestCaseJ4.TEST_HOME);
+    System.setProperty("solr.solr.home", SolrTestCaseJ4.TEST_HOME());
   }
   
   @Override

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/common/util/TestSystemIdResolver.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/common/util/TestSystemIdResolver.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/common/util/TestSystemIdResolver.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/common/util/TestSystemIdResolver.java Mon Apr  4 13:03:42 2011
@@ -38,9 +38,9 @@ public class TestSystemIdResolver extend
   }
   
   public void testResolving() throws Exception {
-    final ResourceLoader loader = new SolrResourceLoader(SolrTestCaseJ4.TEST_HOME, this.getClass().getClassLoader());
+    final ResourceLoader loader = new SolrResourceLoader(SolrTestCaseJ4.TEST_HOME(), this.getClass().getClassLoader());
     final SystemIdResolver resolver = new SystemIdResolver(loader);
-    final String fileUri = new File(SolrTestCaseJ4.TEST_HOME+"/crazy-path-to-config.xml").toURI().toASCIIString();
+    final String fileUri = new File(SolrTestCaseJ4.TEST_HOME()+"/crazy-path-to-config.xml").toURI().toASCIIString();
     
     assertEquals("solrres:/test.xml", SystemIdResolver.createSystemIdFromResourceName("test.xml"));
     assertEquals("solrres://@/usr/local/etc/test.xml", SystemIdResolver.createSystemIdFromResourceName("/usr/local/etc/test.xml"));
@@ -60,10 +60,10 @@ public class TestSystemIdResolver extend
     assertEntityResolving(resolver, "solrres:/schema.xml", "solrres:/solrconfig.xml", "schema.xml");
     assertEntityResolving(resolver, "solrres:/org/apache/solr/common/util/TestSystemIdResolver.class",
       "solrres:/org/apache/solr/common/ResourceLoader.class", "util/TestSystemIdResolver.class");
-    assertEntityResolving(resolver, SystemIdResolver.createSystemIdFromResourceName(SolrTestCaseJ4.TEST_HOME+"/conf/schema.xml"),
-      SystemIdResolver.createSystemIdFromResourceName(SolrTestCaseJ4.TEST_HOME+"/conf/solrconfig.xml"), "schema.xml");
-    assertEntityResolving(resolver, SystemIdResolver.createSystemIdFromResourceName(SolrTestCaseJ4.TEST_HOME+"/crazy-path-to-schema.xml"),
-      SystemIdResolver.createSystemIdFromResourceName(SolrTestCaseJ4.TEST_HOME+"/crazy-path-to-config.xml"), "crazy-path-to-schema.xml");
+    assertEntityResolving(resolver, SystemIdResolver.createSystemIdFromResourceName(SolrTestCaseJ4.TEST_HOME()+"/conf/schema.xml"),
+      SystemIdResolver.createSystemIdFromResourceName(SolrTestCaseJ4.TEST_HOME()+"/conf/solrconfig.xml"), "schema.xml");
+    assertEntityResolving(resolver, SystemIdResolver.createSystemIdFromResourceName(SolrTestCaseJ4.TEST_HOME()+"/crazy-path-to-schema.xml"),
+      SystemIdResolver.createSystemIdFromResourceName(SolrTestCaseJ4.TEST_HOME()+"/crazy-path-to-config.xml"), "crazy-path-to-schema.xml");
     
     // test, that resolving works if somebody uses an absolute file:-URI in a href attribute, the resolver should return null (default fallback)
     assertNull(resolver.resolveEntity(null, null, "solrres:/solrconfig.xml", fileUri));

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/request/TestFaceting.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/request/TestFaceting.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/request/TestFaceting.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/request/TestFaceting.java Mon Apr  4 13:03:42 2011
@@ -17,14 +17,17 @@
 
 package org.apache.solr.request;
 
+import java.util.Locale;
+import java.util.Random;
+
+import org.apache.lucene.index.DocTermOrds;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.util.BytesRef;
 import org.apache.solr.SolrTestCaseJ4;
 import org.junit.After;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import java.util.Locale;
-import java.util.Random;
 
 /**
  * @version $Id$
@@ -62,43 +65,47 @@ public class TestFaceting extends SolrTe
   }
 
   void doTermEnum(int size) throws Exception {
+    //System.out.println("doTermEnum size=" + size);
     close();
     createIndex(size);
     req = lrf.makeRequest("q","*:*");
 
-    TermIndex ti = new TermIndex(proto.field());
-    NumberedTermsEnum te = ti.getEnumerator(req.getSearcher().getIndexReader());
+    UnInvertedField uif = new UnInvertedField(proto.field(), req.getSearcher());
 
-    // iterate through first
-    while(te.term() != null) te.next();
-    assertEquals(size, te.getTermNumber());
-    te.close();
+    assertEquals(size, uif.getNumTerms());
 
-    te = ti.getEnumerator(req.getSearcher().getIndexReader());
+    TermsEnum te = uif.getOrdTermsEnum(req.getSearcher().getIndexReader());
+    assertEquals(size == 0, te == null);
 
     Random r = new Random(size);
     // test seeking by term string
     for (int i=0; i<size*2+10; i++) {
       int rnum = r.nextInt(size+2);
       String s = t(rnum);
-      BytesRef br = te.skipTo(new BytesRef(s));
+      //System.out.println("s=" + s);
+      final BytesRef br;
+      if (te == null) {
+        br = null;
+      } else {
+        TermsEnum.SeekStatus status = te.seek(new BytesRef(s));
+        if (status == TermsEnum.SeekStatus.END) {
+          br = null;
+        } else {
+          br = te.term();
+        }
+      }
       assertEquals(br != null, rnum < size);
       if (rnum < size) {
-        assertEquals(rnum, te.pos);
+        assertEquals(rnum, (int) te.ord());
         assertEquals(s, te.term().utf8ToString());
-      } else {
-        assertEquals(null, te.term());
-        assertEquals(size, te.getTermNumber());
       }
     }
 
     // test seeking before term
-    assertEquals(size>0, te.skipTo(new BytesRef("000")) != null);
-    assertEquals(0, te.getTermNumber());
     if (size>0) {
+      assertEquals(size>0, te.seek(new BytesRef("000"), true) != TermsEnum.SeekStatus.END);
+      assertEquals(0, te.ord());
       assertEquals(t(0), te.term().utf8ToString());
-    } else {
-      assertEquals(null, te.term());
     }
 
     if (size>0) {
@@ -106,9 +113,10 @@ public class TestFaceting extends SolrTe
       for (int i=0; i<size*2+10; i++) {
         int rnum = r.nextInt(size);
         String s = t(rnum);
-        BytesRef br = te.skipTo(rnum);
+        assertTrue(te.seek((long) rnum) != TermsEnum.SeekStatus.END);
+        BytesRef br = te.term();
         assertNotNull(br);
-        assertEquals(rnum, te.pos);
+        assertEquals(rnum, (int) te.ord());
         assertEquals(s, te.term().utf8ToString());
       }
     }
@@ -118,11 +126,12 @@ public class TestFaceting extends SolrTe
   public void testTermEnum() throws Exception {
     doTermEnum(0);
     doTermEnum(1);
-    doTermEnum(TermIndex.interval - 1);  // test boundaries around the block size
-    doTermEnum(TermIndex.interval);
-    doTermEnum(TermIndex.interval + 1);
-    doTermEnum(TermIndex.interval * 2 + 2);    
-    // doTermEnum(TermIndex.interval * 3 + 3);    
+    final int DEFAULT_INDEX_INTERVAL = 1 << DocTermOrds.DEFAULT_INDEX_INTERVAL_BITS;
+    doTermEnum(DEFAULT_INDEX_INTERVAL - 1);  // test boundaries around the block size
+    doTermEnum(DEFAULT_INDEX_INTERVAL);
+    doTermEnum(DEFAULT_INDEX_INTERVAL + 1);
+    doTermEnum(DEFAULT_INDEX_INTERVAL * 2 + 2);    
+    // doTermEnum(DEFAULT_INDEX_INTERVAL * 3 + 3);    
   }
 
   @Test

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/CustomSimilarityFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/CustomSimilarityFactory.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/CustomSimilarityFactory.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/CustomSimilarityFactory.java Mon Apr  4 13:03:42 2011
@@ -16,11 +16,11 @@
  */
 package org.apache.solr.schema;
 
-import org.apache.lucene.search.SimilarityProvider;
+import org.apache.lucene.search.Similarity;
 
 public class CustomSimilarityFactory extends SimilarityFactory {
   @Override
-  public SimilarityProvider getSimilarityProvider() {
+  public Similarity getSimilarity() {
     return new MockConfigurableSimilarity(params.get("echo"));
   }
 }

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/DateFieldTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/DateFieldTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/DateFieldTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/DateFieldTest.java Mon Apr  4 13:03:42 2011
@@ -17,6 +17,8 @@
 
 package org.apache.solr.schema;
 
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Fieldable;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.solr.schema.DateField;
 import org.apache.solr.util.DateMathParser;
@@ -114,4 +116,13 @@ public class DateFieldTest extends Lucen
 
   }
 
+  public void testCreateField() {
+    int props = FieldProperties.INDEXED ^ FieldProperties.STORED;
+    SchemaField sf = new SchemaField( "test", f, props, null );
+    Fieldable out = (Field)f.createField(sf, "1995-12-31T23:59:59Z", 1.0f );
+    assertEquals(820454399000l, f.toObject( out ).getTime() );
+    
+    out = (Field)f.createField(sf, new Date(820454399000l), 1.0f );
+    assertEquals(820454399000l, f.toObject( out ).getTime() );
+  }
 }

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/IndexSchemaTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/IndexSchemaTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/IndexSchemaTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/IndexSchemaTest.java Mon Apr  4 13:03:42 2011
@@ -81,11 +81,11 @@ public class IndexSchemaTest extends Sol
   }
 
   @Test
-  public void testSimilarityFactory() {
+  public void testSimilarityProviderFactory() {
     SolrCore core = h.getCore();
-    SimilarityProvider similarity = core.getSchema().getSimilarityProvider();
-    assertTrue("wrong class", similarity instanceof MockConfigurableSimilarity);
-    assertEquals("is there an echo?", ((MockConfigurableSimilarity)similarity).getPassthrough());
+    SimilarityProvider similarityProvider = core.getSchema().getSimilarityProvider();
+    assertTrue("wrong class", similarityProvider instanceof MockConfigurableSimilarityProvider);
+    assertEquals("is there an echo?", ((MockConfigurableSimilarityProvider)similarityProvider).getPassthrough());
   }
   
   @Test

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/MockConfigurableSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/MockConfigurableSimilarity.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/MockConfigurableSimilarity.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/MockConfigurableSimilarity.java Mon Apr  4 13:03:42 2011
@@ -16,9 +16,9 @@
  */
 package org.apache.solr.schema;
 
-import org.apache.lucene.search.DefaultSimilarityProvider;
+import org.apache.lucene.search.DefaultSimilarity;
 
-public class MockConfigurableSimilarity extends DefaultSimilarityProvider {
+public class MockConfigurableSimilarity extends DefaultSimilarity {
   private String passthrough;
 
   public MockConfigurableSimilarity(String passthrough) {

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/servlet/NoCacheHeaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/servlet/NoCacheHeaderTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/servlet/NoCacheHeaderTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/servlet/NoCacheHeaderTest.java Mon Apr  4 13:03:42 2011
@@ -31,7 +31,7 @@ import org.junit.Test;
 public class NoCacheHeaderTest extends CacheHeaderTestBase {
   @BeforeClass
   public static void beforeTest() throws Exception {
-    createJetty(TEST_HOME, "solr/conf/solrconfig-nocache.xml", null);
+    createJetty(TEST_HOME(), "solr/conf/solrconfig-nocache.xml", null);
   }
 
   // The tests

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/spelling/suggest/PersistenceTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/spelling/suggest/PersistenceTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/spelling/suggest/PersistenceTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/spelling/suggest/PersistenceTest.java Mon Apr  4 13:03:42 2011
@@ -49,7 +49,7 @@ public class PersistenceTest extends Sol
     for (String k : keys) {
       lookup.add(k, new Float(k.length()));
     }
-    File storeDir = new File(TEST_HOME);
+    File storeDir = new File(TEST_HOME());
     lookup.store(storeDir);
     lookup = new TSTLookup();
     lookup.load(storeDir);
@@ -66,7 +66,7 @@ public class PersistenceTest extends Sol
     for (String k : keys) {
       lookup.add(k, new Float(k.length()));
     }
-    File storeDir = new File(TEST_HOME);
+    File storeDir = new File(TEST_HOME());
     lookup.store(storeDir);
     lookup = new JaspellLookup();
     lookup.load(storeDir);

Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java Mon Apr  4 13:03:42 2011
@@ -25,11 +25,16 @@ import org.apache.solr.spelling.suggest.
 import org.apache.solr.spelling.suggest.tst.TSTLookup;
 import org.apache.solr.util.TermFreqIterator;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
+import com.google.common.collect.Lists;
+
 import java.io.File;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Random;
 
@@ -130,10 +135,47 @@ public class SuggesterTest extends SolrT
     return tfit;
   }
   
-  private void _benchmark(Lookup lookup, Map<String,Integer> ref, boolean estimate, Bench bench) throws Exception {
+  static class Bench {
+    long buildTime;
+    long lookupTime;
+  }
+
+  @Test @Ignore
+  public void testBenchmark() throws Exception {
+    final List<Class<? extends Lookup>> benchmarkClasses = Lists.newArrayList();  
+    benchmarkClasses.add(JaspellLookup.class);
+    benchmarkClasses.add(TSTLookup.class);
+
+    // Run a single pass just to see if everything works fine and provide size estimates.
+    final RamUsageEstimator rue = new RamUsageEstimator();
+    for (Class<? extends Lookup> cls : benchmarkClasses) {
+      Lookup lookup = singleBenchmark(cls, null);
+      System.err.println(
+          String.format(Locale.ENGLISH,
+              "%20s, size[B]=%,d",
+              lookup.getClass().getSimpleName(), 
+              rue.estimateRamUsage(lookup)));
+    }
+
+    int warmupCount = 10;
+    int measuredCount = 100;
+    for (Class<? extends Lookup> cls : benchmarkClasses) {
+      Bench b = fullBenchmark(cls, warmupCount, measuredCount);
+      System.err.println(String.format(Locale.ENGLISH,
+          "%s: buildTime[ms]=%,d lookupTime[ms]=%,d",
+          cls.getSimpleName(),
+          (b.buildTime / measuredCount),
+          (b.lookupTime / measuredCount / 1000000)));
+    }
+  }
+
+  private Lookup singleBenchmark(Class<? extends Lookup> cls, Bench bench) throws Exception {
+    Lookup lookup = cls.newInstance();
+
     long start = System.currentTimeMillis();
     lookup.build(getTFIT());
     long buildTime = System.currentTimeMillis() - start;
+
     TermFreqIterator tfit = getTFIT();
     long elapsed = 0;
     while (tfit.hasNext()) {
@@ -148,78 +190,37 @@ public class SuggesterTest extends SolrT
       for (LookupResult lr : res) {
         assertTrue(lr.key.startsWith(prefix));
       }
-      if (ref != null) { // verify the counts
-        Integer Cnt = ref.get(key);
-        if (Cnt == null) { // first pass
-          ref.put(key, res.size());
-        } else {
-          assertEquals(key + ", prefix: " + prefix, Cnt.intValue(), res.size());
-        }
-      }
-    }
-    if (estimate) {
-      RamUsageEstimator rue = new RamUsageEstimator();
-      long size = rue.estimateRamUsage(lookup);
-      System.err.println(lookup.getClass().getSimpleName() + " - size=" + size);
     }
+
     if (bench != null) {
       bench.buildTime += buildTime;
       bench.lookupTime +=  elapsed;
     }
-  }
-  
-  class Bench {
-    long buildTime;
-    long lookupTime;
-  }
 
-  @Test
-  public void testBenchmark() throws Exception {
-    // this benchmark is very time consuming
-    boolean doTest = false;
-    if (!doTest) {
-      return;
-    }
-    Map<String,Integer> ref = new HashMap<String,Integer>();
-    JaspellLookup jaspell = new JaspellLookup();
-    TSTLookup tst = new TSTLookup();
-    
-    _benchmark(tst, ref, true, null);
-    _benchmark(jaspell, ref, true, null);
-    jaspell = null;
-    tst = null;
-    int count = 100;
-    Bench b = runBenchmark(JaspellLookup.class, count);
-    System.err.println(JaspellLookup.class.getSimpleName() + ": buildTime[ms]=" + (b.buildTime / count) +
-            " lookupTime[ms]=" + (b.lookupTime / count / 1000000));
-    b = runBenchmark(TSTLookup.class, count);
-    System.err.println(TSTLookup.class.getSimpleName() + ": buildTime[ms]=" + (b.buildTime / count) +
-            " lookupTime[ms]=" + (b.lookupTime / count / 1000000));
+    return lookup;
   }
-  
-  private Bench runBenchmark(Class<? extends Lookup> cls, int count) throws Exception {
-    System.err.println("* Running " + count + " iterations for " + cls.getSimpleName() + " ...");
-    System.err.println("  - warm-up 10 iterations...");
-    for (int i = 0; i < 10; i++) {
+
+  private Bench fullBenchmark(Class<? extends Lookup> cls, int warmupCount, int measuredCount) throws Exception {
+    System.err.println("* Running " + measuredCount + " iterations for " + cls.getSimpleName() + " ...");
+    System.err.println("  - warm-up " + warmupCount + " iterations...");
+    for (int i = 0; i < warmupCount; i++) {
       System.runFinalization();
       System.gc();
-      Lookup lookup = cls.newInstance();
-      _benchmark(lookup, null, false, null);
-      lookup = null;
+      singleBenchmark(cls, null);
     }
+
     Bench b = new Bench();
     System.err.print("  - main iterations:"); System.err.flush();
-    for (int i = 0; i < count; i++) {
+    for (int i = 0; i < measuredCount; i++) {
       System.runFinalization();
       System.gc();
-      Lookup lookup = cls.newInstance();
-      _benchmark(lookup, null, false, b);
-      lookup = null;
+      singleBenchmark(cls, b);
       if (i > 0 && (i % 10 == 0)) {
         System.err.print(" " + i);
         System.err.flush();
       }
     }
+
     System.err.println();
     return b;
   }

Modified: lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/form.jsp
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/form.jsp?rev=1088606&r1=1088605&r2=1088606&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/form.jsp (original)
+++ lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/form.jsp Mon Apr  4 13:03:42 2011
@@ -72,7 +72,7 @@
 	<strong>Query Type</strong>
   </td>
   <td>
-	<input name="qt" type="text" value="standard">
+	<input name="qt" type="text">
   </td>
 </tr>
 <tr>



Mime
View raw message