You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2012/10/25 15:10:51 UTC

svn commit: r1402140 [16/17] - in /lucene/dev/branches/LUCENE-2878: ./ dev-tools/ dev-tools/eclipse/ dev-tools/eclipse/dot.settings/ dev-tools/idea/.idea/libraries/ dev-tools/idea/lucene/classification/ dev-tools/maven/ dev-tools/maven/lucene/classific...

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/update/TransactionLog.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/update/TransactionLog.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/update/TransactionLog.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/update/TransactionLog.java Thu Oct 25 13:10:25 2012
@@ -585,7 +585,7 @@ public class TransactionLog {
     /** Returns the next object from the log, or null if none available.
      *
      * @return The log record, or null if EOF
-     * @throws IOException
+     * @throws IOException If there is a low-level I/O error.
      */
     public Object next() throws IOException, InterruptedException {
       long pos = fis.position();
@@ -674,7 +674,7 @@ public class TransactionLog {
     /** Returns the next object from the log, or null if none available.
      *
      * @return The log record, or null if EOF
-     * @throws IOException
+     * @throws IOException If there is a low-level I/O error.
      */
     public Object next() throws IOException {
       if (prevPos <= 0) return null;

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/update/UpdateHandler.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/update/UpdateHandler.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/update/UpdateHandler.java Thu Oct 25 13:10:25 2012
@@ -19,7 +19,6 @@ package org.apache.solr.update;
 
 
 import java.io.IOException;
-import java.util.List;
 import java.util.Vector;
 
 import org.apache.solr.core.PluginInfo;
@@ -29,7 +28,6 @@ import org.apache.solr.core.SolrInfoMBea
 import org.apache.solr.schema.FieldType;
 import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.SchemaField;
-import org.apache.solr.search.SolrIndexSearcher;
 import org.apache.solr.util.plugin.SolrCoreAware;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -57,16 +55,6 @@ public abstract class UpdateHandler impl
 
   protected UpdateLog ulog;
 
-  /**
-   * Called when a SolrCore using this UpdateHandler is closed.
-   */
-  public abstract void decref();
-  
-  /**
-   * Called when this UpdateHandler is shared with another SolrCore.
-   */
-  public abstract void incref();
-
   private void parseEventListeners() {
     final Class<SolrEventListener> clazz = SolrEventListener.class;
     final String label = "Event Listener";
@@ -129,7 +117,7 @@ public abstract class UpdateHandler impl
    * 
    * @param rollback IndexWriter if true else close
    * 
-   * @throws IOException
+   * @throws IOException If there is a low-level I/O error.
    */
   public abstract void newIndexWriter(boolean rollback) throws IOException;
 

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java Thu Oct 25 13:10:25 2012
@@ -45,6 +45,7 @@ import org.apache.solr.common.cloud.ZkSt
 import org.apache.solr.common.cloud.ZooKeeperException;
 import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction;
 import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.params.UpdateParams;
 import org.apache.solr.common.util.Hash;
 import org.apache.solr.common.util.NamedList;
@@ -332,7 +333,7 @@ public class DistributedUpdateProcessor 
     ModifiableSolrParams params = null;
     if (nodes != null) {
       
-      params = new ModifiableSolrParams(req.getParams());
+      params = new ModifiableSolrParams(filterParams(req.getParams()));
       params.set(DISTRIB_UPDATE_PARAM, 
                  (isLeader ? 
                   DistribPhase.FROMLEADER.toString() : 
@@ -341,7 +342,7 @@ public class DistributedUpdateProcessor 
         params.set("distrib.from", ZkCoreNodeProps.getCoreUrl(
             zkController.getBaseUrl(), req.getCore().getName()));
       }
-      params.remove("commit"); // this will be distributed from the local commit
+
       params.set("distrib.from", ZkCoreNodeProps.getCoreUrl(
           zkController.getBaseUrl(), req.getCore().getName()));
       cmdDistrib.distribAdd(cmd, nodes, params);
@@ -437,9 +438,8 @@ public class DistributedUpdateProcessor 
   }
 
   /**
-   * @param cmd
    * @return whether or not to drop this cmd
-   * @throws IOException
+   * @throws IOException If there is a low-level I/O error.
    */
   private boolean versionAdd(AddUpdateCommand cmd) throws IOException {
     BytesRef idBytes = cmd.getIndexedId();
@@ -680,7 +680,7 @@ public class DistributedUpdateProcessor 
     ModifiableSolrParams params = null;
     if (nodes != null) {
       
-      params = new ModifiableSolrParams(req.getParams());
+      params = new ModifiableSolrParams(filterParams(req.getParams()));
       params.set(DISTRIB_UPDATE_PARAM, 
                  (isLeader ? 
                   DistribPhase.FROMLEADER.toString() : 
@@ -689,7 +689,6 @@ public class DistributedUpdateProcessor 
         params.set("distrib.from", ZkCoreNodeProps.getCoreUrl(
             zkController.getBaseUrl(), req.getCore().getName()));
       }
-      params.remove("commit"); // we already will have forwarded this from our local commit
       cmdDistrib.distribDelete(cmd, nodes, params);
     }
 
@@ -706,6 +705,19 @@ public class DistributedUpdateProcessor 
     }
   }
 
+  private ModifiableSolrParams filterParams(SolrParams params) {
+    ModifiableSolrParams fparams = new ModifiableSolrParams();
+    passParam(params, fparams, UpdateParams.UPDATE_CHAIN);
+    return fparams;
+  }
+
+  private void passParam(SolrParams params, ModifiableSolrParams fparams, String param) {
+    String value = params.get(param);
+    if (value != null) {
+      fparams.add(param, value);
+    }
+  }
+
   public void doDeleteByQuery(DeleteUpdateCommand cmd) throws IOException {
     // even in non zk mode, tests simulate updates from a leader
     if(!zkEnabled) {
@@ -736,7 +748,7 @@ public class DistributedUpdateProcessor 
                 + zkController.getClusterState().getCollections());
       }
 
-      ModifiableSolrParams params = new ModifiableSolrParams(req.getParams());
+      ModifiableSolrParams params = new ModifiableSolrParams(filterParams(req.getParams()));
       params.set(DISTRIB_UPDATE_PARAM, DistribPhase.TOLEADER.toString());
 
       List<Node> leaders =  new ArrayList<Node>(slices.size());
@@ -847,7 +859,7 @@ public class DistributedUpdateProcessor 
 
     // forward to all replicas
     if (leaderLogic && replicas != null) {
-      ModifiableSolrParams params = new ModifiableSolrParams(req.getParams());
+      ModifiableSolrParams params = new ModifiableSolrParams(filterParams(req.getParams()));
       params.set(VERSION_FIELD, Long.toString(cmd.getVersion()));
       params.set(DISTRIB_UPDATE_PARAM, DistribPhase.FROMLEADER.toString());
       params.set("update.from", ZkCoreNodeProps.getCoreUrl(
@@ -1005,8 +1017,8 @@ public class DistributedUpdateProcessor 
     // TODO: we should consider this? commit everyone in the current collection
 
     if (zkEnabled) {
-      ModifiableSolrParams params = new ModifiableSolrParams(req.getParams());
-      if (!params.getBool(COMMIT_END_POINT, false)) {
+      ModifiableSolrParams params = new ModifiableSolrParams(filterParams(req.getParams()));
+      if (!req.getParams().getBool(COMMIT_END_POINT, false)) {
         params.set(COMMIT_END_POINT, true);
 
         String nodeName = req.getCore().getCoreDescriptor().getCoreContainer()

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/util/SimplePostTool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/util/SimplePostTool.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/util/SimplePostTool.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/util/SimplePostTool.java Thu Oct 25 13:10:25 2012
@@ -585,7 +585,7 @@ public class SimplePostTool {
    * Reads an input stream into a byte array
    * @param is the input stream
    * @return the byte array
-   * @throws IOException
+   * @throws IOException If there is a low-level I/O error.
    */
   protected byte[] inputStreamToByteArray(InputStream is) throws IOException {
     ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -761,7 +761,6 @@ public class SimplePostTool {
    * @param url the URL
    * @param append the path to append
    * @return the final URL version 
-   * @throws MalformedURLException
    */
   protected static URL appendUrlPath(URL url, String append) throws MalformedURLException {
     return new URL(url.getProtocol() + "://" + url.getAuthority() + url.getPath() + append + (url.getQuery() != null ? "?"+url.getQuery() : ""));

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/util/xslt/TransformerProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/util/xslt/TransformerProvider.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/util/xslt/TransformerProvider.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/java/org/apache/solr/util/xslt/TransformerProvider.java Thu Oct 25 13:10:25 2012
@@ -64,7 +64,7 @@ public class TransformerProvider {
   }
   
   /** Return a new Transformer, possibly created from our cached Templates object  
-   * @throws IOException 
+   * @throws IOException If there is a low-level I/O error.
    */ 
   public synchronized Transformer getTransformer(SolrConfig solrConfig, String filename,int cacheLifetimeSeconds) throws IOException {
     // For now, the Templates are blindly reloaded once cacheExpires is over.

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema-phrasesuggest.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema-phrasesuggest.xml?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema-phrasesuggest.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema-phrasesuggest.xml Thu Oct 25 13:10:25 2012
@@ -40,6 +40,14 @@
 	    <filter class="solr.TrimFilterFactory"/>
 	  </analyzer>
 	</fieldtype>
+	
+	<fieldtype name="ja_suggest" class="solr.TextField">
+	  <analyzer>
+	    <tokenizer class="solr.JapaneseTokenizerFactory" mode="normal"/>
+	    <filter class="solr.CJKWidthFilterFactory"/>
+	    <filter class="solr.JapaneseReadingFormFilterFactory" useRomaji="true"/>
+	  </analyzer>
+	</fieldtype>
   </types>
 
   <fields>

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml Thu Oct 25 13:10:25 2012
@@ -27,22 +27,22 @@
     <fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
 
     <fieldType name="srpt_geohash"   class="solr.SpatialRecursivePrefixTreeFieldType"
-               prefixTree="geohash"
+               prefixTree="geohash" units="degrees"
         />
     <fieldType name="srpt_quad"   class="solr.SpatialRecursivePrefixTreeFieldType"
-              prefixTree="quad"
+              prefixTree="quad" units="degrees"
         />
     <fieldType name="srpt_100km"   class="solr.SpatialRecursivePrefixTreeFieldType"
-              maxDetailDist="0.9"
+              maxDistErr="0.9" units="degrees"
         />
     <fieldType name="stqpt_geohash"   class="solr.SpatialTermQueryPrefixTreeFieldType"
-              prefixTree="geohash" />
+              prefixTree="geohash" units="degrees" />
 
     <fieldType name="stqpt_u"  class="solr.SpatialTermQueryPrefixTreeFieldType"
-        geo="false" distCalculator="cartesian^2" worldBounds="0 0 1000 1000"/>
+        geo="false" distCalculator="cartesian^2" worldBounds="0 0 1000 1000" units="degrees"/>
 
-    <fieldType name="twodoubles" class="solr.SpatialTwoDoublesFieldType"
-               numberType="tdouble"/>
+    <fieldType name="pointvector" class="solr.SpatialPointVectorFieldType"
+               numberType="tdouble" units="degrees"/>
 
   </types>
 
@@ -54,7 +54,7 @@
     <field name="srpt_geohash" type="srpt_geohash" multiValued="true" />
     <field name="srpt_quad" type="srpt_quad" multiValued="true" />
     <field name="stqpt_geohash" type="stqpt_geohash" multiValued="true" />
-    <field name="twodoubles" type="twodoubles" />
+    <field name="pointvector" type="pointvector" />
 
   </fields>
 

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema.xml?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema.xml Thu Oct 25 13:10:25 2012
@@ -649,6 +649,8 @@
       termVectors="true" termPositions="true" termOffsets="true"/>
    <dynamicField name="tv_mv_*"  type="text" indexed="true"  stored="true" multiValued="true"
       termVectors="true" termPositions="true" termOffsets="true"/>
+   <dynamicField name="tv_no_off_*" type="text" indexed="true" stored="true"
+      termVectors="true" termPositions="true"/>
 
    <dynamicField name="*_p"  type="xyd" indexed="true"  stored="true" multiValued="false"/>
 

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema15.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema15.xml?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema15.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema15.xml Thu Oct 25 13:10:25 2012
@@ -269,6 +269,12 @@
         <filter class="solr.LengthFilterFactory" min="2" max="5"/>
       </analyzer>
     </fieldtype>
+    <fieldtype name="limitfilt" class="solr.TextField">
+      <analyzer>
+        <tokenizer class="solr.MockTokenizerFactory"/>
+        <filter class="solr.LimitTokenCountFilterFactory" maxTokenCount="100" />
+      </analyzer>
+    </fieldtype>
 
     <fieldtype name="subword" class="solr.TextField" multiValued="true" positionIncrementGap="100">
       <analyzer type="index">

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema_codec.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema_codec.xml?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema_codec.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/schema_codec.xml Thu Oct 25 13:10:25 2012
@@ -17,9 +17,9 @@
 -->
 <schema name="codec" version="1.2">
  <types>
-  <fieldType name="string_pulsing" class="solr.StrField" postingsFormat="Pulsing40"/>
+  <fieldType name="string_pulsing" class="solr.StrField" postingsFormat="Pulsing41"/>
   <fieldType name="string_simpletext" class="solr.StrField" postingsFormat="SimpleText"/>
-  <fieldType name="string_standard" class="solr.StrField" postingsFormat="Lucene40"/>
+  <fieldType name="string_standard" class="solr.StrField" postingsFormat="Lucene41"/>
     <fieldType name="string" class="solr.StrField" />
   
  </types>

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/solrconfig-phrasesuggest.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/solrconfig-phrasesuggest.xml?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/solrconfig-phrasesuggest.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/collection1/conf/solrconfig-phrasesuggest.xml Thu Oct 25 13:10:25 2012
@@ -43,6 +43,27 @@
     <str name="queryAnalyzerFieldType">phrase_suggest</str>
   </searchComponent>
   
+  <!-- AnalyzingLookup suggest component -->
+  <searchComponent class="solr.SpellCheckComponent" name="suggest_analyzing">
+    <lst name="spellchecker">
+      <str name="name">suggest_analyzing</str>
+      <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
+      <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.AnalyzingLookupFactory</str>
+      <str name="storeDir">suggest_analyzing</str>
+      <str name="buildOnCommit">false</str>
+
+      <!-- Suggester properties -->
+      <bool name="exactMatchFirst">true</bool>
+      <str name="suggestAnalyzerFieldType">ja_suggest</str>
+      <bool name="preserveSep">false</bool>
+      
+      <str name="sourceLocation">jasuggest.txt</str>
+    </lst>
+    
+    <!-- specify a fieldtype using keywordtokenizer + lowercase + cleanup -->
+    <str name="queryAnalyzerFieldType">phrase_suggest</str>
+  </searchComponent>
+  
   <!-- is this thing just configured globally or wtf is going on here?! -->
   <queryConverter name="queryConverter" class="org.apache.solr.spelling.SuggestQueryConverter"/>
   
@@ -60,4 +81,18 @@
     </arr>
   </requestHandler>
   
+  <!--  analyzing (finite state automaton based) -->
+  <requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest_analyzing">
+    <lst name="defaults">
+      <str name="spellcheck">true</str>
+      <str name="spellcheck.dictionary">suggest_analyzing</str>
+      <str name="spellcheck.collate">false</str>
+      <!-- NOTE: if this is false, results are alpha-ordered, not by weight! -->
+      <str name="spellcheck.onlyMorePopular">true</str>
+    </lst>
+    <arr name="components">
+      <str>suggest_analyzing</str>
+    </arr>
+  </requestHandler>
+  
 </config>

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java Thu Oct 25 13:10:25 2012
@@ -59,11 +59,11 @@ public class BasicDistributedZk2Test ext
           "now is the time for all good men", "foo_f", 1.414f, "foo_b", "true",
           "foo_d", 1.414d);
       
-      // make sure we are in a steady state...
-      waitForRecoveriesToFinish(false);
-      
       commit();
       
+      // make sure we are in a steady state...
+      waitForRecoveriesToFinish(false);
+
       assertDocCounts(false);
       
       indexAbunchOfDocs();
@@ -203,6 +203,9 @@ public class BasicDistributedZk2Test ext
     }
     
     commit();
+    
+    printLayout();
+    
     query("q", "*:*", "sort", "n_tl1 desc");
     
     // long cloudClientDocs = cloudClient.query(new

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java Thu Oct 25 13:10:25 2012
@@ -27,6 +27,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Random;
 import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CompletionService;
@@ -49,6 +50,7 @@ import org.apache.solr.client.solrj.requ
 import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;
 import org.apache.solr.client.solrj.request.CoreAdminRequest;
 import org.apache.solr.client.solrj.request.CoreAdminRequest.Create;
+import org.apache.solr.client.solrj.request.CoreAdminRequest.Unload;
 import org.apache.solr.client.solrj.request.QueryRequest;
 import org.apache.solr.client.solrj.response.CoreAdminResponse;
 import org.apache.solr.client.solrj.response.QueryResponse;
@@ -65,9 +67,11 @@ import org.apache.solr.common.cloud.ZkNo
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.params.CollectionParams.CollectionAction;
 import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.CoreAdminParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.params.UpdateParams;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.update.DirectUpdateHandler2;
 import org.apache.solr.update.SolrCmdDistributor.Request;
 import org.apache.solr.util.DefaultSolrThreadFactory;
 import org.junit.Before;
@@ -123,7 +127,7 @@ public class BasicDistributedZkTest exte
     fixShardCount = true;
     
     sliceCount = 2;
-    shardCount = 3;
+    shardCount = 4;
     completionService = new ExecutorCompletionService<Request>(executor);
     pending = new HashSet<Future<Request>>();
     
@@ -318,17 +322,18 @@ public class BasicDistributedZkTest exte
 
     // would be better if these where all separate tests - but much, much
     // slower
-    doOptimisticLockingAndUpdating();
-    testMultipleCollections();
-    testANewCollectionInOneInstance();
-    testSearchByCollectionName();
-    testANewCollectionInOneInstanceWithManualShardAssignement();
-    testNumberOfCommitsWithCommitAfterAdd();
-
-    testUpdateProcessorsRunOnlyOnce("distrib-dup-test-chain-explicit");
-    testUpdateProcessorsRunOnlyOnce("distrib-dup-test-chain-implicit");
-
-    testCollectionsAPI();
+//    doOptimisticLockingAndUpdating();
+//    testMultipleCollections();
+//    testANewCollectionInOneInstance();
+//    testSearchByCollectionName();
+//    testANewCollectionInOneInstanceWithManualShardAssignement();
+//    testNumberOfCommitsWithCommitAfterAdd();
+//
+//    testUpdateProcessorsRunOnlyOnce("distrib-dup-test-chain-explicit");
+//    testUpdateProcessorsRunOnlyOnce("distrib-dup-test-chain-implicit");
+//
+//    testCollectionsAPI();
+    testCoreUnloadAndLeaders();
     
     // Thread.sleep(10000000000L);
     if (DEBUG) {
@@ -336,6 +341,215 @@ public class BasicDistributedZkTest exte
     }
   }
 
+  /**
+   * @throws Exception on any problem
+   */
+  private void testCoreUnloadAndLeaders() throws Exception {
+    // create a new collection collection
+    SolrServer client = clients.get(0);
+    String url1 = getBaseUrl(client);
+    HttpSolrServer server = new HttpSolrServer(url1);
+    
+    Create createCmd = new Create();
+    createCmd.setCoreName("unloadcollection1");
+    createCmd.setCollection("unloadcollection");
+    createCmd.setNumShards(1);
+    String core1DataDir = dataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection1" + "_1n";
+    createCmd.setDataDir(core1DataDir);
+    server.request(createCmd);
+    
+    zkStateReader.updateClusterState(true);
+
+    int slices = zkStateReader.getClusterState().getCollectionStates().get("unloadcollection").size();
+    assertEquals(1, slices);
+    
+    client = clients.get(1);
+    String url2 = getBaseUrl(client);
+    server = new HttpSolrServer(url2);
+    
+    createCmd = new Create();
+    createCmd.setCoreName("unloadcollection2");
+    createCmd.setCollection("unloadcollection");
+    String core2dataDir = dataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection1" + "_2n";
+    createCmd.setDataDir(core2dataDir);
+    server.request(createCmd);
+    
+    zkStateReader.updateClusterState(true);
+    slices = zkStateReader.getClusterState().getCollectionStates().get("unloadcollection").size();
+    assertEquals(1, slices);
+    
+    waitForRecoveriesToFinish("unloadcollection", zkStateReader, false);
+    
+    ZkCoreNodeProps leaderProps = getLeaderUrlFromZk("unloadcollection", "shard1");
+    
+    Random random = random();
+    HttpSolrServer collectionClient;
+    if (random.nextBoolean()) {
+      collectionClient = new HttpSolrServer(leaderProps.getCoreUrl());
+      // lets try and use the solrj client to index and retrieve a couple
+      // documents
+      SolrInputDocument doc1 = getDoc(id, 6, i1, -600, tlong, 600, t1,
+          "humpty dumpy sat on a wall");
+      SolrInputDocument doc2 = getDoc(id, 7, i1, -600, tlong, 600, t1,
+          "humpty dumpy3 sat on a walls");
+      SolrInputDocument doc3 = getDoc(id, 8, i1, -600, tlong, 600, t1,
+          "humpty dumpy2 sat on a walled");
+      collectionClient.add(doc1);
+      collectionClient.add(doc2);
+      collectionClient.add(doc3);
+      collectionClient.commit();
+    }
+
+    // create another replica for our collection
+    client = clients.get(2);
+    String url3 = getBaseUrl(client);
+    server = new HttpSolrServer(url3);
+    
+    createCmd = new Create();
+    createCmd.setCoreName("unloadcollection3");
+    createCmd.setCollection("unloadcollection");
+    String core3dataDir = dataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection" + "_3n";
+    createCmd.setDataDir(core3dataDir);
+    server.request(createCmd);
+    
+    Thread.sleep(1000);
+    
+    waitForRecoveriesToFinish("unloadcollection", zkStateReader, false);
+    
+    // so that we start with some versions when we reload...
+    DirectUpdateHandler2.commitOnClose = false;
+    
+    HttpSolrServer addClient = new HttpSolrServer(url3 + "/unloadcollection3");
+    // add a few docs
+    for (int x = 20; x < 100; x++) {
+      SolrInputDocument doc1 = getDoc(id, x, i1, -600, tlong, 600, t1,
+          "humpty dumpy sat on a wall");
+      addClient.add(doc1);
+    }
+
+    // don't commit so they remain in the tran log
+    //collectionClient.commit();
+    
+    // unload the leader
+    collectionClient = new HttpSolrServer(leaderProps.getBaseUrl());
+    
+    Unload unloadCmd = new Unload(false);
+    unloadCmd.setCoreName(leaderProps.getCoreName());
+    ModifiableSolrParams p = (ModifiableSolrParams) unloadCmd.getParams();
+
+    collectionClient.request(unloadCmd);
+
+//    Thread.currentThread().sleep(500);
+//    printLayout();
+    
+    int tries = 20;
+    while (leaderProps.getCoreUrl().equals(zkStateReader.getLeaderUrl("unloadcollection", "shard1", 15000))) {
+      Thread.sleep(100);
+      if (tries-- == 0) {
+        fail("Leader never changed");
+      }
+    }
+    
+    // ensure there is a leader
+    zkStateReader.getLeaderProps("unloadcollection", "shard1", 15000);
+    
+    addClient = new HttpSolrServer(url2 + "/unloadcollection2");
+    // add a few docs while the leader is down
+    for (int x = 101; x < 200; x++) {
+      SolrInputDocument doc1 = getDoc(id, x, i1, -600, tlong, 600, t1,
+          "humpty dumpy sat on a wall");
+      addClient.add(doc1);
+    }
+    
+    
+    // create another replica for our collection
+    client = clients.get(3);
+    String url4 = getBaseUrl(client);
+    server = new HttpSolrServer(url4);
+    
+    createCmd = new Create();
+    createCmd.setCoreName("unloadcollection4");
+    createCmd.setCollection("unloadcollection");
+    String core4dataDir = dataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "unloadcollection" + "_4n";
+    createCmd.setDataDir(core4dataDir);
+    server.request(createCmd);
+    
+    Thread.sleep(1000);
+    
+    waitForRecoveriesToFinish("unloadcollection", zkStateReader, false);
+    
+    // unload the leader again
+    leaderProps = getLeaderUrlFromZk("unloadcollection", "shard1");
+    collectionClient = new HttpSolrServer(leaderProps.getBaseUrl());
+    
+    unloadCmd = new Unload(false);
+    unloadCmd.setCoreName(leaderProps.getCoreName());
+    p = (ModifiableSolrParams) unloadCmd.getParams();
+    collectionClient.request(unloadCmd);
+    
+    tries = 20;
+    while (leaderProps.getCoreUrl().equals(zkStateReader.getLeaderUrl("unloadcollection", "shard1", 15000))) {
+      Thread.sleep(100);
+      if (tries-- == 0) {
+        fail("Leader never changed");
+      }
+    }
+    
+    zkStateReader.getLeaderProps("unloadcollection", "shard1", 15000);
+    
+    
+    // set this back
+    DirectUpdateHandler2.commitOnClose = true;
+    
+    // bring the downed leader back as replica
+    server = new HttpSolrServer(leaderProps.getBaseUrl());
+    
+    createCmd = new Create();
+    createCmd.setCoreName(leaderProps.getCoreName());
+    createCmd.setCollection("unloadcollection");
+    createCmd.setDataDir(core1DataDir);
+    server.request(createCmd);
+    
+    Thread.sleep(1000);
+    
+    waitForRecoveriesToFinish("unloadcollection", zkStateReader, false);
+    
+    
+    server = new HttpSolrServer(url1 + "/unloadcollection");
+   // System.out.println(server.query(new SolrQuery("*:*")).getResults().getNumFound());
+    server = new HttpSolrServer(url2 + "/unloadcollection");
+    server.commit();
+    SolrQuery q = new SolrQuery("*:*");
+    q.set("distrib", false);
+    long found1 = server.query(q).getResults().getNumFound();
+    server = new HttpSolrServer(url3 + "/unloadcollection");
+    server.commit();
+    q = new SolrQuery("*:*");
+    q.set("distrib", false);
+    long found3 = server.query(q).getResults().getNumFound();
+    server = new HttpSolrServer(url4 + "/unloadcollection");
+    server.commit();
+    q = new SolrQuery("*:*");
+    q.set("distrib", false);
+    long found4 = server.query(q).getResults().getNumFound();
+    
+    // all 3 shards should now have the same number of docs
+    assertEquals(found1, found3);
+    assertEquals(found3, found4);
+    
+  }
+
+
+  private String getBaseUrl(SolrServer client) {
+    String url2 = ((HttpSolrServer) client).getBaseURL()
+        .substring(
+            0,
+            ((HttpSolrServer) client).getBaseURL().length()
+                - DEFAULT_COLLECTION.length() -1);
+    return url2;
+  }
+
+
   private void testCollectionsAPI() throws Exception {
  
     // TODO: fragile - because we dont pass collection.confName, it will only
@@ -346,32 +560,13 @@ public class BasicDistributedZkTest exte
     // create new collections rapid fire
     Map<String,List<Integer>> collectionInfos = new HashMap<String,List<Integer>>();
     int cnt = atLeast(3);
+    
     for (int i = 0; i < cnt; i++) {
-      ModifiableSolrParams params = new ModifiableSolrParams();
-      params.set("action", CollectionAction.CREATE.toString());
-      int numShards = _TestUtil.nextInt(random(), 0, shardCount) + 1;
-      int numReplicas = _TestUtil.nextInt(random(), 0, 5) + 1;
-      params.set("numShards", numShards);
-      params.set(OverseerCollectionProcessor.REPLICATION_FACTOR, numReplicas);
-      String collectionName = "awholynewcollection_" + i;
-      int clientIndex = random().nextInt(2);
-      List<Integer> list = new ArrayList<Integer>();
-      list.add(numShards);
-      list.add(numReplicas);
-      collectionInfos.put(collectionName, list);
-      params.set("name", collectionName);
-      SolrRequest request = new QueryRequest(params);
-      request.setPath("/admin/collections");
-   
-      final String baseUrl = ((HttpSolrServer) clients.get(clientIndex)).getBaseURL().substring(
-          0,
-          ((HttpSolrServer) clients.get(clientIndex)).getBaseURL().length()
-              - DEFAULT_COLLECTION.length() - 1);
-      
-      createNewSolrServer("", baseUrl).request(request);
+      createCollection(collectionInfos, i,
+          _TestUtil.nextInt(random(), 0, shardCount) + 1,
+          _TestUtil.nextInt(random(), 0, 5) + 1);
     }
     
-    
     Set<Entry<String,List<Integer>>> collectionInfosEntrySet = collectionInfos.entrySet();
     for (Entry<String,List<Integer>> entry : collectionInfosEntrySet) {
       String collection = entry.getKey();
@@ -386,8 +581,8 @@ public class BasicDistributedZkTest exte
       waitForNon403or404or503(collectionClient);
     }
     
-    for (int i = 0; i < cnt; i++) {
-      waitForRecoveriesToFinish("awholynewcollection_" + i, zkStateReader, false);
+    for (int j = 0; j < cnt; j++) {
+      waitForRecoveriesToFinish("awholynewcollection_" + j, zkStateReader, false);
     }
     
     List<String> collectionNameList = new ArrayList<String>();
@@ -399,7 +594,7 @@ public class BasicDistributedZkTest exte
     HttpSolrServer collectionClient = new HttpSolrServer(url);
     
     
-    // lets try and use the solrj client to index and retrieve a couple documents
+    // lets try and use the solrj client to index a couple documents
     SolrInputDocument doc1 = getDoc(id, 6, i1, -600, tlong, 600, t1,
         "humpty dumpy sat on a wall");
     SolrInputDocument doc2 = getDoc(id, 7, i1, -600, tlong, 600, t1,
@@ -441,6 +636,9 @@ public class BasicDistributedZkTest exte
     boolean allTimesAreCorrect = waitForReloads(collectionName, urlToTimeBefore);
     assertTrue("some core start times did not change on reload", allTimesAreCorrect);
     
+    
+    waitForRecoveriesToFinish("awholynewcollection_" + (cnt - 1), zkStateReader, false);
+    
     // remove a collection
     params = new ModifiableSolrParams();
     params.set("action", CollectionAction.DELETE.toString());
@@ -452,9 +650,37 @@ public class BasicDistributedZkTest exte
     
     // ensure its out of the state
     checkForMissingCollection(collectionName);
+    
+    //collectionNameList.remove(collectionName);
 
   }
 
+
+  protected void createCollection(Map<String,List<Integer>> collectionInfos,
+      int i, int numShards, int numReplicas) throws SolrServerException, IOException {
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    params.set("action", CollectionAction.CREATE.toString());
+
+    params.set("numShards", numShards);
+    params.set(OverseerCollectionProcessor.REPLICATION_FACTOR, numReplicas);
+    String collectionName = "awholynewcollection_" + i;
+    int clientIndex = random().nextInt(2);
+    List<Integer> list = new ArrayList<Integer>();
+    list.add(numShards);
+    list.add(numReplicas);
+    collectionInfos.put(collectionName, list);
+    params.set("name", collectionName);
+    SolrRequest request = new QueryRequest(params);
+    request.setPath("/admin/collections");
+  
+    final String baseUrl = ((HttpSolrServer) clients.get(clientIndex)).getBaseURL().substring(
+        0,
+        ((HttpSolrServer) clients.get(clientIndex)).getBaseURL().length()
+            - DEFAULT_COLLECTION.length() - 1);
+    
+    createNewSolrServer("", baseUrl).request(request);
+  }
+
   private boolean waitForReloads(String collectionName, Map<String,Long> urlToTimeBefore) throws SolrServerException, IOException {
     
     
@@ -536,6 +762,15 @@ public class BasicDistributedZkTest exte
     
     throw new RuntimeException("Could not find a live node for collection:" + collection);
   }
+  
+  private ZkCoreNodeProps getLeaderUrlFromZk(String collection, String slice) {
+    ClusterState clusterState = solrj.getZkStateReader().getClusterState();
+    ZkNodeProps leader = clusterState.getLeader(collection, slice);
+    if (leader == null) {
+      throw new RuntimeException("Could not find leader:" + collection + " " + slice);
+    }
+    return new ZkCoreNodeProps(leader);
+  }
 
   private void waitForNon403or404or503(HttpSolrServer collectionClient)
       throws Exception {
@@ -742,10 +977,10 @@ public class BasicDistributedZkTest exte
         0,
         ((HttpSolrServer) client).getBaseURL().length()
             - DEFAULT_COLLECTION.length() - 1);
-    createCollection(oneInstanceCollection2, collectionClients, baseUrl, 1, "slice1");
-    createCollection(oneInstanceCollection2, collectionClients, baseUrl, 2, "slice2");
-    createCollection(oneInstanceCollection2, collectionClients, baseUrl, 3, "slice2");
-    createCollection(oneInstanceCollection2, collectionClients, baseUrl, 4, "slice1");
+    createSolrCore(oneInstanceCollection2, collectionClients, baseUrl, 1, "slice1");
+    createSolrCore(oneInstanceCollection2, collectionClients, baseUrl, 2, "slice2");
+    createSolrCore(oneInstanceCollection2, collectionClients, baseUrl, 3, "slice2");
+    createSolrCore(oneInstanceCollection2, collectionClients, baseUrl, 4, "slice1");
     
    while (pending != null && pending.size() > 0) {
       
@@ -764,7 +999,7 @@ public class BasicDistributedZkTest exte
     
     assertAllActive(oneInstanceCollection2, solrj.getZkStateReader());
     
-    printLayout();
+    //printLayout();
     
    // TODO: enable when we don't falsely get slice1...
    // solrj.getZkStateReader().getLeaderUrl(oneInstanceCollection2, "slice1", 30000);
@@ -803,6 +1038,27 @@ public class BasicDistributedZkTest exte
     assertNotNull(slices);
     String roles = slices.get("slice1").getReplicasMap().values().iterator().next().getStr(ZkStateReader.ROLES_PROP);
     assertEquals("none", roles);
+    
+    
+    ZkCoreNodeProps props = new ZkCoreNodeProps(solrj.getZkStateReader().getClusterState().getLeader(oneInstanceCollection2, "slice1"));
+    
+    // now test that unloading a core gets us a new leader
+    HttpSolrServer server = new HttpSolrServer(baseUrl);
+    Unload unloadCmd = new Unload(true);
+    unloadCmd.setCoreName(props.getCoreName());
+    
+    String leader = props.getCoreUrl();
+    
+    server.request(unloadCmd);
+    
+    int tries = 50;
+    while (leader.equals(zkStateReader.getLeaderUrl(oneInstanceCollection2, "slice1", 10000))) {
+      Thread.sleep(100);
+      if (tries-- == 0) {
+        fail("Leader never changed");
+      }
+    }
+
   }
 
   private void testSearchByCollectionName() throws SolrServerException {
@@ -875,10 +1131,10 @@ public class BasicDistributedZkTest exte
 
   private void createCollection(String collection,
       List<SolrServer> collectionClients, String baseUrl, int num) {
-    createCollection(collection, collectionClients, baseUrl, num, null);
+    createSolrCore(collection, collectionClients, baseUrl, num, null);
   }
   
-  private void createCollection(final String collection,
+  private void createSolrCore(final String collection,
       List<SolrServer> collectionClients, final String baseUrl, final int num,
       final String shardId) {
     Callable call = new Callable() {
@@ -1077,5 +1333,8 @@ public class BasicDistributedZkTest exte
     }
     System.clearProperty("numShards");
     System.clearProperty("zkHost");
+    
+    // insurance
+    DirectUpdateHandler2.commitOnClose = true;
   }
 }

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java Thu Oct 25 13:10:25 2012
@@ -40,7 +40,6 @@ import org.apache.zookeeper.KeeperExcept
 import org.apache.zookeeper.KeeperException.NoNodeException;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 
 @Slow
@@ -114,7 +113,7 @@ public class LeaderElectionTest extends 
           elector, "shard1", "collection1", Integer.toString(nodeNumber),
           props, zkStateReader);
       elector.setup(context);
-      seq = elector.joinElection(context);
+      seq = elector.joinElection(context, false);
       electionDone = true;
       seqToThread.put(seq, this);
     }
@@ -175,7 +174,7 @@ public class LeaderElectionTest extends 
     ElectionContext context = new ShardLeaderElectionContextBase(elector,
         "shard2", "collection1", "dummynode1", props, zkStateReader);
     elector.setup(context);
-    elector.joinElection(context);
+    elector.joinElection(context, false);
     assertEquals("http://127.0.0.1/solr/",
         getLeaderUrl("collection1", "shard2"));
   }
@@ -188,7 +187,7 @@ public class LeaderElectionTest extends 
     ElectionContext firstContext = new ShardLeaderElectionContextBase(first,
         "slice1", "collection2", "dummynode1", props, zkStateReader);
     first.setup(firstContext);
-    first.joinElection(firstContext);
+    first.joinElection(firstContext, false);
 
     Thread.sleep(1000);
     assertEquals("original leader was not registered", "http://127.0.0.1/solr/1/", getLeaderUrl("collection2", "slice1"));
@@ -199,7 +198,7 @@ public class LeaderElectionTest extends 
     ElectionContext context = new ShardLeaderElectionContextBase(second,
         "slice1", "collection2", "dummynode1", props, zkStateReader);
     second.setup(context);
-    second.joinElection(context);
+    second.joinElection(context, false);
     Thread.sleep(1000);
     assertEquals("original leader should have stayed leader", "http://127.0.0.1/solr/1/", getLeaderUrl("collection2", "slice1"));
     firstContext.cancelElection();

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java Thu Oct 25 13:10:25 2012
@@ -139,7 +139,7 @@ public class OverseerTest extends SolrTe
           ShardLeaderElectionContextBase ctx = new ShardLeaderElectionContextBase(
               elector, shardId, collection, nodeName + "_" + coreName, props,
               zkStateReader);
-          elector.joinElection(ctx);
+          elector.joinElection(ctx, false);
           return shardId;
         }
         Thread.sleep(500);
@@ -876,7 +876,7 @@ public class OverseerTest extends SolrTe
         new HttpShardHandlerFactory().getShardHandler(), "/admin/cores", reader);
     ElectionContext ec = new OverseerElectionContext(zkClient, overseer, address.replaceAll("/", "_"));
     overseerElector.setup(ec);
-    overseerElector.joinElection(ec);
+    overseerElector.joinElection(ec, false);
     return zkClient;
   }
   

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java Thu Oct 25 13:10:25 2012
@@ -33,8 +33,6 @@ public class AlternateDirectoryTest exte
 
   /**
    * Simple test to ensure that alternate IndexReaderFactory is being used.
-   * 
-   * @throws Exception
    */
   @Test
   public void testAltDirectoryUsed() throws Exception {

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/IndexReaderFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/IndexReaderFactoryTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/IndexReaderFactoryTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/IndexReaderFactoryTest.java Thu Oct 25 13:10:25 2012
@@ -32,8 +32,6 @@ public class IndexReaderFactoryTest exte
 
   /**
    * Simple test to ensure that alternate IndexReaderFactory is being used.
-   *
-   * @throws Exception
    */
   public void testAltReaderUsed() throws Exception {
     IndexReaderFactory readerFactory = h.getCore().getIndexReaderFactory();

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java Thu Oct 25 13:10:25 2012
@@ -37,14 +37,14 @@ public class TestCodecSupport extends So
     Map<String, SchemaField> fields = h.getCore().getSchema().getFields();
     SchemaField schemaField = fields.get("string_pulsing_f");
     PerFieldPostingsFormat format = (PerFieldPostingsFormat) codec.postingsFormat();
-    assertEquals("Pulsing40", format.getPostingsFormatForField(schemaField.getName()).getName());
+    assertEquals("Pulsing41", format.getPostingsFormatForField(schemaField.getName()).getName());
     schemaField = fields.get("string_simpletext_f");
     assertEquals("SimpleText",
         format.getPostingsFormatForField(schemaField.getName()).getName());
     schemaField = fields.get("string_standard_f");
-    assertEquals("Lucene40", format.getPostingsFormatForField(schemaField.getName()).getName());
+    assertEquals("Lucene41", format.getPostingsFormatForField(schemaField.getName()).getName());
     schemaField = fields.get("string_f");
-    assertEquals("Lucene40", format.getPostingsFormatForField(schemaField.getName()).getName());
+    assertEquals("Lucene41", format.getPostingsFormatForField(schemaField.getName()).getName());
   }
 
   public void testDynamicFields() {
@@ -53,10 +53,10 @@ public class TestCodecSupport extends So
 
     assertEquals("SimpleText", format.getPostingsFormatForField("foo_simple").getName());
     assertEquals("SimpleText", format.getPostingsFormatForField("bar_simple").getName());
-    assertEquals("Pulsing40", format.getPostingsFormatForField("foo_pulsing").getName());
-    assertEquals("Pulsing40", format.getPostingsFormatForField("bar_pulsing").getName());
-    assertEquals("Lucene40", format.getPostingsFormatForField("foo_standard").getName());
-    assertEquals("Lucene40", format.getPostingsFormatForField("bar_standard").getName());
+    assertEquals("Pulsing41", format.getPostingsFormatForField("foo_pulsing").getName());
+    assertEquals("Pulsing41", format.getPostingsFormatForField("bar_pulsing").getName());
+    assertEquals("Lucene41", format.getPostingsFormatForField("foo_standard").getName());
+    assertEquals("Lucene41", format.getPostingsFormatForField("bar_standard").getName());
   }
 
   public void testUnknownField() {

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java Thu Oct 25 13:10:25 2012
@@ -111,6 +111,46 @@ public class XmlUpdateRequestHandlerTest
   }
   
   @Test
+  public void testExternalEntities() throws Exception
+  {
+    String file = getFile("mailing_lists.pdf").toURI().toASCIIString();
+    String xml = 
+      "<?xml version=\"1.0\"?>" +
+      // check that external entities are not resolved!
+      "<!DOCTYPE foo [<!ENTITY bar SYSTEM \""+file+"\">]>" +
+      "<add>" +
+      "  &bar;" +
+      "  <doc>" +
+      "    <field name=\"id\">12345</field>" +
+      "    <field name=\"name\">kitten</field>" +
+      "  </doc>" +
+      "</add>";
+    SolrQueryRequest req = req();
+    SolrQueryResponse rsp = new SolrQueryResponse();
+    BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+    XMLLoader loader = new XMLLoader().init(null);
+    loader.load(req, rsp, new ContentStreamBase.StringStream(xml), p);
+
+    AddUpdateCommand add = p.addCommands.get(0);
+    assertEquals("12345", add.solrDoc.getField("id").getFirstValue());
+    req.close();
+  }
+
+  public void testNamedEntity() throws Exception {
+    assertU("<?xml version=\"1.0\" ?>\n"+
+            "<!DOCTYPE add [\n<!ENTITY wacky \"zzz\" >\n]>"+
+            "<add><doc>"+
+            "<field name=\"id\">1</field>"+
+            "<field name=\"foo_s\">&wacky;</field>" + 
+            "</doc></add>");
+    
+    assertU("<commit/>");
+    assertQ(req("foo_s:zzz"),
+            "//*[@numFound='1']"
+            );
+  }
+  
+  @Test
   public void testReadDelete() throws Exception {
       String xml =
         "<update>" +

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/XsltUpdateRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/XsltUpdateRequestHandlerTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/XsltUpdateRequestHandlerTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/XsltUpdateRequestHandlerTest.java Thu Oct 25 13:10:25 2012
@@ -28,9 +28,13 @@ import org.apache.solr.common.util.Conte
 import org.apache.solr.common.util.ContentStreamBase;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.loader.XMLLoader;
 import org.apache.solr.request.LocalSolrQueryRequest;
 import org.apache.solr.response.QueryResponseWriter;
+import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.update.AddUpdateCommand;
+import org.apache.solr.update.processor.BufferingRequestProcessor;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -89,4 +93,36 @@ public class XsltUpdateRequestHandlerTes
             , "//int[@name='id'][.='12345']"
         );
   }
+  
+  @Test
+  public void testEntities() throws Exception
+  {
+    // use a binary file, so when it's loaded fail with XML eror:
+    String file = getFile("mailing_lists.pdf").toURI().toASCIIString();
+    String xml = 
+      "<?xml version=\"1.0\"?>" +
+      "<!DOCTYPE foo [" + 
+      // check that external entities are not resolved!
+      "<!ENTITY bar SYSTEM \""+file+"\">"+
+      // but named entities should be
+      "<!ENTITY wacky \"zzz\">"+
+      "]>" +
+      "<random>" +
+      " &bar;" +
+      " <document>" +
+      "  <node name=\"id\" value=\"12345\"/>" +
+      "  <node name=\"foo_s\" value=\"&wacky;\"/>" +
+      " </document>" +
+      "</random>";
+    SolrQueryRequest req = req(CommonParams.TR, "xsl-update-handler-test.xsl");
+    SolrQueryResponse rsp = new SolrQueryResponse();
+    BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+    XMLLoader loader = new XMLLoader().init(null);
+    loader.load(req, rsp, new ContentStreamBase.StringStream(xml), p);
+
+    AddUpdateCommand add = p.addCommands.get(0);
+    assertEquals("12345", add.solrDoc.getField("id").getFirstValue());
+    assertEquals("zzz", add.solrDoc.getField("foo_s").getFirstValue());
+    req.close();
+  }  
 }

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java Thu Oct 25 13:10:25 2012
@@ -150,6 +150,25 @@ public class HighlighterTest extends Sol
             "//arr[@name='tv_text']/str[.=' <em>long</em> fragments.']"
             );
   }
+
+  @Test
+  public void testTermVectorWithoutOffsetsHighlight() {
+
+    HashMap<String,String> args = new HashMap<String, String>();
+    args.put("hl", "true");
+    args.put("hl.fl", "tv_no_off_text");
+
+    TestHarness.LocalRequestFactory sumLRF = h.getRequestFactory("standard", 0, 200, args);
+
+    assertU(adoc("tv_no_off_text", "Crackerjack Cameron", "id", "1"));
+    assertU(commit());
+    assertU(optimize());
+
+    assertQ("Fields with term vectors switched on but no offsets should be correctly highlighted",
+            sumLRF.makeRequest("tv_no_off_text:cameron"),
+            "//arr[@name='tv_no_off_text']/str[.='Crackerjack <em>Cameron</em>']");
+
+  }
   
   @Test
   public void testTermOffsetsTokenStream() throws Exception {
@@ -299,6 +318,22 @@ public class HighlighterTest extends Sol
     );
   }
 
+
+  @Test
+  public void testPreserveMulti() throws Exception {
+    assertU(adoc("id","1", "cat", "electronics", "cat", "monitor"));
+    assertU(commit());
+
+    assertJQ(req("q", "cat:monitor", "hl", "true", "hl.fl", "cat", "hl.snippets", "2", "f.cat.hl.preserveMulti", "true"),
+        "/highlighting/1/cat==['electronics','<em>monitor</em>']"
+    );
+
+    // No match still lists all snippets?
+    assertJQ(req("q", "id:1 OR cat:duuuude", "hl", "true", "hl.fl", "cat", "hl.snippets", "2", "f.cat.hl.preserveMulti", "true"),
+        "/highlighting/1/cat==['electronics','monitor']"
+    );
+  }
+
   @Test
   public void testDefaultFieldHighlight() {
 

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/schema/CurrencyFieldTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/schema/CurrencyFieldTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/schema/CurrencyFieldTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/schema/CurrencyFieldTest.java Thu Oct 25 13:10:25 2012
@@ -16,7 +16,6 @@ package org.apache.solr.schema;
  * limitations under the License.
  */
 
-import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.index.StorableField;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.core.SolrCore;
@@ -141,7 +140,32 @@ public class CurrencyFieldTest extends S
     assertQ(req("fl", "*,score", "q",
             "amount:[24.99,EUR TO 25.01,EUR]"),
             "//*[@numFound='1']");
-  }
+    
+    // Open ended ranges without currency
+    assertQ(req("fl", "*,score", "q",
+            "amount:[* TO *]"),
+            "//*[@numFound='10']");
+    
+    // Open ended ranges with currency
+    assertQ(req("fl", "*,score", "q",
+            "amount:[*,EUR TO *,EUR]"),
+            "//*[@numFound='10']");
+
+    // Open ended start range without currency
+    assertQ(req("fl", "*,score", "q",
+            "amount:[* TO 5,USD]"),
+            "//*[@numFound='5']");
+
+    // Open ended start range with currency (currency for the * won't matter)
+    assertQ(req("fl", "*,score", "q",
+            "amount:[*,USD TO 5,USD]"),
+            "//*[@numFound='5']");
+
+    // Open ended end range
+    assertQ(req("fl", "*,score", "q",
+            "amount:[3 TO *]"),
+            "//*[@numFound='8']");
+}
 
   @Test
   public void testCurrencyPointQuery() throws Exception {

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java Thu Oct 25 13:10:25 2012
@@ -21,9 +21,13 @@ import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.transform.*;
+
+import org.apache.lucene.util._TestUtil;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import java.util.Random;
 
 public class ReturnFieldsTest extends SolrTestCaseJ4 {
 
@@ -302,4 +306,38 @@ public class ReturnFieldsTest extends So
     assertFalse(rf.wantsField("xxx"));
     assertFalse(rf.wantsAllFields());
   }
+
+  public void testWhitespace() {
+    Random r = random();
+    final int iters = atLeast(30);
+
+    for (int i = 0; i < iters; i++) {
+      final boolean aliasId = r.nextBoolean();
+      final boolean aliasFoo = r.nextBoolean();
+
+      final String id = _TestUtil.randomWhitespace(r, 0, 3) + 
+        (aliasId ? "aliasId:" : "") +
+        "id" + 
+        _TestUtil.randomWhitespace(r, 1, 3);
+      final String foo_i = _TestUtil.randomWhitespace(r, 0, 3) + 
+        (aliasFoo ? "aliasFoo:" : "") +
+        "foo_i" + 
+        _TestUtil.randomWhitespace(r, 0, 3);
+
+      final String fl = id + (r.nextBoolean() ? "" : ",") + foo_i;
+      ReturnFields rf = new ReturnFields(req("fl", fl));
+
+      assertFalse("score ("+fl+")", rf.wantsScore());
+
+      assertTrue("id ("+fl+")", rf.wantsField("id"));
+      assertTrue("foo_i ("+fl+")", rf.wantsField("foo_i"));
+
+      assertEquals("aliasId ("+fl+")", aliasId, rf.wantsField("aliasId"));
+      assertEquals("aliasFoo ("+fl+")", aliasFoo, rf.wantsField("aliasFoo"));
+
+      assertFalse(rf.wantsField("xxx"));
+      assertFalse(rf.wantsAllFields());
+    }
+  }
+
 }

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial.java Thu Oct 25 13:10:25 2012
@@ -43,7 +43,7 @@ public class TestSolr4Spatial extends So
   @ParametersFactory
   public static Iterable<Object[]> parameters() {
     return Arrays.asList(new Object[][]{
-        {"srpt_geohash"}, {"srpt_quad"}, {"stqpt_geohash"}, {"twodoubles"}
+        {"srpt_geohash"}, {"srpt_quad"}, {"stqpt_geohash"}, {"pointvector"}
     });
   }
 
@@ -262,7 +262,7 @@ public class TestSolr4Spatial extends So
 
   @Test
   public void testSortMultiVal() throws Exception {
-    RandomizedTest.assumeFalse("Multivalue not supported for this field", fieldName.equals("twodoubles"));
+    RandomizedTest.assumeFalse("Multivalue not supported for this field", fieldName.equals("pointvector"));
 
     assertU(adoc("id", "100", fieldName, "1,2"));//1 point
     assertU(adoc("id", "101", fieldName, "4,-1", fieldName, "3,5"));//2 points, 2nd is pretty close to query point

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java Thu Oct 25 13:10:25 2012
@@ -138,7 +138,6 @@ public class FileBasedSpellCheckerTest e
 
   /**
    * No indexDir location set
-   * @throws Exception
    */
   @Test
   public void testRAMDirectory() throws Exception {

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java Thu Oct 25 13:10:25 2012
@@ -18,12 +18,24 @@
 package org.apache.solr.update;
 
 import org.apache.lucene.document.Document;
+import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.AtomicReader;
+import org.apache.lucene.index.SlowCompositeReaderWrapper;
+import org.apache.lucene.search.similarities.DefaultSimilarity;
 import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.SolrInputField;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.search.DocList;
 import org.apache.solr.schema.FieldType;
 import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.response.ResultContext;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -206,11 +218,153 @@ public class DocumentBuilderTest extends
     assertNull(h.validateUpdate(add(xml, new String[0])));
   }
   
+  public void testMultiValuedFieldAndDocBoosts() throws Exception {
+    SolrCore core = h.getCore();
+    IndexSchema schema = core.getSchema();
+    SolrInputDocument doc = new SolrInputDocument();
+    doc.setDocumentBoost(3.0f);
+    SolrInputField field = new SolrInputField( "foo_t" );
+    field.addValue( "summer time" , 1.0f );
+    field.addValue( "in the city" , 5.0f ); // using boost
+    field.addValue( "living is easy" , 1.0f );
+    doc.put( field.getName(), field );
+
+    Document out = DocumentBuilder.toDocument( doc, core.getSchema() );
+    IndexableField[] outF = out.getFields( field.getName() );
+    assertEquals("wrong number of field values",
+                 3, outF.length);
+
+    // since Lucene no longer has native documnt boosts, we should find
+    // the doc boost multiplied into the boost o nthe first field value
+    // all other field values should be 1.0f
+    // (lucene will multiply all of the field boosts later)
+    assertEquals(15.0f, outF[0].boost(), 0.0f);
+    assertEquals(1.0f, outF[1].boost(), 0.0f);
+    assertEquals(1.0f, outF[2].boost(), 0.0f);
+    
+  }
+
+  public void testCopyFieldsAndFieldBoostsAndDocBoosts() throws Exception {
+    SolrCore core = h.getCore();
+    IndexSchema schema = core.getSchema();
+    SolrInputDocument doc = new SolrInputDocument();
+
+    final float DOC_BOOST = 3.0F;
+    doc.setDocumentBoost(DOC_BOOST);
+    doc.addField("id", "42");
+
+    SolrInputField inTitle = new SolrInputField( "title" );
+    inTitle.addValue( "titleA" , 2.0F ); 
+    inTitle.addValue( "titleB" , 7.0F ); 
+    final float TITLE_BOOST = 2.0F * 7.0F;
+    assertEquals(TITLE_BOOST, inTitle.getBoost(), 0.0F);
+    doc.put( inTitle.getName(), inTitle );
+    
+    SolrInputField inFoo = new SolrInputField( "foo_t" );
+    inFoo.addValue( "summer time" , 1.0F );
+    inFoo.addValue( "in the city" , 5.0F ); 
+    inFoo.addValue( "living is easy" , 11.0F );
+    final float FOO_BOOST = 1.0F * 5.0F * 11.0F;
+    assertEquals(FOO_BOOST, inFoo.getBoost(), 0.0F);
+    doc.put( inFoo.getName(), inFoo );
+
+    Document out = DocumentBuilder.toDocument( doc, core.getSchema() );
+
+    IndexableField[] outTitle = out.getFields( inTitle.getName() );
+    assertEquals("wrong number of title values",
+                 2, outTitle.length);
+
+    IndexableField[] outNoNorms = out.getFields( "title_stringNoNorms" );
+    assertEquals("wrong number of nonorms values",
+                 2, outNoNorms.length);
+
+    IndexableField[] outFoo = out.getFields( inFoo.getName() );
+    assertEquals("wrong number of foo values",
+                 3, outFoo.length);
+
+    IndexableField[] outText = out.getFields( "text" );
+    assertEquals("wrong number of text values",
+                 5, outText.length);
+
+    // since Lucene no longer has native document boosts, we should find
+    // the doc boost multiplied into the boost on the first field value
+    // of each field.  All other field values should be 1.0f
+    // (lucene will multiply all of the field value boosts later)
+    assertEquals(TITLE_BOOST * DOC_BOOST, outTitle[0].boost(), 0.0F);
+    assertEquals(1.0F,                    outTitle[1].boost(), 0.0F);
+    //
+    assertEquals(FOO_BOOST * DOC_BOOST,   outFoo[0].boost(), 0.0F);
+    assertEquals(1.0F,                    outFoo[1].boost(), 0.0F);
+    assertEquals(1.0F,                    outFoo[2].boost(), 0.0F);
+    //
+    assertEquals(TITLE_BOOST * DOC_BOOST, outText[0].boost(), 0.0F);
+    assertEquals(1.0F,                    outText[1].boost(), 0.0F);
+    assertEquals(FOO_BOOST,               outText[2].boost(), 0.0F);
+    assertEquals(1.0F,                    outText[3].boost(), 0.0F);
+    assertEquals(1.0F,                    outText[4].boost(), 0.0F);
+    
+    // copyField dest with no norms should not have recieved any boost
+    assertEquals(1.0F, outNoNorms[0].boost(), 0.0F);
+    assertEquals(1.0F, outNoNorms[1].boost(), 0.0F);
+    
+    // now index that SolrInputDocument to check the computed norms
+
+    assertU(adoc(doc));
+    assertU(commit());
+
+    SolrQueryRequest req = req("q", "id:42");
+    try {
+      // very hack-ish
+
+      SolrQueryResponse rsp = new SolrQueryResponse();
+      core.execute(core.getRequestHandler(req.getParams().get(CommonParams.QT)), req, rsp);
+
+      DocList dl = ((ResultContext) rsp.getValues().get("response")).docs;
+      assertTrue("can't find the doc we just added", 1 == dl.size());
+      int docid = dl.iterator().nextDoc();
+
+      SolrIndexSearcher searcher = req.getSearcher();
+      AtomicReader reader = SlowCompositeReaderWrapper.wrap(searcher.getTopReaderContext().reader());
+
+      assertTrue("similarity doesn't extend DefaultSimilarity, " + 
+                 "config or defaults have changed since test was written",
+                 searcher.getSimilarity() instanceof DefaultSimilarity);
+
+      DefaultSimilarity sim = (DefaultSimilarity) searcher.getSimilarity();
+      
+      byte[] titleNorms = (byte[]) reader.normValues("title").getSource().getArray();
+      byte[] fooNorms = (byte[]) reader.normValues("foo_t").getSource().getArray();
+      byte[] textNorms = (byte[]) reader.normValues("text").getSource().getArray();
+
+      assertEquals(expectedNorm(sim, 2, TITLE_BOOST * DOC_BOOST),
+                   titleNorms[docid]);
+
+      assertEquals(expectedNorm(sim, 8-3, FOO_BOOST * DOC_BOOST),
+                   fooNorms[docid]);
+
+      assertEquals(expectedNorm(sim, 2 + 8-3, 
+                                TITLE_BOOST * FOO_BOOST * DOC_BOOST),
+                   textNorms[docid]);
+
+    } finally {
+      req.close();
+    }
+  }
+
   /**
-   * Its not ok to boost a field if it omits norms
+   * Given a length, and boost returns the expected encoded norm 
    */
+  private static byte expectedNorm(final DefaultSimilarity sim,
+                                   final int length, final float boost) {
+    
+    return sim.encodeNormValue(boost / ((float) Math.sqrt(length)));
+
+  }
+    
+
   public void testBoostOmitNorms() throws Exception {
     XmlDoc xml = new XmlDoc();
+    // explicitly boosting a field if that omits norms is not ok
     xml.xml = "<doc>"
         + "<field name=\"id\">ignore_exception</field>"
         + "<field name=\"title_stringNoNorms\" boost=\"3.0\">mytitle</field>"
@@ -221,6 +375,12 @@ public class DocumentBuilderTest extends
     } catch (SolrException expected) {
       // expected exception
     }
+    // boosting a field that is copied to another field that omits norms is ok
+    xml.xml = "<doc>"
+      + "<field name=\"id\">42</field>"
+      + "<field name=\"title\" boost=\"3.0\">mytitle</field>"
+      + "</doc>";
+    assertNull(h.validateUpdate(add(xml, new String[0])));
   }
   
   /**

Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java Thu Oct 25 13:10:25 2012
@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.concurrent.SynchronousQueue;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.solr.BaseDistributedSearchTestCase;
 import org.apache.solr.client.solrj.SolrQuery;
@@ -38,13 +39,19 @@ import org.apache.solr.common.cloud.ZkSt
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.util.ExecutorUtil;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.core.SolrEventListener;
+import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.servlet.SolrDispatchFilter;
 import org.apache.solr.update.SolrCmdDistributor.Node;
 import org.apache.solr.update.SolrCmdDistributor.Response;
 import org.apache.solr.update.SolrCmdDistributor.StdNode;
+import org.apache.solr.update.processor.DistributedUpdateProcessor;
 import org.apache.solr.util.DefaultSolrThreadFactory;
 
 public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
-  private static ThreadPoolExecutor executor;
+  private ThreadPoolExecutor executor;
   
   public SolrCmdDistributorTest() {
     fixShardCount = true;
@@ -92,6 +99,7 @@ public class SolrCmdDistributorTest exte
     SolrCmdDistributor cmdDistrib = new SolrCmdDistributor(5, executor);
     
     ModifiableSolrParams params = new ModifiableSolrParams();
+
     List<Node> nodes = new ArrayList<Node>();
 
     ZkNodeProps nodeProps = new ZkNodeProps(ZkStateReader.BASE_URL_PROP,
@@ -103,12 +111,17 @@ public class SolrCmdDistributorTest exte
     
     AddUpdateCommand cmd = new AddUpdateCommand(null);
     cmd.solrDoc = sdoc("id", 1);
+    params = new ModifiableSolrParams();
+
     cmdDistrib.distribAdd(cmd, nodes, params);
     
     CommitUpdateCommand ccmd = new CommitUpdateCommand(null, false);
+    params = new ModifiableSolrParams();
+    params.set(DistributedUpdateProcessor.COMMIT_END_POINT, true);
     cmdDistrib.distribCommit(ccmd, nodes, params);
     cmdDistrib.finish();
 
+    
     Response response = cmdDistrib.getResponse();
     
     assertEquals(response.errors.toString(), 0, response.errors.size());
@@ -125,18 +138,26 @@ public class SolrCmdDistributorTest exte
     // add another 2 docs to control and 3 to client
     cmdDistrib = new SolrCmdDistributor(5, executor);
     cmd.solrDoc = sdoc("id", 2);
+    params = new ModifiableSolrParams();
+    params.set(DistributedUpdateProcessor.COMMIT_END_POINT, true);
     cmdDistrib.distribAdd(cmd, nodes, params);
     
     AddUpdateCommand cmd2 = new AddUpdateCommand(null);
     cmd2.solrDoc = sdoc("id", 3);
 
+    params = new ModifiableSolrParams();
+    params.set(DistributedUpdateProcessor.COMMIT_END_POINT, true);
     cmdDistrib.distribAdd(cmd2, nodes, params);
     
     AddUpdateCommand cmd3 = new AddUpdateCommand(null);
     cmd3.solrDoc = sdoc("id", 4);
     
+    params = new ModifiableSolrParams();
+    params.set(DistributedUpdateProcessor.COMMIT_END_POINT, true);
     cmdDistrib.distribAdd(cmd3, Collections.singletonList(nodes.get(1)), params);
     
+    params = new ModifiableSolrParams();
+    params.set(DistributedUpdateProcessor.COMMIT_END_POINT, true);
     cmdDistrib.distribCommit(ccmd, nodes, params);
     cmdDistrib.finish();
     response = cmdDistrib.getResponse();
@@ -156,9 +177,18 @@ public class SolrCmdDistributorTest exte
     DeleteUpdateCommand dcmd = new DeleteUpdateCommand(null);
     dcmd.id = "2";
     
+    
+
     cmdDistrib = new SolrCmdDistributor(5, executor);
+    
+    params = new ModifiableSolrParams();
+    params.set(DistributedUpdateProcessor.COMMIT_END_POINT, true);
+    
     cmdDistrib.distribDelete(dcmd, nodes, params);
     
+    params = new ModifiableSolrParams();
+    params.set(DistributedUpdateProcessor.COMMIT_END_POINT, true);
+    
     cmdDistrib.distribCommit(ccmd, nodes, params);
     cmdDistrib.finish();
 
@@ -184,7 +214,7 @@ public class SolrCmdDistributorTest exte
     
     cmdDistrib = new SolrCmdDistributor(5, executor);
     
-    int cnt = atLeast(201);
+    int cnt = atLeast(303);
     for (int i = 0; i < cnt; i++) {
       nodes.clear();
       for (SolrServer c : clients) {
@@ -194,13 +224,13 @@ public class SolrCmdDistributorTest exte
         HttpSolrServer httpClient = (HttpSolrServer) c;
         nodeProps = new ZkNodeProps(ZkStateReader.BASE_URL_PROP,
             httpClient.getBaseURL(), ZkStateReader.CORE_NAME_PROP, "");
-        System.out.println("node props:" + nodeProps);
         nodes.add(new StdNode(new ZkCoreNodeProps(nodeProps)));
 
       }
       AddUpdateCommand c = new AddUpdateCommand(null);
       c.solrDoc = sdoc("id", id++);
       if (nodes.size() > 0) {
+        params = new ModifiableSolrParams();
         cmdDistrib.distribAdd(c, nodes, params);
       }
     }
@@ -214,11 +244,37 @@ public class SolrCmdDistributorTest exte
       
       nodes.add(new StdNode(new ZkCoreNodeProps(nodeProps)));
     }
+    
+    final AtomicInteger commits = new AtomicInteger();
+    for(JettySolrRunner jetty : jettys) {
+      CoreContainer cores = ((SolrDispatchFilter) jetty.getDispatchFilter().getFilter()).getCores();
+      SolrCore core = cores.getCore("collection1");
+      try {
+        core.getUpdateHandler().registerCommitCallback(new SolrEventListener() {
+          @Override
+          public void init(NamedList args) {}
+          @Override
+          public void postSoftCommit() {}
+          @Override
+          public void postCommit() {
+            commits.incrementAndGet();
+          }
+          @Override
+          public void newSearcher(SolrIndexSearcher newSearcher,
+              SolrIndexSearcher currentSearcher) {}
+        });
+      } finally {
+        core.close();
+      }
+    }
+    params = new ModifiableSolrParams();
+    params.set(DistributedUpdateProcessor.COMMIT_END_POINT, true);
 
     cmdDistrib.distribCommit(ccmd, nodes, params);
     
-    
     cmdDistrib.finish();
+
+    assertEquals(shardCount, commits.get());
     
     for (SolrServer c : clients) {
       NamedList<Object> resp = c.request(new LukeRequest());
@@ -240,6 +296,7 @@ public class SolrCmdDistributorTest exte
   @Override
   public void tearDown() throws Exception {
     ExecutorUtil.shutdownNowAndAwaitTermination(executor);
+    executor = null;
     super.tearDown();
   }
 }

Modified: lucene/dev/branches/LUCENE-2878/solr/example/exampledocs/test_utf8.sh
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/example/exampledocs/test_utf8.sh?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/example/exampledocs/test_utf8.sh (original)
+++ lucene/dev/branches/LUCENE-2878/solr/example/exampledocs/test_utf8.sh Thu Oct 25 13:10:25 2012
@@ -27,7 +27,7 @@ curl "$URL/select?q=hello&params=explici
 if [ $? = 0 ]; then
   echo "Solr server is up."
 else
-  echo "ERROR: Solr is not up."
+  echo "ERROR: Could not curl to Solr - is curl installed? Is Solr not running?"
   exit 1
 fi
 

Modified: lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/schema.xml?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/schema.xml Thu Oct 25 13:10:25 2012
@@ -686,7 +686,7 @@
       http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
     -->
     <fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
-        geo="true" distErrPct="0.025" maxDetailDist="0.000009" />
+        geo="true" distErrPct="0.025" maxDistErr="0.000009" units="degrees" />
 
    <!-- Money/currency field type. See http://wiki.apache.org/solr/MoneyFieldType
         Parameters:

Modified: lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/solrconfig.xml?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/solrconfig.xml Thu Oct 25 13:10:25 2012
@@ -136,6 +136,12 @@
     <!-- Maximum time to wait for a write lock (ms) for an IndexWriter. Default: 1000 -->
     <!-- <writeLockTimeout>1000</writeLockTimeout>  -->
 
+    <!-- The maximum number of simultaneous threads that may be
+         indexing documents at once in IndexWriter; if more than this
+         many threads arrive they will wait for others to finish.
+         Default in Solr/Lucene is 8. -->
+    <!-- <maxIndexingThreads>8</maxIndexingThreads>  -->
+
     <!-- Expert: Enabling compound file will use less files for the index, 
          using fewer file descriptors on the expense of performance decrease. 
          Default in Lucene is "true". Default in Solr is "false" (since 3.6) -->

Modified: lucene/dev/branches/LUCENE-2878/solr/licenses/javax.servlet-api-NOTICE.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/licenses/javax.servlet-api-NOTICE.txt?rev=1402140&r1=1402139&r2=1402140&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/licenses/javax.servlet-api-NOTICE.txt (original)
+++ lucene/dev/branches/LUCENE-2878/solr/licenses/javax.servlet-api-NOTICE.txt Thu Oct 25 13:10:25 2012
@@ -1,36 +1,2 @@
-==============================================================
- Jetty Web Container 
- Copyright 1995-2009 Mort Bay Consulting Pty Ltd
-==============================================================
-
-The Jetty Web Container is Copyright Mort Bay Consulting Pty Ltd
-unless otherwise noted. It is licensed under the apache 2.0
-license.
-
-The javax.servlet package used by Jetty is copyright 
-Sun Microsystems, Inc and Apache Software Foundation. It is 
-distributed under the Common Development and Distribution License.
-You can obtain a copy of the license at 
-https://glassfish.dev.java.net/public/CDDLv1.0.html.
-
-The UnixCrypt.java code ~Implements the one way cryptography used by
-Unix systems for simple password protection.  Copyright 1996 Aki Yoshida,
-modified April 2001  by Iris Van den Broeke, Daniel Deville.
-Permission to use, copy, modify and distribute UnixCrypt 
-for non-commercial or commercial purposes and without fee is
-granted provided that the copyright notice appears in all copies.
-
-The default JSP implementation is provided by the Glassfish JSP engine
-from project Glassfish http://glassfish.dev.java.net.  Copyright 2005
-Sun Microsystems, Inc. and portions Copyright Apache Software Foundation.
-
-Some portions of the code are Copyright:
-  2006 Tim Vernum 
-  1999 Jason Gilbert.
-
-The jboss integration module contains some LGPL code.
-
-The win32 Java Service Wrapper (v3.2.3) is Copyright (c) 1999, 2006 
-Tanuki Software, Inc.  and 2001 Silver Egg Technology.  It is 
-covered by an open license which is viewable at
-http://svn.codehaus.org/jetty/jetty/branches/jetty-6.1/extras/win32service/LICENSE.txt
+Servlet-api.jar is under the CDDL license, the original source
+code for this can be found at http://www.eclipse.org/jetty/downloads.php