lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sar...@apache.org
Subject svn commit: r1470979 [3/5] - in /lucene/dev/branches/branch_4x: ./ solr/ solr/contrib/ solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/ solr/contrib/dataimporthandler-extras/src/test/org/apache/solr/handler/dataimport/ solr/...
Date Tue, 23 Apr 2013 14:29:13 GMT
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java Tue Apr 23 14:29:10 2013
@@ -21,46 +21,59 @@ import org.apache.solr.cloud.ZkControlle
 import org.apache.solr.cloud.ZkSolrResourceLoader;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.common.cloud.ZkCmdExecutor;
-import org.apache.solr.common.cloud.ZooKeeperException;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrConfig;
+import org.apache.solr.core.SolrCore;
 import org.apache.solr.core.SolrResourceLoader;
-import org.apache.solr.util.FileUtils;
 import org.apache.solr.util.SystemIdResolver;
+import org.apache.solr.util.plugin.SolrCoreAware;
 import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.data.Stat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.InputSource;
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.StringWriter;
 
-public class ManagedIndexSchemaFactory extends IndexSchemaFactory {
+/** Factory for ManagedIndexSchema */
+public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements SolrCoreAware {
   private static final Logger log = LoggerFactory.getLogger(ManagedIndexSchemaFactory.class);
   private static final String UPGRADED_SCHEMA_EXTENSION = ".bak";
+  private static final String SCHEMA_DOT_XML = "schema.xml";
+
+  public static final String DEFAULT_MANAGED_SCHEMA_RESOURCE_NAME = "managed-schema";
+  public static final String MANAGED_SCHEMA_RESOURCE_NAME = "managedSchemaResourceName";
 
   private boolean isMutable;
   private String managedSchemaResourceName;
+  public String getManagedSchemaResourceName() { return managedSchemaResourceName; }
   private SolrConfig config;
   private SolrResourceLoader loader;
+  public SolrResourceLoader getResourceLoader() { return loader; }
   private String resourceName;
-  private IndexSchema schema;
+  private ManagedIndexSchema schema;
+  private SolrCore core;
+  private ZkIndexSchemaReader zkIndexSchemaReader;
+
+
+  private String loadedResource;
+  private boolean shouldUpgrade = false;
 
   @Override
   public void init(NamedList args) {
     SolrParams params = SolrParams.toSolrParams(args);
     isMutable = params.getBool("mutable", false);
     args.remove("mutable");
-    managedSchemaResourceName = params.get("managedSchemaResourceName", "managed-schema");
-    args.remove("managedSchemaResourceName");
-    if ("schema.xml".equals(managedSchemaResourceName)) {
-      String msg = "managedSchemaResourceName can't be 'schema.xml'";
+    managedSchemaResourceName = params.get(MANAGED_SCHEMA_RESOURCE_NAME, DEFAULT_MANAGED_SCHEMA_RESOURCE_NAME);
+    args.remove(MANAGED_SCHEMA_RESOURCE_NAME);
+    if (SCHEMA_DOT_XML.equals(managedSchemaResourceName)) {
+      String msg = MANAGED_SCHEMA_RESOURCE_NAME + " can't be '" + SCHEMA_DOT_XML + "'";
       log.error(msg);
       throw new SolrException(ErrorCode.SERVER_ERROR, msg);
     }
@@ -89,35 +102,102 @@ public class ManagedIndexSchemaFactory e
    * After the managed schema file is persisted, the original schema file is
    * renamed by appending the extension named in {@link #UPGRADED_SCHEMA_EXTENSION}.
    */
-  public IndexSchema create(String resourceName, SolrConfig config) {
+  @Override
+  public ManagedIndexSchema create(String resourceName, SolrConfig config) {
     this.resourceName = resourceName;
     this.config = config;
-    SolrResourceLoader loader = config.getResourceLoader();
-    this.loader = loader;
+    this.loader = config.getResourceLoader();
     InputStream schemaInputStream = null;
-    boolean shouldUpgrade = false;
-    String loadedResource = null;
 
     if (null == resourceName) {
       resourceName = IndexSchema.DEFAULT_SCHEMA_FILE;
     }
 
+    int schemaZkVersion = -1;
+    if ( ! (loader instanceof ZkSolrResourceLoader)) {
+      schemaInputStream = readSchemaLocally();
+    } else { // ZooKeeper
+      final ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader;
+      final SolrZkClient zkClient = zkLoader.getZkController().getZkClient();
+      final String managedSchemaPath = zkLoader.getCollectionZkPath() + "/" + managedSchemaResourceName;
+      Stat stat = new Stat();
+      try {
+        // Attempt to load the managed schema
+        byte[] data = zkClient.getData(managedSchemaPath, null, stat, true);
+        schemaZkVersion = stat.getVersion();
+        schemaInputStream = new ByteArrayInputStream(data);
+        loadedResource = managedSchemaResourceName;
+        warnIfNonManagedSchemaExists();
+      } catch (InterruptedException e) {
+        // Restore the interrupted status
+        Thread.currentThread().interrupt();
+        log.warn("", e);
+      } catch (KeeperException.NoNodeException e) {
+        log.info("The schema is configured as managed, but managed schema resource " + managedSchemaResourceName
+                + " not found - loading non-managed schema " + resourceName + " instead");
+      } catch (KeeperException e) {
+        String msg = "Error attempting to access " + managedSchemaPath;
+        log.error(msg, e);
+        throw new SolrException(ErrorCode.SERVER_ERROR, msg, e);
+      }
+      if (null == schemaInputStream) {
+        // The managed schema file could not be found - load the non-managed schema
+        try {
+          schemaInputStream = loader.openSchema(resourceName);
+          loadedResource = resourceName;
+          shouldUpgrade = true;
+        } catch (Exception e) {
+          try {
+            // Retry to load the managed schema, in case it was created since the first attempt
+            byte[] data = zkClient.getData(managedSchemaPath, null, stat, true);
+            schemaZkVersion = stat.getVersion();
+            schemaInputStream = new ByteArrayInputStream(data);
+            warnIfNonManagedSchemaExists();
+          } catch (Exception e1) {
+            if (e1 instanceof InterruptedException) {
+              Thread.currentThread().interrupt(); // Restore the interrupted status
+            }
+            final String msg = "Error loading both non-managed schema '" + resourceName + "' and managed schema '"
+                             + managedSchemaResourceName + "'";
+            log.error(msg, e);
+            throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg, e);
+          }
+        }
+      }
+    }
+    InputSource inputSource = new InputSource(schemaInputStream);
+    inputSource.setSystemId(SystemIdResolver.createSystemIdFromResourceName(loadedResource));
+    try {
+      schema = new ManagedIndexSchema(config, loadedResource, inputSource, isMutable, 
+                                      managedSchemaResourceName, schemaZkVersion, getSchemaUpdateLock());
+    } catch (KeeperException e) {
+      final String msg = "Error instantiating ManagedIndexSchema";
+      log.error(msg, e);
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg, e);
+    } catch (InterruptedException e) {
+      // Restore the interrupted status
+      Thread.currentThread().interrupt();
+      log.warn("", e);
+    }
+
+    if (shouldUpgrade) {
+      // Persist the managed schema if it doesn't already exist
+      upgradeToManagedSchema();
+    }
+
+    return schema;
+  }
+
+  private InputStream readSchemaLocally() {
+    InputStream schemaInputStream = null;
     try {
       // Attempt to load the managed schema
       schemaInputStream = loader.openSchema(managedSchemaResourceName);
       loadedResource = managedSchemaResourceName;
-
-      // Check if the non-managed schema is also present
-      if ( ! resourceName.equals(managedSchemaResourceName)) {
-        if (nonManagedSchemaExists()) {
-          // Warn if the non-managed schema is present
-          log.warn("The schema has been upgraded to managed, but the non-managed schema " + resourceName
-              + " is still loadable.  PLEASE REMOVE THIS FILE.");
-        }
-      }
+      warnIfNonManagedSchemaExists();
     } catch (IOException e) {
-      log.info("SolrConfig.isManagedSchema = true, but managed schema resource " + managedSchemaResourceName
-          + " not found - loading non-managed schema " + resourceName + " instead");
+      log.info("The schema is configured as managed, but managed schema resource " + managedSchemaResourceName
+              + " not found - loading non-managed schema " + resourceName + " instead");
     }
     if (null == schemaInputStream) {
       // The managed schema file could not be found - load the non-managed schema
@@ -126,63 +206,54 @@ public class ManagedIndexSchemaFactory e
         loadedResource = resourceName;
         shouldUpgrade = true;
       } catch (Exception e) {
-        try {
-          // Retry to load the managed schema, in case it was created since the first attempt
-          schemaInputStream = loader.openSchema(managedSchemaResourceName);
-          loadedResource = managedSchemaResourceName;
-        } catch (IOException e1) {
-          final String msg = "Error loading both non-managed schema '" + resourceName + "' and managed schema '"
-                           + managedSchemaResourceName + "'";
-          log.error(msg, e);
-          throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg, e);
-        }
+        final String msg = "Error loading both non-managed schema '" + resourceName + "' and managed schema '"
+                         + managedSchemaResourceName + "'";
+        log.error(msg, e);
+        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg, e);
       }
     }
-    InputSource inputSource = new InputSource(schemaInputStream);
-    inputSource.setSystemId(SystemIdResolver.createSystemIdFromResourceName(loadedResource));
-    schema = new ManagedIndexSchema(config, loadedResource, inputSource, isMutable);
-
-    if (shouldUpgrade) {
-      // Persist the managed schema if it doesn't already exist
-      upgradeToManagedSchema();
-    }
-    return schema;
+    return schemaInputStream; 
   }
 
   /**
    * Return whether a non-managed schema exists, either in local storage or on ZooKeeper. 
    */
-  private boolean nonManagedSchemaExists() {
-    boolean exists = false;
-    SolrResourceLoader loader = config.getResourceLoader();
-    if (loader instanceof ZkSolrResourceLoader) {
-      ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader;
-      String nonManagedSchemaPath = zkLoader.getCollectionZkPath() + "/" + resourceName;
-      try {
-        exists = zkLoader.getZkController().pathExists(nonManagedSchemaPath);
-      } catch (InterruptedException e) {
-        Thread.currentThread().interrupt(); // Restore the interrupted status
-        log.warn("", e); // Log as warning and suppress the exception 
-      } catch (KeeperException e) {
-        // log as warning and suppress the exception
-        log.warn("Error checking for the existence of the non-managed schema " + resourceName, e);
-      }
-    } else { // Config is not in ZooKeeper
-      InputStream nonManagedSchemaInputStream = null;
-      try {
-        nonManagedSchemaInputStream = loader.openSchema(resourceName);
-        if (null != nonManagedSchemaInputStream) {
-          exists = true;
+  private void warnIfNonManagedSchemaExists() {
+    if ( ! resourceName.equals(managedSchemaResourceName)) {
+      boolean exists = false;
+      SolrResourceLoader loader = config.getResourceLoader();
+      if (loader instanceof ZkSolrResourceLoader) {
+        ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader;
+        String nonManagedSchemaPath = zkLoader.getCollectionZkPath() + "/" + resourceName;
+        try {
+          exists = zkLoader.getZkController().pathExists(nonManagedSchemaPath);
+        } catch (InterruptedException e) {
+          Thread.currentThread().interrupt(); // Restore the interrupted status
+          log.warn("", e); // Log as warning and suppress the exception 
+        } catch (KeeperException e) {
+          // log as warning and suppress the exception
+          log.warn("Error checking for the existence of the non-managed schema " + resourceName, e);
+        }
+      } else { // Config is not in ZooKeeper
+        InputStream nonManagedSchemaInputStream = null;
+        try {
+          nonManagedSchemaInputStream = loader.openSchema(resourceName);
+          if (null != nonManagedSchemaInputStream) {
+            exists = true;
+          }
+        } catch (IOException e) {
+          // This is expected when the non-managed schema does not exist
+        } finally {
+          IOUtils.closeQuietly(nonManagedSchemaInputStream);
         }
-      } catch (IOException e) {
-        // This is expected when the non-managed schema does not exist
-      } finally {
-        IOUtils.closeQuietly(nonManagedSchemaInputStream);
+      }
+      if (exists) {
+        log.warn("The schema has been upgraded to managed, but the non-managed schema " + resourceName
+                + " is still loadable.  PLEASE REMOVE THIS FILE.");
       }
     }
-    return exists;
   }
-
+  
   /**
    * Persist the managed schema and rename the non-managed schema 
    * by appending {@link #UPGRADED_SCHEMA_EXTENSION}.
@@ -196,33 +267,7 @@ public class ManagedIndexSchemaFactory e
       zkUgradeToManagedSchema();
     } else {
       // Configs are not on ZooKeeper
-      File managedSchemaFile = new File(loader.getConfigDir(), managedSchemaResourceName);
-      OutputStreamWriter writer = null;
-      try {
-        File parentDir = managedSchemaFile.getParentFile();
-        if (!parentDir.isDirectory()) {
-          if (!parentDir.mkdirs()) {
-            final String msg = "Can't create managed schema directory " + parentDir.getAbsolutePath();
-            throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg);
-          }
-        }
-        final FileOutputStream out = new FileOutputStream(managedSchemaFile);
-        writer = new OutputStreamWriter(out, "UTF-8");
-        schema.persist(writer);
-        log.info("Upgraded to managed schema at " + managedSchemaFile.getPath());
-      } catch (IOException e) {
-        final String msg = "Error persisting managed schema " + managedSchemaFile;
-        log.error(msg, e);
-        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg, e);
-      } finally {
-        IOUtils.closeQuietly(writer);
-        try {
-          FileUtils.sync(managedSchemaFile);
-        } catch (IOException e) {
-          final String msg = "Error syncing the managed schema file " + managedSchemaFile;
-          log.error(msg, e);
-        }
-      }
+      schema.persistManagedSchema(true);  // Only create it - don't update it if it already exists
 
       // After successfully persisting the managed schema, rename the non-managed
       // schema file by appending UPGRADED_SCHEMA_EXTENSION to its name.
@@ -293,29 +338,7 @@ public class ManagedIndexSchemaFactory e
    * and no exception will be thrown.
    */
   private void zkUgradeToManagedSchema() {
-    ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)config.getResourceLoader();
-    ZkCmdExecutor zkCmdExecutor = new ZkCmdExecutor(30);
-    ZkController zkController = zkLoader.getZkController();
-    final String managedSchemaPath = zkLoader.getCollectionZkPath() + "/" + managedSchemaResourceName;
-    try {
-      // Create the managed schema znode
-      zkCmdExecutor.ensureExists(managedSchemaPath, zkController.getZkClient());
-      // Persist the managed schema
-      StringWriter writer = new StringWriter();
-      schema.persist(writer);
-      zkController.getZkClient().setData(managedSchemaPath, writer.toString().getBytes("UTF-8"), true);
-      log.info("Upgraded to managed schema at " + managedSchemaPath + "");
-    } catch (Exception e) {
-      if (e instanceof InterruptedException) {
-        Thread.currentThread().interrupt(); // Restore the interrupted status
-        log.error("", e);
-        throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
-      } else {
-        final String msg = "Error persisting managed schema resource " + managedSchemaResourceName;
-        log.error(msg, e);
-        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg, e);
-      }
-    }
+    schema.persistManagedSchemaToZooKeeper(true); // Only create, don't update it if it already exists
 
     // After successfully persisting the managed schema, rename the non-managed
     // schema znode by appending UPGRADED_SCHEMA_EXTENSION to its name.
@@ -325,8 +348,11 @@ public class ManagedIndexSchemaFactory e
           + resourceName + " because it's the same as the managed schema's name.");
     } else {
       // Rename the non-managed schema znode in ZooKeeper
+      ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader;
       final String nonManagedSchemaPath = zkLoader.getCollectionZkPath() + "/" + resourceName;
       try {
+        ZkController zkController = zkLoader.getZkController();
+        ZkCmdExecutor zkCmdExecutor = new ZkCmdExecutor(zkController.getClientTimeout());
         if (zkController.pathExists(nonManagedSchemaPath)) {
           // First, copy the non-managed schema znode content to the upgraded schema znode
           byte[] bytes = zkController.getZkClient().getData(nonManagedSchemaPath, null, null, true);
@@ -340,20 +366,40 @@ public class ManagedIndexSchemaFactory e
           schema.setResourceName(managedSchemaResourceName);
 
           log.info("After upgrading to managed schema in ZooKeeper, renamed the non-managed schema "
-              + nonManagedSchemaPath + " to " + upgradedSchemaPath);
+                  + nonManagedSchemaPath + " to " + upgradedSchemaPath);
         } else {
           log.info("After upgrading to managed schema in ZooKeeper, the non-managed schema "
-              + nonManagedSchemaPath + " no longer exists.");
+                  + nonManagedSchemaPath + " no longer exists.");
         }
       } catch (Exception e) {
         if (e instanceof InterruptedException) {
           Thread.currentThread().interrupt(); // Restore the interrupted status
-          log.warn("", e); // Log as warning and suppress the exception 
-        } else {
-          final String msg = "Error persisting managed schema resource " + managedSchemaResourceName;
-          log.warn(msg, e); // Log as warning and suppress the exception
         }
+        final String msg = "Error persisting managed schema resource " + managedSchemaResourceName;
+        log.warn(msg, e); // Log as warning and suppress the exception
       }
     }
   }
+
+  private Object schemaUpdateLock = new Object();
+  public Object getSchemaUpdateLock() { return schemaUpdateLock; }
+
+  @Override
+  public void inform(SolrCore core) {
+    this.core = core;
+    if (loader instanceof ZkSolrResourceLoader) {
+      this.zkIndexSchemaReader = new ZkIndexSchemaReader(this);
+    } else {
+      this.zkIndexSchemaReader = null;
+    }
+  }
+
+  public ManagedIndexSchema getSchema() {
+    return schema;
+  }
+
+  public void setSchema(ManagedIndexSchema schema) {
+    this.schema = schema;
+    core.setLatestSchema(schema);
+  }
 }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/PointType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/PointType.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/PointType.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/PointType.java Tue Apr 23 14:29:10 2013
@@ -55,7 +55,6 @@ public class PointType extends Coordinat
               "The dimension must be > 0: " + dimension);
     }
     args.remove(DIMENSION);
-    this.schema = schema;
     super.init(schema, args);
 
     // cache suffixes
@@ -83,7 +82,7 @@ public class PointType extends Coordinat
 
     if (field.indexed()) {
       for (int i=0; i<dimension; i++) {
-        SchemaField sf = subField(field, i);
+        SchemaField sf = subField(field, i, schema);
         f.add(sf.createField(point[i], sf.indexed() && !sf.omitNorms() ? boost : 1f));
       }
     }
@@ -102,7 +101,7 @@ public class PointType extends Coordinat
   public ValueSource getValueSource(SchemaField field, QParser parser) {
     ArrayList<ValueSource> vs = new ArrayList<ValueSource>(dimension);
     for (int i=0; i<dimension; i++) {
-      SchemaField sub = subField(field, i);
+      SchemaField sub = subField(field, i, schema);
       vs.add(sub.getType().getValueSource(sub, parser));
     }
     return new PointTypeValueSource(field, vs);
@@ -146,7 +145,7 @@ public class PointType extends Coordinat
     }
     BooleanQuery result = new BooleanQuery(true);
     for (int i = 0; i < dimension; i++) {
-      SchemaField subSF = subField(field, i);
+      SchemaField subSF = subField(field, i, schema);
       // points must currently be ordered... should we support specifying any two opposite corner points?
       result.add(subSF.getType().getRangeQuery(parser, subSF, p1[i], p2[i], minInclusive, maxInclusive), BooleanClause.Occur.MUST);
     }
@@ -164,7 +163,7 @@ public class PointType extends Coordinat
     //TODO: should we assert that p1.length == dimension?
     BooleanQuery bq = new BooleanQuery(true);
     for (int i = 0; i < dimension; i++) {
-      SchemaField sf = subField(field, i);
+      SchemaField sf = subField(field, i, schema);
       Query tq = sf.getType().getFieldQuery(parser, sf, p1[i]);
       bq.add(tq, BooleanClause.Occur.MUST);
     }
@@ -186,11 +185,12 @@ public class PointType extends Coordinat
     } catch (InvalidShapeException e) {
       throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
     }
+    IndexSchema schema = parser.getReq().getSchema();
     if (dimension == 1){
       //TODO: Handle distance measures
       String lower = String.valueOf(point[0] - options.distance);
       String upper = String.valueOf(point[0] + options.distance);
-      SchemaField subSF = subField(options.field, 0);
+      SchemaField subSF = subField(options.field, 0, schema);
       // points must currently be ordered... should we support specifying any two opposite corner points?
       result = subSF.getType().getRangeQuery(parser, subSF, lower, upper, true, true);
     } else {
@@ -199,7 +199,7 @@ public class PointType extends Coordinat
       double [] ur = DistanceUtils.vectorBoxCorner(point, null, options.distance, true);
       double [] ll = DistanceUtils.vectorBoxCorner(point, null, options.distance, false);
       for (int i = 0; i < ur.length; i++) {
-        SchemaField subSF = subField(options.field, i);
+        SchemaField subSF = subField(options.field, i, schema);
         Query range = subSF.getType().getRangeQuery(parser, subSF, String.valueOf(ll[i]), String.valueOf(ur[i]), true, true);
         tmp.add(range, BooleanClause.Occur.MUST);
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SchemaField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SchemaField.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SchemaField.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SchemaField.java Tue Apr 23 14:29:10 2013
@@ -21,7 +21,6 @@ import org.apache.solr.common.SolrExcept
 import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.search.SortField;
 import org.apache.solr.common.util.SimpleOrderedMap;
-import org.apache.solr.common.util.StrUtils;
 import org.apache.solr.search.QParser;
 
 import org.apache.solr.response.TextResponseWriter;
@@ -49,7 +48,7 @@ public final class SchemaField extends F
   boolean required = false;  // this can't be final since it may be changed dynamically
   
   /** Declared field property overrides */
-  Map<String,String> args = Collections.emptyMap();
+  Map<String,?> args = Collections.emptyMap();
 
 
   /** Create a new SchemaField with the given name and type,
@@ -195,14 +194,14 @@ public final class SchemaField extends F
     
   }
 
-  static SchemaField create(String name, FieldType ft, Map<String,String> props) {
+  static SchemaField create(String name, FieldType ft, Map<String,?> props) {
 
     String defaultValue = null;
     if (props.containsKey(DEFAULT_VALUE)) {
-      defaultValue = props.get(DEFAULT_VALUE);
+      defaultValue = (String)props.get(DEFAULT_VALUE);
     }
     SchemaField field = new SchemaField(name, ft, calcProps(name, ft, props), defaultValue);
-    field.args = new HashMap<String,String>(props);
+    field.args = new HashMap<String,Object>(props);
     return field;
   }
 
@@ -220,7 +219,7 @@ public final class SchemaField extends F
     return new SchemaField(name, ft, props, defValue);
   }
 
-  static int calcProps(String name, FieldType ft, Map<String, String> props) {
+  static int calcProps(String name, FieldType ft, Map<String,?> props) {
     int trueProps = parseProperties(props,true,true);
     int falseProps = parseProperties(props,false,true);
 
@@ -334,13 +333,14 @@ public final class SchemaField extends F
       // The BINARY property is always false
       // properties.add(getPropertyName(BINARY), isBinary());
     } else {
-      for (Map.Entry<String,String> arg : args.entrySet()) {
+      for (Map.Entry<String,?> arg : args.entrySet()) {
         String key = arg.getKey();
-        String value = arg.getValue();
+        Object value = arg.getValue();
         if (key.equals(DEFAULT_VALUE)) {
           properties.add(key, value);
         } else {
-          properties.add(key, StrUtils.parseBool(value, false));
+          boolean boolVal = value instanceof Boolean ? (Boolean)value : Boolean.parseBoolean(value.toString());
+          properties.add(key, boolVal);
         }
       }
     }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SpatialPointVectorFieldType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SpatialPointVectorFieldType.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SpatialPointVectorFieldType.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/schema/SpatialPointVectorFieldType.java Tue Apr 23 14:29:10 2013
@@ -43,6 +43,14 @@ public class SpatialPointVectorFieldType
 
   }
 
+  /**
+   * Adds X and Y fields to the given schema for each field with this class as its field type.
+   * 
+   * {@inheritDoc}
+   * 
+   * @param schema {@inheritDoc}
+   *
+   */
   @Override
   public void inform(IndexSchema schema) {
     FieldType fieldType = schema.getFieldTypeByName(numberFieldName);

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java Tue Apr 23 14:29:10 2013
@@ -1442,10 +1442,10 @@ public class ExtendedDismaxQParser exten
     public ExtendedDismaxConfiguration(SolrParams localParams,
         SolrParams params, SolrQueryRequest req) {
       solrParams = SolrParams.wrapDefaults(localParams, params);
-      minShouldMatch = DisMaxQParser.parseMinShouldMatch(req.getSchema(), solrParams);
+      minShouldMatch = DisMaxQParser.parseMinShouldMatch(req.getSchema(), solrParams); // req.getSearcher() here causes searcher refcount imbalance
       userFields = new UserFields(U.parseFieldBoosts(solrParams.getParams(DMP.UF)));
       try {
-        queryFields = DisMaxQParser.parseQueryFields(req.getSchema(), solrParams);
+        queryFields = DisMaxQParser.parseQueryFields(req.getSchema(), solrParams);  // req.getSearcher() here causes searcher refcount imbalance
       } catch (SyntaxError e) {
         throw new RuntimeException();
       }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/grouping/distributed/requestfactory/TopGroupsShardRequestFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/grouping/distributed/requestfactory/TopGroupsShardRequestFactory.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/grouping/distributed/requestfactory/TopGroupsShardRequestFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/grouping/distributed/requestfactory/TopGroupsShardRequestFactory.java Tue Apr 23 14:29:10 2013
@@ -27,6 +27,7 @@ import org.apache.solr.common.params.Sha
 import org.apache.solr.handler.component.ResponseBuilder;
 import org.apache.solr.handler.component.ShardRequest;
 import org.apache.solr.schema.FieldType;
+import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.search.Grouping;
 import org.apache.solr.search.SolrIndexSearcher;
 import org.apache.solr.search.grouping.distributed.ShardRequestFactory;
@@ -112,12 +113,13 @@ public class TopGroupsShardRequestFactor
     }
 
     sreq.params.set(GroupParams.GROUP_DISTRIBUTED_SECOND, "true");
+    final IndexSchema schema = rb.req.getSearcher().getSchema();
     for (Map.Entry<String, Collection<SearchGroup<BytesRef>>> entry : rb.mergedSearchGroups.entrySet()) {
       for (SearchGroup<BytesRef> searchGroup : entry.getValue()) {
         String groupValue;
         if (searchGroup.groupValue != null) {
           String rawGroupValue = searchGroup.groupValue.utf8ToString();
-          FieldType fieldType = rb.req.getSearcher().getSchema().getField(entry.getKey()).getType();
+          FieldType fieldType = schema.getField(entry.getKey()).getType();
           groupValue = fieldType.indexedToReadable(rawGroupValue);
         } else {
           groupValue = GROUP_NULL_VALUE;
@@ -127,9 +129,9 @@ public class TopGroupsShardRequestFactor
     }
 
     if ((rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES) != 0 || rb.getSortSpec().includesScore()) {
-      sreq.params.set(CommonParams.FL, rb.req.getSchema().getUniqueKeyField().getName() + ",score");
+      sreq.params.set(CommonParams.FL, schema.getUniqueKeyField().getName() + ",score");
     } else {
-      sreq.params.set(CommonParams.FL, rb.req.getSchema().getUniqueKeyField().getName());
+      sreq.params.set(CommonParams.FL, schema.getUniqueKeyField().getName());
     }
     
     int origTimeAllowed = sreq.params.getInt(CommonParams.TIME_ALLOWED, -1);

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java Tue Apr 23 14:29:10 2013
@@ -32,6 +32,7 @@ import org.apache.solr.common.util.Named
 import org.apache.solr.handler.component.ResponseBuilder;
 import org.apache.solr.handler.component.ShardDoc;
 import org.apache.solr.schema.FieldType;
+import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.SchemaField;
 import org.apache.solr.search.grouping.Command;
 import org.apache.solr.search.grouping.distributed.command.QueryCommand;
@@ -66,11 +67,12 @@ public class TopGroupsResultTransformer 
   @Override
   public NamedList transform(List<Command> data) throws IOException {
     NamedList<NamedList> result = new NamedList<NamedList>();
+    final IndexSchema schema = rb.req.getSearcher().getSchema();
     for (Command command : data) {
       NamedList commandResult;
       if (TopGroupsFieldCommand.class.isInstance(command)) {
         TopGroupsFieldCommand fieldCommand = (TopGroupsFieldCommand) command;
-        SchemaField groupField = rb.req.getSearcher().getSchema().getField(fieldCommand.getKey());
+        SchemaField groupField = schema.getField(fieldCommand.getKey());
         commandResult = serializeTopGroups(fieldCommand.result(), groupField);
       } else if (QueryCommand.class.isInstance(command)) {
         QueryCommand queryCommand = (QueryCommand) command;
@@ -184,7 +186,8 @@ public class TopGroupsResultTransformer 
     }
     CharsRef spare = new CharsRef();
 
-    SchemaField uniqueField = rb.req.getSearcher().getSchema().getUniqueKeyField();
+    final IndexSchema schema = rb.req.getSearcher().getSchema();
+    SchemaField uniqueField = schema.getUniqueKeyField();
     for (GroupDocs<BytesRef> searchGroup : data.groups) {
       NamedList<Object> groupResult = new NamedList<Object>();
       groupResult.add("totalHits", searchGroup.totalHits);
@@ -211,7 +214,7 @@ public class TopGroupsResultTransformer 
         for (int j = 0; j < fieldDoc.fields.length; j++) {
           Object sortValue  = fieldDoc.fields[j];
           Sort sortWithinGroup = rb.getGroupingSpec().getSortWithinGroup();
-          SchemaField field = sortWithinGroup.getSort()[j].getField() != null ? rb.req.getSearcher().getSchema().getFieldOrNull(sortWithinGroup.getSort()[j].getField()) : null;
+          SchemaField field = sortWithinGroup.getSort()[j].getField() != null ? schema.getFieldOrNull(sortWithinGroup.getSort()[j].getField()) : null;
           if (field != null) {
             FieldType fieldType = field.getType();
             if (sortValue instanceof BytesRef) {
@@ -244,7 +247,8 @@ public class TopGroupsResultTransformer 
     List<NamedList> documents = new ArrayList<NamedList>();
     queryResult.add("documents", documents);
 
-    SchemaField uniqueField = rb.req.getSearcher().getSchema().getUniqueKeyField();
+    final IndexSchema schema = rb.req.getSearcher().getSchema();
+    SchemaField uniqueField = schema.getUniqueKeyField();
     CharsRef spare = new CharsRef();
     for (ScoreDoc scoreDoc : result.getTopDocs().scoreDocs) {
       NamedList<Object> document = new NamedList<Object>();
@@ -264,7 +268,8 @@ public class TopGroupsResultTransformer 
       for (int j = 0; j < fieldDoc.fields.length; j++) {
         Object sortValue  = fieldDoc.fields[j];
         Sort groupSort = rb.getGroupingSpec().getGroupSort();
-        SchemaField field = groupSort.getSort()[j].getField() != null ? rb.req.getSearcher().getSchema().getFieldOrNull(groupSort.getSort()[j].getField()) : null;
+        SchemaField field = groupSort.getSort()[j].getField() != null 
+                          ? schema.getFieldOrNull(groupSort.getSort()[j].getField()) : null;
         if (field != null) {
           FieldType fieldType = field.getType();
           if (sortValue instanceof BytesRef) {

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/similarities/SchemaSimilarityFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/similarities/SchemaSimilarityFactory.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/similarities/SchemaSimilarityFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/similarities/SchemaSimilarityFactory.java Tue Apr 23 14:29:10 2013
@@ -20,14 +20,15 @@ package org.apache.solr.search.similarit
 import org.apache.lucene.search.similarities.DefaultSimilarity;
 import org.apache.lucene.search.similarities.PerFieldSimilarityWrapper;
 import org.apache.lucene.search.similarities.Similarity;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.core.SolrCore;
 import org.apache.solr.schema.FieldType;
-import org.apache.solr.schema.IndexSchema;
-import org.apache.solr.schema.SchemaAware;
 import org.apache.solr.schema.SimilarityFactory;
+import org.apache.solr.util.plugin.SolrCoreAware;
 
 /**
  * SimilarityFactory that returns a {@link PerFieldSimilarityWrapper}
- * that delegates to the field type, if its configured, otherwise
+ * that delegates to the field type, if it's configured, otherwise
  * {@link DefaultSimilarity}.
  *
  * <p>
@@ -42,16 +43,23 @@ import org.apache.solr.schema.Similarity
  *
  * @see FieldType#getSimilarity
  */
-public class SchemaSimilarityFactory extends SimilarityFactory implements SchemaAware {
+public class SchemaSimilarityFactory extends SimilarityFactory implements SolrCoreAware {
   private Similarity similarity;
   private Similarity defaultSimilarity = new DefaultSimilarity();
+  private volatile SolrCore core;
+
+  @Override
+  public void inform(SolrCore core) {
+    this.core = core;
+  }
   
   @Override
-  public void inform(final IndexSchema schema) {
+  public void init(SolrParams args) {
+    super.init(args);
     similarity = new PerFieldSimilarityWrapper() {
       @Override
       public Similarity get(String name) {
-        FieldType fieldType = schema.getFieldTypeNoEx(name);
+        FieldType fieldType = core.getLatestSchema().getFieldTypeNoEx(name);
         if (fieldType == null) {
           return defaultSimilarity;
         } else {
@@ -64,7 +72,7 @@ public class SchemaSimilarityFactory ext
 
   @Override
   public Similarity getSimilarity() {
-    assert similarity != null : "inform must be called first";
+    assert core != null : "inform must be called first";
     return similarity;
   }
 }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java Tue Apr 23 14:29:10 2013
@@ -44,6 +44,7 @@ import org.apache.commons.fileupload.dis
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.apache.lucene.util.IOUtils;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.MultiMapSolrParams;
 import org.apache.solr.common.params.SolrParams;
@@ -161,7 +162,7 @@ public class SolrRequestParsers 
     String[] strs = params.getParams( CommonParams.STREAM_URL );
     if( strs != null ) {
       if( !enableRemoteStreams ) {
-        throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Remote Streaming is disabled." );
+        throw new SolrException( ErrorCode.BAD_REQUEST, "Remote Streaming is disabled." );
       }
       for( final String url : strs ) {
         ContentStreamBase stream = new ContentStreamBase.URLStream( new URL(url) );
@@ -176,7 +177,7 @@ public class SolrRequestParsers 
     strs = params.getParams( CommonParams.STREAM_FILE );
     if( strs != null ) {
       if( !enableRemoteStreams ) {
-        throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Remote Streaming is disabled." );
+        throw new SolrException( ErrorCode.BAD_REQUEST, "Remote Streaming is disabled." );
       }
       for( final String file : strs ) {
         ContentStreamBase stream = new ContentStreamBase.FileStream( new File(file) );
@@ -232,7 +233,7 @@ public class SolrRequestParsers 
             if (pos < len) {
               final char ch = queryString.charAt(pos);
               if (ch > 127) {
-                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "URLDecoder: The query string contains a not-%-escaped byte > 127 at position " + pos);
+                throw new SolrException(ErrorCode.BAD_REQUEST, "URLDecoder: The query string contains a not-%-escaped byte > 127 at position " + pos);
               }
               pos++;
               return ch;
@@ -243,7 +244,7 @@ public class SolrRequestParsers 
         };
         parseFormDataContent(in, Long.MAX_VALUE, IOUtils.CHARSET_UTF_8, map);
       } catch (IOException ioe) {
-        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, ioe);
+        throw new SolrException(ErrorCode.BAD_REQUEST, ioe);
       }
     }
   }
@@ -273,7 +274,7 @@ public class SolrRequestParsers 
             final String key = decodeChars(keyStream, keyPos, charsetDecoder), value = decodeChars(valueStream, valuePos, charsetDecoder);
             MultiMapSolrParams.addParam(key, value, map);
           } else if (valueStream.size() > 0) {
-            throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "application/x-www-form-urlencoded invalid: missing key");
+            throw new SolrException(ErrorCode.BAD_REQUEST, "application/x-www-form-urlencoded invalid: missing key");
           }
           keyStream.reset();
           valueStream.reset();
@@ -305,7 +306,7 @@ public class SolrRequestParsers 
       }
       len++;
       if (len > maxLen) {
-        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "application/x-www-form-urlencoded content exceeds upload limit of " + (maxLen/1024L) + " KB");
+        throw new SolrException(ErrorCode.BAD_REQUEST, "application/x-www-form-urlencoded content exceeds upload limit of " + (maxLen/1024L) + " KB");
       }
     }
     return len;
@@ -315,7 +316,7 @@ public class SolrRequestParsers 
     try {
       return charsetDecoder.decode(ByteBuffer.wrap(stream.buffer(), 0, stream.size())).toString();
     } catch (CharacterCodingException cce) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
+      throw new SolrException(ErrorCode.BAD_REQUEST,
         "URLDecoder: Invalid character encoding detected after position " + position +
         " of query string / form data (while parsing as " + charsetDecoder.charset().name() + ")"
       );
@@ -331,7 +332,7 @@ public class SolrRequestParsers 
   
   private static int digit16(int b) {
     if (b == -1) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "URLDecoder: Incomplete trailing escape (%) pattern");
+      throw new SolrException(ErrorCode.BAD_REQUEST, "URLDecoder: Incomplete trailing escape (%) pattern");
     }
     if (b >= '0' && b <= '9') {
       return b - '0';
@@ -342,7 +343,7 @@ public class SolrRequestParsers 
     if (b >= 'a' && b <= 'f') {
       return b - ('a' - 10);
     }
-    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "URLDecoder: Invalid digit (" + ((char) b) + ") in escape (%) pattern");
+    throw new SolrException(ErrorCode.BAD_REQUEST, "URLDecoder: Invalid digit (" + ((char) b) + ") in escape (%) pattern");
   }
   
   public boolean isHandleSelect() {
@@ -471,7 +472,7 @@ class MultipartRequestParser implements 
       final HttpServletRequest req, ArrayList<ContentStream> streams ) throws Exception
   {
     if( !ServletFileUpload.isMultipartContent(req) ) {
-      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Not multipart content! "+req.getContentType() );
+      throw new SolrException( ErrorCode.BAD_REQUEST, "Not multipart content! "+req.getContentType() );
     }
     
     MultiMapSolrParams params = SolrRequestParsers.parseQueryString( req.getQueryString() );
@@ -526,7 +527,7 @@ class FormDataRequestParser implements S
       final HttpServletRequest req, ArrayList<ContentStream> streams ) throws Exception
   {
     if (!isFormData(req)) {
-      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Not application/x-www-form-urlencoded content: "+req.getContentType() );
+      throw new SolrException( ErrorCode.BAD_REQUEST, "Not application/x-www-form-urlencoded content: "+req.getContentType() );
     }
     
     final Map<String,String[]> map = new HashMap<String, String[]>();
@@ -541,7 +542,7 @@ class FormDataRequestParser implements S
     final long totalLength = req.getContentLength();
     final long maxLength = ((long) uploadLimitKB) * 1024L;
     if (totalLength > maxLength) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "application/x-www-form-urlencoded content length (" +
+      throw new SolrException(ErrorCode.BAD_REQUEST, "application/x-www-form-urlencoded content length (" +
         totalLength + " bytes) exceeds upload limit of " + uploadLimitKB + " KB");
     }
     
@@ -556,7 +557,7 @@ class FormDataRequestParser implements S
         throw getParameterIncompatibilityException();
       }
     } catch (IOException ioe) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, ioe);
+      throw new SolrException(ErrorCode.BAD_REQUEST, ioe);
     } catch (IllegalStateException ise) {
       throw (SolrException) getParameterIncompatibilityException().initCause(ise);
     } finally {
@@ -567,7 +568,7 @@ class FormDataRequestParser implements S
   }
   
   private SolrException getParameterIncompatibilityException() {
-    return new SolrException(SolrException.ErrorCode.SERVER_ERROR,
+    return new SolrException(ErrorCode.SERVER_ERROR,
       "Solr requires that request parameters sent using application/x-www-form-urlencoded " +
       "content-type can be read through the request input stream. Unfortunately, the " +
       "stream was empty / not available. This may be caused by another servlet filter calling " +
@@ -613,7 +614,8 @@ class StandardRequestParser implements S
       final HttpServletRequest req, ArrayList<ContentStream> streams ) throws Exception
   {
     String method = req.getMethod().toUpperCase(Locale.ROOT);
-    if ("GET".equals(method) || "HEAD".equals(method)) {
+    if ("GET".equals(method) || "HEAD".equals(method) 
+        || ("PUT".equals(method) && req.getRequestURI().contains("/schema"))) {
       return SolrRequestParsers.parseQueryString(req.getQueryString());
     }
     if ("POST".equals( method ) ) {
@@ -625,7 +627,7 @@ class StandardRequestParser implements S
       }
       return raw.parseParamsAndFillStreams(req, streams);
     }
-    throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Unsupported method: "+method );
+    throw new SolrException(ErrorCode.BAD_REQUEST, "Unsupported method: " + method + " for request " + req);
   }
 }
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java Tue Apr 23 14:29:10 2013
@@ -21,7 +21,13 @@ import java.io.InputStreamReader;
 import java.util.List;
 
 import org.apache.lucene.document.Field;
-import org.apache.lucene.index.*;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.LogByteSizeMergePolicy;
+import org.apache.lucene.index.LogMergePolicy;
+import org.apache.solr.schema.IndexSchema;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -60,7 +66,7 @@ public class FileBasedSpellChecker exten
 
   @Override
   public void build(SolrCore core, SolrIndexSearcher searcher) throws IOException {
-    loadExternalFileDictionary(core);
+    loadExternalFileDictionary(core, searcher);
     spellChecker.clearIndex();
     // TODO: you should be able to specify the IWC params?
     // TODO: if we enable this, codec gets angry since field won't exist in the schema
@@ -76,12 +82,12 @@ public class FileBasedSpellChecker exten
     return null;
   }
 
-  private void loadExternalFileDictionary(SolrCore core) {
+  private void loadExternalFileDictionary(SolrCore core, SolrIndexSearcher searcher) {
     try {
-
+      IndexSchema schema = null == searcher ? core.getLatestSchema() : searcher.getSchema();
       // Get the field's analyzer
-      if (fieldTypeName != null && core.getSchema().getFieldTypeNoEx(fieldTypeName) != null) {
-        FieldType fieldType = core.getSchema().getFieldTypes().get(fieldTypeName);
+      if (fieldTypeName != null && schema.getFieldTypeNoEx(fieldTypeName) != null) {
+        FieldType fieldType = schema.getFieldTypes().get(fieldTypeName);
         // Do index-time analysis using the given fieldType's analyzer
         RAMDirectory ramDir = new RAMDirectory();
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/SolrSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/SolrSpellChecker.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/SolrSpellChecker.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/SolrSpellChecker.java Tue Apr 23 14:29:10 2013
@@ -29,6 +29,7 @@ import org.apache.solr.common.util.Named
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.handler.component.SpellCheckMergeData;
 import org.apache.solr.schema.FieldType;
+import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.search.SolrIndexSearcher;
 
 import java.io.IOException;
@@ -63,12 +64,13 @@ public abstract class SolrSpellChecker {
       name = DEFAULT_DICTIONARY_NAME;
     }
     field = (String)config.get(FIELD);
-    if (field != null && core.getSchema().getFieldTypeNoEx(field) != null)  {
-      analyzer = core.getSchema().getFieldType(field).getQueryAnalyzer();
+    IndexSchema schema = core.getLatestSchema();
+    if (field != null && schema.getFieldTypeNoEx(field) != null)  {
+      analyzer = schema.getFieldType(field).getQueryAnalyzer();
     }
     fieldTypeName = (String) config.get(FIELD_TYPE);
-    if (core.getSchema().getFieldTypes().containsKey(fieldTypeName))  {
-      FieldType fieldType = core.getSchema().getFieldTypes().get(fieldTypeName);
+    if (schema.getFieldTypes().containsKey(fieldTypeName))  {
+      FieldType fieldType = schema.getFieldTypes().get(fieldTypeName);
       analyzer = fieldType.getQueryAnalyzer();
     }
     if (analyzer == null)   {

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/suggest/fst/AnalyzingLookupFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/suggest/fst/AnalyzingLookupFactory.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/suggest/fst/AnalyzingLookupFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/suggest/fst/AnalyzingLookupFactory.java Tue Apr 23 14:29:10 2013
@@ -77,7 +77,7 @@ public class AnalyzingLookupFactory exte
     if (fieldTypeName == null) {
       throw new IllegalArgumentException("Error in configuration: " + QUERY_ANALYZER + " parameter is mandatory");
     }
-    FieldType ft = core.getSchema().getFieldTypeByName(fieldTypeName.toString());
+    FieldType ft = core.getLatestSchema().getFieldTypeByName(fieldTypeName.toString());
     Analyzer indexAnalyzer = ft.getAnalyzer();
     Analyzer queryAnalyzer = ft.getQueryAnalyzer();
     

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/suggest/fst/FuzzyLookupFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/suggest/fst/FuzzyLookupFactory.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/suggest/fst/FuzzyLookupFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/spelling/suggest/fst/FuzzyLookupFactory.java Tue Apr 23 14:29:10 2013
@@ -67,7 +67,7 @@ public class FuzzyLookupFactory extends 
       throw new IllegalArgumentException("Error in configuration: " + AnalyzingLookupFactory.QUERY_ANALYZER + " parameter is mandatory");
     }
     // retrieve index and query analyzers for the field
-    FieldType ft = core.getSchema().getFieldTypeByName(fieldTypeName.toString());
+    FieldType ft = core.getLatestSchema().getFieldTypeByName(fieldTypeName.toString());
     Analyzer indexAnalyzer = ft.getAnalyzer();
     Analyzer queryAnalyzer = ft.getQueryAnalyzer();
     

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java Tue Apr 23 14:29:10 2013
@@ -195,7 +195,7 @@ public final class DefaultSolrCoreState 
   
   protected SolrIndexWriter createMainIndexWriter(SolrCore core, String name) throws IOException {
     return SolrIndexWriter.create(name, core.getNewIndexDir(),
-        core.getDirectoryFactory(), false, core.getSchema(),
+        core.getDirectoryFactory(), false, core.getLatestSchema(),
         core.getSolrConfig().indexConfig, core.getDeletionPolicy(), core.getCodec());
   }
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java Tue Apr 23 14:29:10 2013
@@ -51,6 +51,7 @@ import org.apache.solr.request.LocalSolr
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.SolrRequestInfo;
 import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.SchemaField;
 import org.apache.solr.search.FunctionRangeQuery;
 import org.apache.solr.search.QParser;
@@ -157,6 +158,7 @@ public class DirectUpdateHandler2 extend
       }
       
       try {
+        IndexSchema schema = cmd.getReq().getSchema();
         
         if (cmd.overwrite) {
           
@@ -396,7 +398,7 @@ public class DirectUpdateHandler2 extend
       RefCounted<IndexWriter> iw = solrCoreState.getIndexWriter(core);
       try {
         IndexWriter writer = iw.get();
-        writer.updateDocument(idTerm, luceneDocument, core.getSchema()
+        writer.updateDocument(idTerm, luceneDocument, cmd.getReq().getSchema()
             .getAnalyzer());
         
         for (Query q : dbqList) {

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java Tue Apr 23 14:29:10 2013
@@ -17,8 +17,6 @@
 
 package org.apache.solr.update;
 
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 
 import org.apache.lucene.document.Document;
@@ -38,143 +36,6 @@ import org.apache.solr.schema.SchemaFiel
 
 // Not thread safe - by design.  Create a new builder for each thread.
 public class DocumentBuilder {
-  private final IndexSchema schema;
-  private Document doc;
-  private HashMap<String,String> map;
-
-  public DocumentBuilder(IndexSchema schema) {
-    this.schema = schema;
-  }
-
-  public void startDoc() {
-    doc = new Document();
-    map = new HashMap<String,String>();
-  }
-
-  protected void addSingleField(SchemaField sfield, String val, float boost) {
-    //System.out.println("###################ADDING FIELD "+sfield+"="+val);
-
-    // we don't check for a null val ourselves because a solr.FieldType
-    // might actually want to map it to something.  If createField()
-    // returns null, then we don't store the field.
-    List<IndexableField> fields = sfield.createFields(val, boost);
-    if (!fields.isEmpty()) {
-      if (!sfield.multiValued()) {
-        String oldValue = map.put(sfield.getName(), val);
-        if (oldValue != null) {
-          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "ERROR: multiple values encountered for non multiValued field " + sfield.getName()
-                  + ": first='" + oldValue + "' second='" + val + "'");
-        }
-      }
-      // Add each field
-      for (IndexableField field : fields) {
-        doc.add((Field) field);
-      }
-    }
-
-  }
-
-  /**
-   * Add the specified {@link org.apache.solr.schema.SchemaField} to the document.  Does not invoke the copyField mechanism.
-   * @param sfield The {@link org.apache.solr.schema.SchemaField} to add
-   * @param val The value to add
-   * @param boost The boost factor
-   *
-   * @see #addField(String, String)
-   * @see #addField(String, String, float)
-   * @see #addSingleField(org.apache.solr.schema.SchemaField, String, float)
-   */
-  public void addField(SchemaField sfield, String val, float boost) {
-    addSingleField(sfield,val,boost);
-  }
-
-  /**
-   * Add the Field and value to the document, invoking the copyField mechanism
-   * @param name The name of the field
-   * @param val The value to add
-   *
-   * @see #addField(String, String, float)
-   * @see #addField(org.apache.solr.schema.SchemaField, String, float)
-   * @see #addSingleField(org.apache.solr.schema.SchemaField, String, float)
-   */
-  public void addField(String name, String val) {
-    addField(name, val, 1.0f);
-  }
-
-  /**
-   * Add the Field and value to the document with the specified boost, invoking the copyField mechanism
-   * @param name The name of the field.
-   * @param val The value to add
-   * @param boost The boost
-   *
-   * @see #addField(String, String)
-   * @see #addField(org.apache.solr.schema.SchemaField, String, float)
-   * @see #addSingleField(org.apache.solr.schema.SchemaField, String, float)
-   *
-   */
-  public void addField(String name, String val, float boost) {
-    SchemaField sfield = schema.getFieldOrNull(name);
-    if (sfield != null) {
-      addField(sfield,val,boost);
-    }
-
-    // Check if we should copy this field to any other fields.
-    // This could happen whether it is explicit or not.
-    final List<CopyField> copyFields = schema.getCopyFieldsList(name);
-    if (copyFields != null) {
-      for(CopyField cf : copyFields) {
-        addSingleField(cf.getDestination(), cf.getLimitedValue( val ), boost);
-      }
-    }
-
-    // error if this field name doesn't match anything
-    if (sfield==null && (copyFields==null || copyFields.size()==0)) {
-      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"ERROR:unknown field '" + name + "'");
-    }
-  }
-
-  public void endDoc() {
-  }
-
-  // specific to this type of document builder
-  public Document getDoc() throws IllegalArgumentException {
-    
-    // Check for all required fields -- Note, all fields with a
-    // default value are defacto 'required' fields.  
-    List<String> missingFields = null;
-    for (SchemaField field : schema.getRequiredFields()) {
-      if (doc.getField(field.getName() ) == null) {
-        if (field.getDefaultValue() != null) {
-          addField(doc, field, field.getDefaultValue(), 1.0f);
-        } else {
-          if (missingFields==null) {
-            missingFields = new ArrayList<String>(1);
-          }
-          missingFields.add(field.getName());
-        }
-      }
-    }
-  
-    if (missingFields != null) {
-      StringBuilder builder = new StringBuilder();
-      // add the uniqueKey if possible
-      if( schema.getUniqueKeyField() != null ) {
-        String n = schema.getUniqueKeyField().getName();
-        String v = doc.getField( n ).stringValue();
-        builder.append( "Document ["+n+"="+v+"] " );
-      }
-      builder.append("missing required fields: " );
-      for (String field : missingFields) {
-        builder.append(field);
-        builder.append(" ");
-      }
-      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, builder.toString());
-    }
-    
-    Document ret = doc; doc=null;
-    return ret;
-  }
-
 
   private static void addField(Document doc, SchemaField field, Object val, float boost) {
     if (val instanceof IndexableField) {

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java Tue Apr 23 14:29:10 2013
@@ -57,8 +57,8 @@ public class SolrIndexSplitter {
   int currPartition = 0;
 
   public SolrIndexSplitter(SplitIndexCommand cmd) {
-    field = cmd.getReq().getSchema().getUniqueKeyField();
     searcher = cmd.getReq().getSearcher();
+    field = searcher.getSchema().getUniqueKeyField();
     ranges = cmd.ranges;
     paths = cmd.paths;
     cores = cmd.cores;
@@ -109,7 +109,7 @@ public class SolrIndexSplitter {
         SolrCore core = searcher.getCore();
         String path = paths.get(partitionNumber);
         iw = SolrIndexWriter.create("SplittingIndexWriter"+partitionNumber + (ranges != null ? " " + ranges.get(partitionNumber) : ""), path,
-                                    core.getDirectoryFactory(), true, core.getSchema(),
+                                    core.getDirectoryFactory(), true, core.getLatestSchema(),
                                     core.getSolrConfig().indexConfig, core.getDeletionPolicy(), core.getCodec());
       }
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/UpdateHandler.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/UpdateHandler.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/UpdateHandler.java Tue Apr 23 14:29:10 2013
@@ -27,7 +27,6 @@ import org.apache.solr.core.SolrCore;
 import org.apache.solr.core.SolrEventListener;
 import org.apache.solr.core.SolrInfoMBean;
 import org.apache.solr.schema.FieldType;
-import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.SchemaField;
 import org.apache.solr.util.plugin.SolrCoreAware;
 import org.slf4j.Logger;
@@ -45,7 +44,6 @@ public abstract class UpdateHandler impl
   protected final static Logger log = LoggerFactory.getLogger(UpdateHandler.class);
 
   protected final SolrCore core;
-  protected final IndexSchema schema;
 
   protected final SchemaField idField;
   protected final FieldType idFieldType;
@@ -125,8 +123,7 @@ public abstract class UpdateHandler impl
   
   public UpdateHandler(SolrCore core, UpdateLog updateLog)  {
     this.core=core;
-    schema = core.getSchema();
-    idField = schema.getUniqueKeyField();
+    idField = core.getLatestSchema().getUniqueKeyField();
     idFieldType = idField!=null ? idField.getType() : null;
     parseEventListeners();
     PluginInfo ulogPluginInfo = core.getSolrConfig().getPluginInfo(UpdateLog.class.getName());

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/VersionInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/VersionInfo.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/VersionInfo.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/VersionInfo.java Tue Apr 23 14:29:10 2013
@@ -27,7 +27,6 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.util.BitUtil;
 import org.apache.lucene.util.BytesRef;
 import org.apache.solr.common.SolrException;
-import org.apache.solr.core.SolrCore;
 import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.SchemaField;
 import org.apache.solr.search.SolrIndexSearcher;
@@ -79,9 +78,9 @@ public class VersionInfo {
 
   public VersionInfo(UpdateLog ulog, int nBuckets) {
     this.ulog = ulog;
-    SolrCore core = ulog.uhandler.core;
-    versionField = getAndCheckVersionField(core.getSchema());
-    idField = core.getSchema().getUniqueKeyField();
+    IndexSchema schema = ulog.uhandler.core.getLatestSchema(); 
+    versionField = getAndCheckVersionField(schema);
+    idField = schema.getUniqueKeyField();
     buckets = new VersionBucket[ BitUtil.nextHighestPowerOfTwo(nBuckets) ];
     for (int i=0; i<buckets.length; i++) {
       buckets[i] = new VersionBucket();

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.java Tue Apr 23 14:29:10 2013
@@ -17,17 +17,12 @@
 package org.apache.solr.update.processor;
 
 import java.io.IOException;
-import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.HashSet;
 
-import org.apache.solr.schema.IndexSchema;
-
 import org.apache.solr.core.SolrCore;
-import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.util.plugin.SolrCoreAware;
 
 import org.apache.solr.common.util.NamedList;
@@ -36,15 +31,13 @@ import org.apache.solr.common.SolrInputF
 import org.apache.solr.common.SolrInputDocument;
 
 import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrException.ErrorCode;
-import static org.apache.solr.common.SolrException.ErrorCode.*;
+import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;
 
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
 
 import org.apache.solr.update.AddUpdateCommand;
 
-import org.apache.solr.update.processor.FieldMutatingUpdateProcessorFactory;
 import org.apache.solr.update.processor.FieldMutatingUpdateProcessorFactory.SelectorParams;
 import org.apache.solr.update.processor.FieldMutatingUpdateProcessor.FieldNameSelector;
 
@@ -200,12 +193,10 @@ public class CloneFieldUpdateProcessorFa
   @Override
   public void inform(final SolrCore core) {
     
-    final IndexSchema schema = core.getSchema();
-
     srcSelector = 
       FieldMutatingUpdateProcessor.createFieldNameSelector
       (core.getResourceLoader(),
-       core.getSchema(),
+       core,
        srcInclusions.fieldName,
        srcInclusions.typeName,
        srcInclusions.typeClass,
@@ -217,7 +208,7 @@ public class CloneFieldUpdateProcessorFa
         (srcSelector,
          FieldMutatingUpdateProcessor.createFieldNameSelector
          (core.getResourceLoader(),
-          core.getSchema(),
+          core,
           exc.fieldName,
           exc.typeName,
           exc.typeClass,

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.java Tue Apr 23 14:29:10 2013
@@ -95,10 +95,10 @@ public final class ConcatFieldUpdateProc
   public FieldMutatingUpdateProcessor.FieldNameSelector 
     getDefaultSelector(final SolrCore core) {
 
-    final IndexSchema schema = core.getSchema();
     return new FieldMutatingUpdateProcessor.FieldNameSelector() {
       @Override
       public boolean shouldMutate(final String fieldName) {
+        final IndexSchema schema = core.getLatestSchema();
 
         // first check type since it should be fastest
         FieldType type = schema.getFieldTypeNoEx(fieldName);

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java Tue Apr 23 14:29:10 2013
@@ -57,6 +57,7 @@ import org.apache.solr.handler.component
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.SolrRequestInfo;
 import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.SchemaField;
 import org.apache.solr.update.AddUpdateCommand;
 import org.apache.solr.update.CommitUpdateCommand;
@@ -685,6 +686,7 @@ public class DistributedUpdateProcessor 
       oldDoc.remove(VERSION_FIELD);
     }
 
+    IndexSchema schema = cmd.getReq().getSchema();
     for (SolrInputField sif : sdoc.values()) {
       Object val = sif.getValue();
       if (val instanceof Map) {
@@ -706,7 +708,7 @@ public class DistributedUpdateProcessor 
             } else {
               // TODO: fieldtype needs externalToObject?
               String oldValS = numericField.getFirstValue().toString();
-              SchemaField sf = cmd.getReq().getSchema().getField(sif.getName());
+              SchemaField sf = schema.getField(sif.getName());
               BytesRef term = new BytesRef();
               sf.getType().readableToIndexed(oldValS, term);
               Object oldVal = sf.getType().toObject(sf, term);

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessor.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessor.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessor.java Tue Apr 23 14:29:10 2013
@@ -18,27 +18,21 @@
 package org.apache.solr.update.processor;
 
 import java.io.IOException;
-import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
 
-import static org.apache.solr.common.SolrException.ErrorCode.*;
+import static org.apache.solr.common.SolrException.ErrorCode.BAD_REQUEST;
+import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;
 
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.SolrInputField;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.core.SolrCore;
 import org.apache.solr.core.SolrResourceLoader;
-import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.FieldType;
 
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.update.AddUpdateCommand;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -197,7 +191,7 @@ public abstract class FieldMutatingUpdat
    */
   public static FieldNameSelector createFieldNameSelector
     (final SolrResourceLoader loader,
-     final IndexSchema schema,
+     final SolrCore core,
      final Set<String> fields,
      final Set<String> typeNames,
      final Collection<String> typeClasses,
@@ -223,25 +217,24 @@ public abstract class FieldMutatingUpdat
       return defSelector;
     }
     
-    return new ConfigurableFieldNameSelector
-      (schema, fields, typeNames, classes, regexes); 
+    return new ConfigurableFieldNameSelector(core, fields, typeNames, classes, regexes); 
   }
   
   private static final class ConfigurableFieldNameSelector 
     implements FieldNameSelector {
 
-    final IndexSchema schema;
+    final SolrCore core;
     final Set<String> fields;
     final Set<String> typeNames;
     final Collection<Class> classes;
     final Collection<Pattern> regexes;
 
-    private ConfigurableFieldNameSelector(final IndexSchema schema,
+    private ConfigurableFieldNameSelector(final SolrCore core,
                                           final Set<String> fields,
                                           final Set<String> typeNames,
                                           final Collection<Class> classes,
                                           final Collection<Pattern> regexes) {
-      this.schema = schema;
+      this.core = core;
       this.fields = fields;
       this.typeNames = typeNames;
       this.classes = classes;
@@ -260,7 +253,7 @@ public abstract class FieldMutatingUpdat
       
       // do not consider it an error if the fieldName has no type
       // there might be another processor dealing with it later
-      FieldType t = schema.getFieldTypeNoEx(fieldName);
+      FieldType t =  core.getLatestSchema().getFieldTypeNoEx(fieldName);
       if (null != t) {
         if (! (typeNames.isEmpty() || typeNames.contains(t.getTypeName())) ) {
           return false;

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessorFactory.java Tue Apr 23 14:29:10 2013
@@ -17,7 +17,6 @@
 
 package org.apache.solr.update.processor;
 
-import java.io.IOException;
 import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -32,11 +31,6 @@ import org.apache.solr.core.SolrCore;
 import org.apache.solr.common.SolrException;
 import static org.apache.solr.common.SolrException.ErrorCode.*;
 import org.apache.solr.common.util.NamedList;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.update.AddUpdateCommand;
-import org.apache.solr.schema.IndexSchema;
-import org.apache.solr.schema.FieldType;
 import org.apache.solr.util.plugin.SolrCoreAware;
 
 
@@ -199,12 +193,10 @@ public abstract class FieldMutatingUpdat
   @Override
   public void inform(final SolrCore core) {
     
-    final IndexSchema schema = core.getSchema();
-
     selector = 
       FieldMutatingUpdateProcessor.createFieldNameSelector
       (core.getResourceLoader(),
-       core.getSchema(),
+       core,
        inclusions.fieldName,
        inclusions.typeName,
        inclusions.typeClass,
@@ -216,7 +208,7 @@ public abstract class FieldMutatingUpdat
         (selector,
          FieldMutatingUpdateProcessor.createFieldNameSelector
          (core.getResourceLoader(),
-          core.getSchema(),
+          core,
           exc.fieldName,
           exc.typeName,
           exc.typeClass,

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/IgnoreFieldUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/IgnoreFieldUpdateProcessorFactory.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/IgnoreFieldUpdateProcessorFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/IgnoreFieldUpdateProcessorFactory.java Tue Apr 23 14:29:10 2013
@@ -22,7 +22,6 @@ import org.apache.solr.schema.IndexSchem
 import org.apache.solr.schema.FieldType;
 
 import org.apache.solr.common.SolrInputField;
-import org.apache.solr.common.util.NamedList;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
 
@@ -71,11 +70,10 @@ public final class IgnoreFieldUpdateProc
   public FieldMutatingUpdateProcessor.FieldNameSelector 
     getDefaultSelector(final SolrCore core) {
 
-    final IndexSchema schema = core.getSchema();
     return new FieldMutatingUpdateProcessor.FieldNameSelector() {
       @Override
       public boolean shouldMutate(final String fieldName) {
-
+        final IndexSchema schema = core.getLatestSchema();
         FieldType type = schema.getFieldTypeNoEx(fieldName);
         return (null == type);
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/PreAnalyzedUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/PreAnalyzedUpdateProcessorFactory.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/PreAnalyzedUpdateProcessorFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/PreAnalyzedUpdateProcessorFactory.java Tue Apr 23 14:29:10 2013
@@ -125,7 +125,7 @@ public class PreAnalyzedUpdateProcessorF
     if (parserImpl != null) {
       args.put(PreAnalyzedField.PARSER_IMPL, parserImpl);
     }
-    parser.init(core.getSchema(), args);
+    parser.init(core.getLatestSchema(), args);
   }  
 }
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/SignatureUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/SignatureUpdateProcessorFactory.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/SignatureUpdateProcessorFactory.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/SignatureUpdateProcessorFactory.java Tue Apr 23 14:29:10 2013
@@ -75,7 +75,7 @@ public class SignatureUpdateProcessorFac
 
   @Override
   public void inform(SolrCore core) {
-    final SchemaField field = core.getSchema().getFieldOrNull(getSignatureField());
+    final SchemaField field = core.getLatestSchema().getFieldOrNull(getSignatureField());
     if (null == field) {
       throw new SolrException
         (ErrorCode.SERVER_ERROR,

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java Tue Apr 23 14:29:10 2013
@@ -19,8 +19,13 @@ package org.apache.solr.util;
 
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.IndexableField;
-import org.apache.lucene.search.*;
+import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.DisjunctionMaxQuery;
+import org.apache.lucene.search.Explanation;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Sort;
 import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrDocumentList;
 import org.apache.solr.common.SolrException;
@@ -38,10 +43,27 @@ import org.apache.solr.request.SolrQuery
 import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.SchemaField;
-import org.apache.solr.search.*;
+import org.apache.solr.search.CacheRegenerator;
+import org.apache.solr.search.DocIterator;
+import org.apache.solr.search.DocList;
+import org.apache.solr.search.DocSet;
+import org.apache.solr.search.FieldParams;
+import org.apache.solr.search.QParser;
+import org.apache.solr.search.QueryParsing;
+import org.apache.solr.search.ReturnFields;
+import org.apache.solr.search.SolrCache;
+import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.search.SolrQueryParser;
+import org.apache.solr.search.SyntaxError;
 
 import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.regex.Pattern;
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationTargetException;
@@ -152,7 +174,7 @@ public class SolrPluginUtils {
           fieldFilter.add(field);
 
         // fetch unique key if one exists.
-        SchemaField keyField = req.getSearcher().getSchema().getUniqueKeyField();
+        SchemaField keyField = searcher.getSchema().getUniqueKeyField();
         if(null != keyField)
           fieldFilter.add(keyField.getName());
       }
@@ -270,7 +292,7 @@ public class SolrPluginUtils {
   {
     if (dbgResults) {
       SolrIndexSearcher searcher = req.getSearcher();
-      IndexSchema schema = req.getSchema();
+      IndexSchema schema = searcher.getSchema();
       boolean explainStruct = req.getParams().getBool(CommonParams.EXPLAIN_STRUCT, false);
 
       NamedList<Explanation> explain = getExplanations(query, results, searcher, schema);

Modified: lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog-managed-schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog-managed-schema.xml?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog-managed-schema.xml (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog-managed-schema.xml Tue Apr 23 14:29:10 2013
@@ -64,29 +64,6 @@
     </updateLog>
   </updateHandler>
 
-  <updateRequestProcessorChain name="dedupe">
-    <processor class="org.apache.solr.update.processor.SignatureUpdateProcessorFactory">
-      <bool name="enabled">true</bool>
-      <bool name="overwriteDupes">true</bool>
-      <str name="fields">v_t,t_field</str>
-      <str name="signatureClass">org.apache.solr.update.processor.TextProfileSignature</str>
-    </processor>
-    <processor class="solr.RunUpdateProcessorFactory" />
-  </updateRequestProcessorChain>
-  <updateRequestProcessorChain name="stored_sig">
-    <!-- this chain is valid even though the signature field is not
-         indexed, because we are not asking for dups to be overwritten
-      -->
-    <processor class="org.apache.solr.update.processor.SignatureUpdateProcessorFactory">
-      <bool name="enabled">true</bool>
-      <str name="signatureField">non_indexed_signature_sS</str>
-      <bool name="overwriteDupes">false</bool>
-      <str name="fields">v_t,t_field</str>
-      <str name="signatureClass">org.apache.solr.update.processor.TextProfileSignature</str>
-    </processor>
-    <processor class="solr.RunUpdateProcessorFactory" />
-  </updateRequestProcessorChain>
-
   <requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
 
   <updateRequestProcessorChain name="distrib-dup-test-chain-explicit">

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/MinimalSchemaTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/MinimalSchemaTest.java?rev=1470979&r1=1470978&r2=1470979&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/MinimalSchemaTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/MinimalSchemaTest.java Tue Apr 23 14:29:10 2013
@@ -43,7 +43,7 @@ public class MinimalSchemaTest extends S
        a uniqueKey field and defeat the point of the tests
     */
     assertNull("UniqueKey Field isn't null", 
-               h.getCore().getSchema().getUniqueKeyField());
+               h.getCore().getLatestSchema().getUniqueKeyField());
 
     lrf.args.put(CommonParams.VERSION,"2.2");
 



Mime
View raw message