Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-10887: Append .xml to managed-schema file VERSION 2 (#279)

Eric Pughdf903cbdc1de
diff --git a/dev-docs/overseer/overseer.adoc b/dev-docs/overseer/overseer.adoc
index 6929270a6de..350096b6633 100644
--- a/dev-docs/overseer/overseer.adoc
+++ b/dev-docs/overseer/overseer.adoc
@@ -322,7 +322,7 @@ These messages are received from the Collection API queue (there’s a single qu
The `createConfigSet()` call implementing `CREATE` copies all the files of an existing config set (by default the `_default` config set) into a new config set, merges the existing config set properties if any with new ones specified in the message (config set properties in the message are properties that start with `"configSetProp."`, for example `configSetProp.immutable` is a property that prevents the config set from ever being deleted) and writes the resulting properties into `/configs/<config set name>/configsetprops.json` (note: creating a config set based on an `immutable` config set makes the new one immutable as well unless it explicitly specifies that `configSetProp.immutable` is false).
-Note the `_default` config set is defined in the SolrCloud distribution and copied if absent into Zookeeper when SolrCloud starts (`ZkController.bootstrapDefaultConfigSet`) then used only from Zookeeper. This config set has a directory `lang` with language specific stop words, contractions and other, and it contains files `managed-schema`, `params.json`, `protwords.txt`, `solrconfig.xml`, `stopwords.txt` and `synonyms.txt`.
+Note the `_default` config set is defined in the SolrCloud distribution and copied if absent into Zookeeper when SolrCloud starts (`ZkController.bootstrapDefaultConfigSet`) then used only from Zookeeper. This config set has a directory `lang` with language specific stop words, contractions and other, and it contains files `managed-schema.xml`, `params.json`, `protwords.txt`, `solrconfig.xml`, `stopwords.txt` and `synonyms.txt`.
deleteConfigSet() deletes the whole znode structure at `/configs/_<config set name>_` assuming the config set is not used by any collection and is not immutable (the only case where an immutable config set can be deleted is when its creation has failed midway).
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 4d53d9c8f06..43e0b366777 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -143,6 +143,8 @@ when told to. The admin UI now tells it to. (Nazerke Seidan, David Smiley)
This was already working for XML & "javabin"/SolrJ. Previously, omitting the ID would be confused
for a partial/atomic update. (David Smiley)
+* SOLR-10887: Migrate "managed-schema" file naming to "managed-schema.xml" file name, with a fallback to the legacy "managed-schema". (Eric Pugh, David Smiley)
+
Build
---------------------
diff --git a/solr/core/src/java/org/apache/solr/core/ConfigSetService.java b/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
index a4b246a03fc..de80fbaf41f 100644
--- a/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
+++ b/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
@@ -265,7 +265,7 @@ public abstract class ConfigSetService {
// This is the schema name that we think will actually be used. In the case of a managed schema,
// we don't know for sure without examining what files exists in the configSet, and we don't
// want to pay the overhead of that at this juncture. If we guess wrong, no schema sharing.
- // The fix is usually to name your schema managed-schema instead of schema.xml.
+ // The fix is usually to name your schema managed-schema.xml instead of schema.xml.
IndexSchemaFactory indexSchemaFactory = IndexSchemaFactory.newIndexSchemaFactory(solrConfig);
String configSet = cd.getConfigSet();
diff --git a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java
index 1108065a2fb..4eb26b2125c 100644
--- a/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java
@@ -1042,7 +1042,7 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
final String prefix = configPathInZk + "/";
final int prefixLen = prefix.length();
Set<String> stripPrefix = files.stream().map(f -> f.startsWith(prefix) ? f.substring(prefixLen) : f).collect(Collectors.toSet());
- stripPrefix.remove(DEFAULT_MANAGED_SCHEMA_RESOURCE_NAME);
+ stripPrefix.remove(schema.getResourceName());
stripPrefix.remove("lang");
stripPrefix.remove(CONFIGOVERLAY_JSON); // treat this file as private
diff --git a/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java b/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java
index 75bdd3a7fa5..7c3e670f13b 100644
--- a/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java
+++ b/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchemaFactory.java
@@ -20,6 +20,9 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import org.apache.commons.io.IOUtils;
import org.apache.solr.cloud.ZkController;
@@ -34,6 +37,7 @@ import org.apache.solr.core.ConfigSetService;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrResourceLoader;
+import org.apache.solr.core.SolrResourceNotFoundException;
import org.apache.solr.util.SystemIdResolver;
import org.apache.solr.util.plugin.SolrCoreAware;
import org.apache.zookeeper.CreateMode;
@@ -49,7 +53,8 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
public 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 DEFAULT_MANAGED_SCHEMA_RESOURCE_NAME = "managed-schema.xml";
+ public static final String LEGACY_MANAGED_SCHEMA_RESOURCE_NAME = "managed-schema";
public static final String MANAGED_SCHEMA_RESOURCE_NAME = "managedSchemaResourceName";
private boolean isMutable = true;
@@ -79,7 +84,6 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
log.error(msg);
throw new SolrException(ErrorCode.SERVER_ERROR, msg);
}
-
if (args.size() > 0) {
String msg = "Unexpected arg(s): " + args;
log.error(msg);
@@ -92,6 +96,65 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
return managedSchemaResourceName; // actually a guess; reality depends on the actual files in the config set :-(
}
+ /**
+ * Lookup the path to the managed schema, dealing with falling back to the
+ * legacy managed-schema file, instead of the expected managed-schema.xml file if the legacy file exists.
+ *
+ * This method is duplicated in ManagedIndexSchema.
+ */
+ public String lookupZKManagedSchemaPath() {
+ final ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader;
+ final ZkController zkController = zkLoader.getZkController();
+ final SolrZkClient zkClient = zkController.getZkClient();
+ String managedSchemaPath = zkLoader.getConfigSetZkPath() + "/" + managedSchemaResourceName;
+ final String legacyManagedSchemaPath = zkLoader.getConfigSetZkPath() + "/" + ManagedIndexSchemaFactory.LEGACY_MANAGED_SCHEMA_RESOURCE_NAME;
+ try {
+ // check if we are using the legacy managed-schema file name.
+ if (zkClient.exists(legacyManagedSchemaPath, true)){
+ log.debug("Legacy managed schema resource {} found - loading legacy managed schema instead of {} file."
+ , ManagedIndexSchemaFactory.LEGACY_MANAGED_SCHEMA_RESOURCE_NAME, managedSchemaResourceName);
+ managedSchemaPath = legacyManagedSchemaPath;
+ }
+ } catch (KeeperException e) {
+ throw new RuntimeException(e);
+ } catch (InterruptedException e) {
+ // Restore the interrupted status
+ Thread.currentThread().interrupt();
+ throw new RuntimeException(e);
+
+ }
+ return managedSchemaPath;
+ }
+
+ /**
+ * Lookup the path to the managed schema, dealing with falling back to the
+ * legacy managed-schema file, instead of the expected managed-schema.xml file if the legacy file exists.
+ */
+ public Path lookupLocalManagedSchemaPath() {
+ final Path legacyManagedSchemaPath = Paths.get(loader.getConfigPath().toString(), ManagedIndexSchemaFactory.LEGACY_MANAGED_SCHEMA_RESOURCE_NAME);
+
+ Path managedSchemaPath = Paths.get(loader.getConfigPath().toString(), managedSchemaResourceName);
+
+ // check if we are using the legacy managed-schema file name.
+ if (Files.exists(legacyManagedSchemaPath)){
+ log.debug("Legacy managed schema resource {} found - loading legacy managed schema instead of {} file.", ManagedIndexSchemaFactory.LEGACY_MANAGED_SCHEMA_RESOURCE_NAME, managedSchemaResourceName);
+ managedSchemaPath = legacyManagedSchemaPath;
+ }
+
+ Path parentPath = managedSchemaPath.getParent();
+ if (!Files.isDirectory(parentPath)) {
+ try {
+ Files.createDirectories(parentPath);
+ }
+ catch (IOException ioe) {
+ final String msg = "Can't create managed schema directory " + parentPath;
+ log.error(msg);
+ throw new SolrException(ErrorCode.SERVER_ERROR, msg);
+ }
+ }
+
+ return managedSchemaPath;
+ }
/**
* First, try to locate the managed schema file named in the managedSchemaResourceName
* param. If the managed schema file exists and is accessible, it is used to instantiate
@@ -102,7 +165,7 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
*
* Once the IndexSchema is instantiated, if the managed schema file does not exist,
* the instantiated IndexSchema is persisted to the managed schema file named in the
- * managedSchemaResourceName param, in the directory given by
+ * managedSchemaResourceName param, in the directory given by
* {@link org.apache.solr.core.SolrResourceLoader#getConfigDir()}, or if configs are
* in ZooKeeper, under {@link org.apache.solr.cloud.ZkSolrResourceLoader#getConfigSetZkPath()}.
*
@@ -126,7 +189,8 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
} else { // ZooKeeper
final ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)loader;
final SolrZkClient zkClient = zkLoader.getZkController().getZkClient();
- final String managedSchemaPath = zkLoader.getConfigSetZkPath() + "/" + managedSchemaResourceName;
+ final String managedSchemaPath = lookupZKManagedSchemaPath();
+ managedSchemaResourceName = managedSchemaPath.substring(managedSchemaPath.lastIndexOf("/")+1); // not loving this
Stat stat = new Stat();
try {
// Attempt to load the managed schema
@@ -153,7 +217,7 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
schemaInputStream = loader.openResource(resourceName);
loadedResource = resourceName;
shouldUpgrade = true;
- } catch (Exception e) {
+ } catch (IOException 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);
@@ -195,6 +259,8 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
InputStream schemaInputStream = null;
try {
// Attempt to load the managed schema
+ final Path managedSchemaPath = lookupLocalManagedSchemaPath();
+ managedSchemaResourceName = managedSchemaPath.getName(managedSchemaPath.getNameCount()-1).toString();
schemaInputStream = loader.openResource(managedSchemaResourceName);
loadedResource = managedSchemaResourceName;
warnIfNonManagedSchemaExists();
@@ -219,7 +285,7 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
}
/**
- * Return whether a non-managed schema exists, either in local storage or on ZooKeeper.
+ * Return whether a non-managed schema exists, either in local storage or on ZooKeeper.
*/
private void warnIfNonManagedSchemaExists() {
if ( ! resourceName.equals(managedSchemaResourceName)) {
@@ -232,7 +298,7 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
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
+ 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);
@@ -244,7 +310,10 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
if (null != nonManagedSchemaInputStream) {
exists = true;
}
- } catch (IOException e) {
+ } catch (SolrResourceNotFoundException e) {
+ // This is expected when the non-managed schema does not exist
+ } catch (IOException e) {
+ throw new RuntimeException(e);
// This is expected when the non-managed schema does not exist
} finally {
IOUtils.closeQuietly(nonManagedSchemaInputStream);
@@ -258,7 +327,7 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
}
/**
- * Persist the managed schema and rename the non-managed schema
+ * Persist the managed schema and rename the non-managed schema
* by appending {@link #UPGRADED_SCHEMA_EXTENSION}.
*
* Failure to rename the non-managed schema will be logged as a warning,
@@ -290,7 +359,7 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
} else {
File upgradedSchemaFile = new File(nonManagedSchemaFile + UPGRADED_SCHEMA_EXTENSION);
if (nonManagedSchemaFile.renameTo(upgradedSchemaFile)) {
- // Set the resource name to the managed schema so that the CoreAdminHandler returns a findable filename
+ // Set the resource name to the managed schema so that the CoreAdminHandler returns a findable filename
schema.setResourceName(managedSchemaResourceName);
log.info("After upgrading to managed schema, renamed the non-managed schema {} to {}"
@@ -320,7 +389,7 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
}
/**
- * Persist the managed schema to ZooKeeper and rename the non-managed schema
+ * Persist the managed schema to ZooKeeper and rename the non-managed schema
* by appending {@link #UPGRADED_SCHEMA_EXTENSION}.
*
* Failure to rename the non-managed schema will be logged as a warning,
@@ -434,7 +503,7 @@ public class ManagedIndexSchemaFactory extends IndexSchemaFactory implements Sol
this.schema = schema;
core.setLatestSchema(schema);
}
-
+
public boolean isMutable() {
return isMutable;
}
diff --git a/solr/core/src/java/org/apache/solr/schema/SchemaManager.java b/solr/core/src/java/org/apache/solr/schema/SchemaManager.java
index cc9e1503a85..03bdde24fe0 100644
--- a/solr/core/src/java/org/apache/solr/schema/SchemaManager.java
+++ b/solr/core/src/java/org/apache/solr/schema/SchemaManager.java
@@ -427,31 +427,33 @@ public class SchemaManager {
KeeperException, InterruptedException {
SolrResourceLoader resourceLoader = core.getResourceLoader();
- String name = core.getLatestSchema().getResourceName();
+ String schemaResourceName = core.getLatestSchema().getResourceName();
if (resourceLoader instanceof ZkSolrResourceLoader) {
final ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader)resourceLoader;
SolrZkClient zkClient = zkLoader.getZkController().getZkClient();
+ String managedSchemaPath = zkLoader.getConfigSetZkPath() + "/" + schemaResourceName;
try {
- if (!zkClient.exists(zkLoader.getConfigSetZkPath() + "/" + name, true)) {
- String backupName = name + ManagedIndexSchemaFactory.UPGRADED_SCHEMA_EXTENSION;
+ if (!zkClient.exists(managedSchemaPath, true)) {
+ String backupName = schemaResourceName + ManagedIndexSchemaFactory.UPGRADED_SCHEMA_EXTENSION;
if (!zkClient.exists(zkLoader.getConfigSetZkPath() + "/" + backupName, true)) {
- log.warn("Unable to retrieve fresh managed schema, neither {} nor {} exist.", name, backupName);
+ log.warn("Unable to retrieve fresh managed schema, neither {} nor {} exist.", schemaResourceName, backupName);
// use current schema
return (ManagedIndexSchema) core.getLatestSchema();
} else {
- name = backupName;
+ schemaResourceName = backupName;
}
}
} catch (Exception e) {
- log.warn("Unable to retrieve fresh managed schema {}", name, e);
+ log.warn("Unable to retrieve fresh managed schema {}", schemaResourceName, e);
// use current schema
return (ManagedIndexSchema) core.getLatestSchema();
}
- InputStream in = resourceLoader.openResource(name);
+ schemaResourceName = managedSchemaPath.substring(managedSchemaPath.lastIndexOf("/")+1);
+ InputStream in = resourceLoader.openResource(schemaResourceName);
if (in instanceof ZkSolrResourceLoader.ZkByteArrayInputStream) {
int version = ((ZkSolrResourceLoader.ZkByteArrayInputStream) in).getStat().getVersion();
log.info("managed schema loaded . version : {} ", version);
- return new ManagedIndexSchema(core.getSolrConfig(), name, () -> IndexSchemaFactory.getParsedSchema(in, zkLoader, core.getLatestSchema().getResourceName()), true, name, version,
+ return new ManagedIndexSchema(core.getSolrConfig(), schemaResourceName, () -> IndexSchemaFactory.getParsedSchema(in, zkLoader, core.getLatestSchema().getResourceName()), true, schemaResourceName, version,
core.getLatestSchema().getSchemaUpdateLock());
} else {
return (ManagedIndexSchema) core.getLatestSchema();
diff --git a/solr/core/src/java/org/apache/solr/schema/ZkIndexSchemaReader.java b/solr/core/src/java/org/apache/solr/schema/ZkIndexSchemaReader.java
index e20a62c3362..3a4ba52d929 100644
--- a/solr/core/src/java/org/apache/solr/schema/ZkIndexSchemaReader.java
+++ b/solr/core/src/java/org/apache/solr/schema/ZkIndexSchemaReader.java
@@ -48,8 +48,8 @@ public class ZkIndexSchemaReader implements OnReconnect {
this.managedIndexSchemaFactory = managedIndexSchemaFactory;
zkLoader = (ZkSolrResourceLoader)managedIndexSchemaFactory.getResourceLoader();
this.zkClient = zkLoader.getZkController().getZkClient();
- this.managedSchemaPath = zkLoader.getConfigSetZkPath() + "/" + managedIndexSchemaFactory.getManagedSchemaResourceName();
- this.uniqueCoreId = solrCore.getName()+":"+solrCore.getStartNanoTime();
+ this.managedSchemaPath = managedIndexSchemaFactory.lookupZKManagedSchemaPath();
+ this.uniqueCoreId = solrCore.getName() + ":" + solrCore.getStartNanoTime();
// register a CloseHook for the core this reader is linked to, so that we can de-register the listener
solrCore.addCloseHook(new CloseHook() {
@@ -172,10 +172,10 @@ public class ZkIndexSchemaReader implements OnReconnect {
}
long start = System.nanoTime();
String resourceName = managedIndexSchemaFactory.getManagedSchemaResourceName();
- ManagedIndexSchema newSchema = new ManagedIndexSchema
- (managedIndexSchemaFactory.getConfig(), resourceName,
- () -> IndexSchemaFactory.getParsedSchema(new ByteArrayInputStream(data),zkLoader , resourceName), managedIndexSchemaFactory.isMutable(),
- resourceName, stat.getVersion(), oldSchema.getSchemaUpdateLock());
+ ManagedIndexSchema newSchema = new ManagedIndexSchema(managedIndexSchemaFactory.getConfig(), resourceName,
+ () -> IndexSchemaFactory.getParsedSchema(new ByteArrayInputStream(data), zkLoader, resourceName),
+ managedIndexSchemaFactory.isMutable(),
+ resourceName, stat.getVersion(), oldSchema.getSchemaUpdateLock());
managedIndexSchemaFactory.setSchema(newSchema);
long stop = System.nanoTime();
log.info("Finished refreshing schema in {} ms", TimeUnit.MILLISECONDS.convert(stop - start, TimeUnit.NANOSECONDS));
@@ -198,7 +198,7 @@ public class ZkIndexSchemaReader implements OnReconnect {
// force update now as the schema may have changed while our zk session was expired
updateSchema(null, -1);
} catch (Exception exc) {
- log.error("Failed to update managed-schema watcher after session expiration due to: {}", exc);
+ log.error("Failed to update managed schema watcher after session expiration due to: {}", exc);
}
}
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-managed-schema.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-managed-schema.xml
index 46158cd77cf..e00b0c10de8 100644
--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-managed-schema.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-managed-schema.xml
@@ -24,7 +24,7 @@
<schemaFactory class="ManagedIndexSchemaFactory">
<bool name="mutable">${managed.schema.mutable}</bool>
- <str name="managedSchemaResourceName">${managed.schema.resourceName:managed-schema}</str>
+ <str name="managedSchemaResourceName">${managed.schema.resourceName:managed-schema.xml}</str>
</schemaFactory>
<codecFactory class="solr.SchemaCodecFactory"/>
diff --git a/solr/core/src/test-files/solr/configsets/upload/regular/managed-schema b/solr/core/src/test-files/solr/configsets/upload/legacy-managed-schema/managed-schema
similarity index 100%
rename from solr/core/src/test-files/solr/configsets/upload/regular/managed-schema
rename to solr/core/src/test-files/solr/configsets/upload/legacy-managed-schema/managed-schema
diff --git a/solr/core/src/test-files/solr/configsets/upload/legacy-managed-schema/solrconfig.xml b/solr/core/src/test-files/solr/configsets/upload/legacy-managed-schema/solrconfig.xml
new file mode 100644
index 00000000000..827b5bd7253
--- /dev/null
+++ b/solr/core/src/test-files/solr/configsets/upload/legacy-managed-schema/solrconfig.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" ?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- This is a "kitchen sink" config file that tests can use.
+ When writting a new test, feel free to add *new* items (plugins,
+ config options, etc...) as long as they don't break any existing
+ tests. if you need to test something esoteric please add a new
+ "solrconfig-your-esoteric-purpose.xml" config file.
+
+ Note in particular that this test is used by MinimalSchemaTest so
+ Anything added to this file needs to work correctly even if there
+ is now uniqueKey or defaultSearch Field.
+ -->
+
+<config>
+
+ <dataDir>${solr.data.dir:}</dataDir>
+
+ <directoryFactory name="DirectoryFactory"
+ class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/>
+
+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+
+ <updateHandler class="solr.DirectUpdateHandler2">
+ <commitWithin>
+ <softCommit>${solr.commitwithin.softcommit:true}</softCommit>
+ </commitWithin>
+
+ </updateHandler>
+ <requestHandler name="/select" class="solr.SearchHandler">
+ <lst name="defaults">
+ <str name="echoParams">explicit</str>
+ <str name="indent">true</str>
+ <str name="df">text</str>
+ </lst>
+
+ </requestHandler>
+
+ <requestHandler name="/update/xslt"
+ startup="lazy"
+ class="solr.XsltUpdateRequestHandler"/>
+
+ <requestHandler name="/update" class="solr.UpdateRequestHandler" />
+</config>
diff --git a/solr/core/src/test-files/solr/configsets/upload/with-lib-directive/managed-schema b/solr/core/src/test-files/solr/configsets/upload/regular/managed-schema.xml
similarity index 100%
rename from solr/core/src/test-files/solr/configsets/upload/with-lib-directive/managed-schema
rename to solr/core/src/test-files/solr/configsets/upload/regular/managed-schema.xml
diff --git a/solr/core/src/test-files/solr/configsets/upload/with-script-processor/managed-schema b/solr/core/src/test-files/solr/configsets/upload/with-lib-directive/managed-schema.xml
similarity index 100%
rename from solr/core/src/test-files/solr/configsets/upload/with-script-processor/managed-schema
rename to solr/core/src/test-files/solr/configsets/upload/with-lib-directive/managed-schema.xml
diff --git a/solr/core/src/test-files/solr/configsets/upload/with-script-processor/managed-schema.xml b/solr/core/src/test-files/solr/configsets/upload/with-script-processor/managed-schema.xml
new file mode 100644
index 00000000000..9e2f9471026
--- /dev/null
+++ b/solr/core/src/test-files/solr/configsets/upload/with-script-processor/managed-schema.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<schema name="minimal" version="1.1">
+ <types>
+ <fieldType name="string" class="solr.StrField"/>
+ </types>
+ <fields>
+ <dynamicField name="*" type="string" indexed="true" stored="true" />
+ </fields>
+</schema>
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
index d5550800aa6..532b2fd28a3 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
@@ -32,6 +32,7 @@ import java.io.OutputStream;
import java.lang.invoke.MethodHandles;
import java.net.URI;
import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
import java.security.Principal;
import java.util.Arrays;
import java.util.Collection;
@@ -403,6 +404,42 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
}
}
+ public void testUploadLegacyManagedSchemaFile() throws Exception {
+ String configSetName = "legacy-managed-schema";
+ SolrZkClient zkClient = new SolrZkClient(cluster.getZkServer().getZkAddress(),
+ AbstractZkTestCase.TIMEOUT, 45000, null);
+ try {
+ long statusCode = uploadConfigSet(configSetName, "", null, zkClient, true);
+ assertEquals(0l, statusCode);
+
+ assertTrue("managed-schema file should have been uploaded",
+ zkClient.exists("/configs/"+configSetName+"/managed-schema", true));
+ } finally {
+ zkClient.close();
+ }
+
+ // try to create a collection with the uploaded configset
+ createCollection("newcollection", configSetName, 1, 1, cluster.getSolrClient());
+
+ String payload = "{\n" +
+ " 'add-field' : {\n" +
+ " 'name':'a1',\n" +
+ " 'type': 'string',\n" +
+ " 'stored':true,\n" +
+ " 'indexed':false\n" +
+ " },\n" +
+ " }";
+
+ ByteBuffer buff = Charset.forName("UTF-8").encode(payload);
+ Map<?, ?> map = postDataAndGetResponse(cluster.getSolrClient(),
+ cluster.getJettySolrRunners().get(0).getBaseUrl().toString()
+ + "/newcollection/schema?wt=js" +
+ "on", buff, null, false);
+ Map<?, ?> responseHeader = (Map<?, ?>)map.get("responseHeader");
+ Long status = (Long)responseHeader.get("status");
+ assertEquals((long)status, 0L);
+ }
+
@Test
public void testOverwriteV1() throws Exception {
testOverwrite(false);
@@ -829,7 +866,7 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
// try to create a collection with the uploaded configset
CollectionAdminResponse resp = createCollection("newcollection3", "with-lib-directive" + trustedSuffix,
1, 1, cluster.getSolrClient());
-
+
SolrInputDocument doc = sdoc("id", "4055", "subject", "Solr");
cluster.getSolrClient().add("newcollection3", doc);
cluster.getSolrClient().commit("newcollection3");
@@ -858,11 +895,11 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
}
}
private void assertConfigsetFiles(String configSetName, String suffix, SolrZkClient zkClient) throws KeeperException, InterruptedException, IOException {
- assertTrue("managed-schema file should have been uploaded",
- zkClient.exists("/configs/"+configSetName+suffix+"/managed-schema", true));
- assertTrue("managed-schema file contents on zookeeper are not exactly same as that of the file uploaded in config",
- Arrays.equals(zkClient.getData("/configs/"+configSetName+suffix+"/managed-schema", null, null, true),
- readFile("solr/configsets/upload/"+configSetName+"/managed-schema")));
+ assertTrue("managed-schema.xml file should have been uploaded",
+ zkClient.exists("/configs/"+configSetName+suffix+"/managed-schema.xml", true));
+ assertTrue("managed-schema.xml file contents on zookeeper are not exactly same as that of the file uploaded in config",
+ Arrays.equals(zkClient.getData("/configs/"+configSetName+suffix+"/managed-schema.xml", null, null, true),
+ readFile("solr/configsets/upload/"+configSetName+"/managed-schema.xml")));
assertTrue("solrconfig.xml file should have been uploaded",
zkClient.exists("/configs/"+configSetName+suffix+"/solrconfig.xml", true));
@@ -1001,7 +1038,7 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
zout.close();
}
}
-
+
public void scriptRequest(String collection) throws SolrServerException, IOException {
SolrClient client = cluster.getSolrClient();
SolrInputDocument doc = sdoc("id", "4055", "subject", "Solr");
@@ -1026,21 +1063,21 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
res.setResponse(client.request(request));
return res;
}
-
+
public static Map<?, ?> postDataAndGetResponse(CloudSolrClient cloudClient,
String uri, ByteBuffer bytarr, String username, boolean usePut) throws IOException {
HttpEntityEnclosingRequestBase httpRequest = null;
HttpEntity entity;
String response = null;
Map<?, ?> m = null;
-
+
try {
if (usePut) {
httpRequest = new HttpPut(uri);
} else {
httpRequest = new HttpPost(uri);
}
-
+
if (username != null) {
httpRequest.addHeader(new BasicHeader("user", username));
}
@@ -1093,7 +1130,7 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
}
return buf;
}
-
+
@Test
public void testDeleteErrors() throws Exception {
final String baseUrl = cluster.getJettySolrRunners().get(0).getBaseUrl().toString();
@@ -1188,15 +1225,15 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
}
/**
- * A simple sanity check that the test-framework hueristic logic for setting
- * {@link ExternalPaths#DEFAULT_CONFIGSET} is working as it should
+ * A simple sanity check that the test-framework hueristic logic for setting
+ * {@link ExternalPaths#DEFAULT_CONFIGSET} is working as it should
* in the current test env, and finding the real directory which matches what {@link ZkController}
* finds and uses to bootstrap ZK in cloud based tests.
*
* <p>
- * This assumes the {@link SolrDispatchFilter#SOLR_DEFAULT_CONFDIR_ATTRIBUTE} system property
- * has not been externally set in the environment where this test is being run -- which should
- * <b>never</b> be the case, since it would prevent the test-framework from using
+ * This assumes the {@link SolrDispatchFilter#SOLR_DEFAULT_CONFDIR_ATTRIBUTE} system property
+ * has not been externally set in the environment where this test is being run -- which should
+ * <b>never</b> be the case, since it would prevent the test-framework from using
* {@link ExternalPaths#DEFAULT_CONFIGSET}
*
* @see SolrDispatchFilter#SOLR_DEFAULT_CONFDIR_ATTRIBUTE
@@ -1208,7 +1245,7 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
final File extPath = new File(ExternalPaths.DEFAULT_CONFIGSET);
assertTrue("_default dir doesn't exist: " + ExternalPaths.DEFAULT_CONFIGSET, extPath.exists());
assertTrue("_default dir isn't a dir: " + ExternalPaths.DEFAULT_CONFIGSET, extPath.isDirectory());
-
+
final String zkBootStrap = ConfigSetService.getDefaultConfigDirPath();
assertEquals("extPath _default configset dir vs zk bootstrap path",
ExternalPaths.DEFAULT_CONFIGSET, zkBootStrap);
diff --git a/solr/core/src/test/org/apache/solr/schema/SpatialRPTFieldTypeTest.java b/solr/core/src/test/org/apache/solr/schema/SpatialRPTFieldTypeTest.java
index 8eade38a943..02e6d20861b 100644
--- a/solr/core/src/test/org/apache/solr/schema/SpatialRPTFieldTypeTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/SpatialRPTFieldTypeTest.java
@@ -28,13 +28,13 @@ import org.junit.Before;
import org.locationtech.spatial4j.shape.Shape;
public class SpatialRPTFieldTypeTest extends AbstractBadConfigTestBase {
-
+
private static File tmpSolrHome;
private static File tmpConfDir;
-
+
private static final String collection = "collection1";
private static final String confDir = collection + "/conf";
-
+
@Before
private void initManagedSchemaCore() throws Exception {
tmpSolrHome = createTempDir().toFile();
@@ -48,14 +48,14 @@ public class SpatialRPTFieldTypeTest extends AbstractBadConfigTestBase {
FileUtils.copyFileToDirectory(new File(testHomeConfDir, "schema-minimal.xml"), tmpConfDir);
FileUtils.copyFileToDirectory(new File(testHomeConfDir, "schema_codec.xml"), tmpConfDir);
FileUtils.copyFileToDirectory(new File(testHomeConfDir, "schema-bm25.xml"), tmpConfDir);
-
+
// initCore will trigger an upgrade to managed schema, since the solrconfig has
// <schemaFactory class="ManagedIndexSchemaFactory" ... />
System.setProperty("managed.schema.mutable", "false");
System.setProperty("enable.update.log", "false");
initCore("solrconfig-managed-schema.xml", "schema-minimal.xml", tmpSolrHome.getPath());
}
-
+
@After
private void afterClass() throws Exception {
deleteCore();
@@ -68,47 +68,47 @@ public class SpatialRPTFieldTypeTest extends AbstractBadConfigTestBase {
static final String DISTANCE_DEGREES = "1.3520328";
static final String DISTANCE_KILOMETERS = "150.33939";
static final String DISTANCE_MILES = "93.416565";
-
+
public void testDistanceUnitsDegrees() throws Exception {
setupRPTField("degrees", "true");
-
+
assertU(adoc("str", "X", "geo", INDEXED_COORDINATES));
assertU(commit());
String q;
-
+
q = "geo:{!geofilt score=distance filter=false sfield=geo pt="+QUERY_COORDINATES+" d=180}";
assertQ(req("q", q, "fl", "*,score"), "//result/doc/float[@name='score'][.='"+DISTANCE_DEGREES+"']");
-
+
q = "geo:{!geofilt score=degrees filter=false sfield=geo pt="+QUERY_COORDINATES+" d=180}";
assertQ(req("q", q, "fl", "*,score"), "//result/doc/float[@name='score'][.='"+DISTANCE_DEGREES+"']");
-
+
q = "geo:{!geofilt score=kilometers filter=false sfield=geo pt="+QUERY_COORDINATES+" d=180}";
assertQ(req("q", q, "fl", "*,score"), "//result/doc/float[@name='score'][.='"+DISTANCE_KILOMETERS+"']");
-
+
q = "geo:{!geofilt score=miles filter=false sfield=geo pt="+QUERY_COORDINATES+" d=180}";
assertQ(req("q", q, "fl", "*,score"), "//result/doc/float[@name='score'][.='"+DISTANCE_MILES+"']");
}
-
+
public void testDistanceUnitsKilometers() throws Exception {
setupRPTField("kilometers", "true");
-
+
assertU(adoc("str", "X", "geo", INDEXED_COORDINATES));
assertU(commit());
String q;
-
+
q = "geo:{!geofilt score=distance filter=false sfield=geo pt="+QUERY_COORDINATES+" d=1000}";
assertQ(req("q", q, "fl", "*,score"), "//result/doc/float[@name='score'][.='"+DISTANCE_KILOMETERS+"']");
-
+
q = "geo:{!geofilt score=degrees filter=false sfield=geo pt="+QUERY_COORDINATES+" d=1000}";
assertQ(req("q", q, "fl", "*,score"), "//result/doc/float[@name='score'][.='"+DISTANCE_DEGREES+"']");
-
+
q = "geo:{!geofilt score=kilometers filter=false sfield=geo pt="+QUERY_COORDINATES+" d=1000}";
assertQ(req("q", q, "fl", "*,score"), "//result/doc/float[@name='score'][.='"+DISTANCE_KILOMETERS+"']");
-
+
q = "geo:{!geofilt score=miles filter=false sfield=geo pt="+QUERY_COORDINATES+" d=1000}";
assertQ(req("q", q, "fl", "*,score"), "//result/doc/float[@name='score'][.='"+DISTANCE_MILES+"']");
}
-
+
public void testJunkValuesForDistanceUnits() throws Exception {
Exception ex = expectThrows(Exception.class, () -> setupRPTField("rose", "true"));
assertTrue(ex.getMessage().startsWith("Must specify distanceUnits as one of"));
@@ -116,17 +116,17 @@ public class SpatialRPTFieldTypeTest extends AbstractBadConfigTestBase {
public void testMaxDistErrConversion() throws Exception {
deleteCore();
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
- Files.delete(managedSchemaFile.toPath()); // Delete managed-schema so it won't block parsing a new schema
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
+ Files.delete(managedSchemaFile.toPath()); // Delete managed-schema.xml so it won't block parsing a new schema
System.setProperty("managed.schema.mutable", "true");
initCore("solrconfig-managed-schema.xml", "schema-one-field-no-dynamic-field.xml", tmpSolrHome.getPath());
-
+
String fieldName = "new_text_field";
assertNull("Field '" + fieldName + "' is present in the schema",
h.getCore().getLatestSchema().getFieldOrNull(fieldName));
-
+
IndexSchema oldSchema = h.getCore().getLatestSchema();
-
+
SpatialRecursivePrefixTreeFieldType rptFieldType = new SpatialRecursivePrefixTreeFieldType();
Map<String, String> rptMap = new HashMap<String,String>();
@@ -232,15 +232,15 @@ public class SpatialRPTFieldTypeTest extends AbstractBadConfigTestBase {
private void setupRPTField(String distanceUnits, String geo, String format, FieldType fieldType) throws Exception {
deleteCore();
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
- Files.delete(managedSchemaFile.toPath()); // Delete managed-schema so it won't block parsing a new schema
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
+ Files.delete(managedSchemaFile.toPath()); // Delete managed-schema.xml so it won't block parsing a new schema
System.setProperty("managed.schema.mutable", "true");
initCore("solrconfig-managed-schema.xml", "schema-one-field-no-dynamic-field.xml", tmpSolrHome.getPath());
String fieldName = "new_text_field";
assertNull("Field '" + fieldName + "' is present in the schema",
h.getCore().getLatestSchema().getFieldOrNull(fieldName));
-
+
IndexSchema oldSchema = h.getCore().getLatestSchema();
if (fieldType == null) {
diff --git a/solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchema.java b/solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchema.java
index 652063b9988..54c679d096a 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchema.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchema.java
@@ -65,12 +65,12 @@ public class TestCloudManagedSchema extends AbstractFullDistribZkTestBase {
NamedList<?> collectionStatus = (NamedList<?>)status.getVal(0);
String collectionSchema = (String)collectionStatus.get(CoreAdminParams.SCHEMA);
// Make sure the upgrade to managed schema happened
- assertEquals("Schema resource name differs from expected name", "managed-schema", collectionSchema);
+ assertEquals("Schema resource name differs from expected name", "managed-schema.xml", collectionSchema);
SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), 30000);
try {
// Make sure "DO NOT EDIT" is in the content of the managed schema
- String fileContent = getFileContentFromZooKeeper(zkClient, "/solr/configs/conf1/managed-schema");
+ String fileContent = getFileContentFromZooKeeper(zkClient, "/solr/configs/conf1/managed-schema.xml");
assertTrue("Managed schema is missing", fileContent.contains("DO NOT EDIT"));
// Make sure the original non-managed schema is no longer in ZooKeeper
diff --git a/solr/core/src/test/org/apache/solr/schema/TestManagedSchema.java b/solr/core/src/test/org/apache/solr/schema/TestManagedSchema.java
index d209f9d9edb..42a5a79a321 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestManagedSchema.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestManagedSchema.java
@@ -48,7 +48,7 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
private static final String collection = "collection1";
private static final String confDir = collection + "/conf";
-
+
@Before
private void initManagedSchemaCore() throws Exception {
tmpSolrHome = createTempDir().toFile();
@@ -64,6 +64,7 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
FileUtils.copyFileToDirectory(new File(testHomeConfDir, "schema_codec.xml"), tmpConfDir);
FileUtils.copyFileToDirectory(new File(testHomeConfDir, "schema-bm25.xml"), tmpConfDir);
+
// initCore will trigger an upgrade to managed schema, since the solrconfig has
// <schemaFactory class="ManagedIndexSchemaFactory" ... />
System.setProperty("managed.schema.mutable", "false");
@@ -77,30 +78,30 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
System.clearProperty("managed.schema.mutable");
System.clearProperty("enable.update.log");
}
-
+
public void testUpgrade() throws Exception {
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
assertTrue(managedSchemaFile.exists());
String managedSchema = FileUtils.readFileToString(managedSchemaFile, "UTF-8");
assertTrue(managedSchema.contains("DO NOT EDIT"));
File upgradedOriginalSchemaFile = new File(tmpConfDir, "schema-minimal.xml.bak");
assertTrue(upgradedOriginalSchemaFile.exists());
- assertSchemaResource(collection, "managed-schema");
+ assertSchemaResource(collection, "managed-schema.xml");
}
-
+
public void testUpgradeThenRestart() throws Exception {
- assertSchemaResource(collection, "managed-schema");
+ assertSchemaResource(collection, "managed-schema.xml");
deleteCore();
File nonManagedSchemaFile = new File(tmpConfDir, "schema-minimal.xml");
assertFalse(nonManagedSchemaFile.exists());
initCore("solrconfig-managed-schema.xml", "schema-minimal.xml", tmpSolrHome.getPath());
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
assertTrue(managedSchemaFile.exists());
String managedSchema = FileUtils.readFileToString(managedSchemaFile, "UTF-8");
assertTrue(managedSchema.contains("DO NOT EDIT"));
File upgradedOriginalSchemaFile = new File(tmpConfDir, "schema-minimal.xml.bak");
assertTrue(upgradedOriginalSchemaFile.exists());
- assertSchemaResource(collection, "managed-schema");
+ assertSchemaResource(collection, "managed-schema.xml");
}
public void testUpgradeThenRestartNonManaged() throws Exception {
@@ -112,13 +113,13 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
}
public void testUpgradeThenRestartNonManagedAfterPuttingBackNonManagedSchema() throws Exception {
- assertSchemaResource(collection, "managed-schema");
+ assertSchemaResource(collection, "managed-schema.xml");
deleteCore();
File nonManagedSchemaFile = new File(tmpConfDir, "schema-minimal.xml");
assertFalse(nonManagedSchemaFile.exists());
File upgradedOriginalSchemaFile = new File(tmpConfDir, "schema-minimal.xml.bak");
assertTrue(upgradedOriginalSchemaFile.exists());
-
+
// After upgrade to managed schema, downgrading to non-managed should work after putting back the non-managed schema.
FileUtils.moveFile(upgradedOriginalSchemaFile, nonManagedSchemaFile);
initCore("solrconfig-basic.xml", "schema-minimal.xml", tmpSolrHome.getPath());
@@ -135,9 +136,9 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
SolrQueryResponse response = new SolrQueryResponse();
admin.handleRequestBody(request, response);
assertNull("Exception on create", response.getException());
- assertSchemaResource(collection, "managed-schema");
+ assertSchemaResource(collection, "managed-schema.xml");
}
-
+
private void assertSchemaResource(String collection, String expectedSchemaResource) throws Exception {
final CoreContainer cores = h.getCoreContainer();
final CoreAdminHandler admin = new CoreAdminHandler(cores);
@@ -153,7 +154,7 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
}
public void testAddFieldWhenNotMutable() throws Exception {
- assertSchemaResource(collection, "managed-schema");
+ assertSchemaResource(collection, "managed-schema.xml");
String errString = "This ManagedIndexSchema is not mutable.";
ignoreException(Pattern.quote(errString));
try {
@@ -177,20 +178,20 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
resetExceptionIgnores();
}
}
-
+
public void testAddFieldPersistence() throws Exception {
- assertSchemaResource(collection, "managed-schema");
+ assertSchemaResource(collection, "managed-schema.xml");
deleteCore();
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
- Files.delete(managedSchemaFile.toPath()); // Delete managed-schema so it won't block parsing a new schema
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
+ Files.delete(managedSchemaFile.toPath()); // Delete managed-schema.xml so it won't block parsing a new schema
System.setProperty("managed.schema.mutable", "true");
initCore("solrconfig-managed-schema.xml", "schema-one-field-no-dynamic-field.xml", tmpSolrHome.getPath());
-
+
assertTrue(managedSchemaFile.exists());
String managedSchemaContents = FileUtils.readFileToString(managedSchemaFile, "UTF-8");
assertFalse(managedSchemaContents.contains("\"new_field\""));
-
+
Map<String,Object> options = new HashMap<>();
options.put("stored", "false");
IndexSchema oldSchema = h.getCore().getLatestSchema();
@@ -206,12 +207,12 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
stream.close(); // Explicitly close so that Windows can delete this file
assertTrue(managedSchemaContents.contains("<field name=\"new_field\" type=\"string\" stored=\"false\"/>"));
}
-
+
public void testAddedFieldIndexableAndQueryable() throws Exception {
- assertSchemaResource(collection, "managed-schema");
+ assertSchemaResource(collection, "managed-schema.xml");
deleteCore();
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
- Files.delete(managedSchemaFile.toPath()); // Delete managed-schema so it won't block parsing a new schema
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
+ Files.delete(managedSchemaFile.toPath()); // Delete managed-schema.xml so it won't block parsing a new schema
System.setProperty("managed.schema.mutable", "true");
initCore("solrconfig-managed-schema.xml", "schema-one-field-no-dynamic-field.xml", tmpSolrHome.getPath());
@@ -254,16 +255,16 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
assertQ(req("new_field:thing1"), "//*[@numFound='1']");
}
-
+
public void testAddFieldWhenItAlreadyExists() throws Exception{
deleteCore();
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
- Files.delete(managedSchemaFile.toPath()); // Delete managed-schema so it won't block parsing a new schema
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
+ Files.delete(managedSchemaFile.toPath()); // Delete managed-schema.xml so it won't block parsing a new schema
System.setProperty("managed.schema.mutable", "true");
initCore("solrconfig-managed-schema.xml", "schema-one-field-no-dynamic-field.xml", tmpSolrHome.getPath());
assertNotNull("Field 'str' is not present in the schema", h.getCore().getLatestSchema().getFieldOrNull("str"));
-
+
String errString = "Field 'str' already exists.";
ignoreException(Pattern.quote(errString));
try {
@@ -290,8 +291,8 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
public void testAddSameFieldTwice() throws Exception{
deleteCore();
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
- Files.delete(managedSchemaFile.toPath()); // Delete managed-schema so it won't block parsing a new schema
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
+ Files.delete(managedSchemaFile.toPath()); // Delete managed-schema.xml so it won't block parsing a new schema
System.setProperty("managed.schema.mutable", "true");
initCore("solrconfig-managed-schema.xml", "schema-one-field-no-dynamic-field.xml", tmpSolrHome.getPath());
@@ -325,8 +326,8 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
public void testAddDynamicField() throws Exception{
deleteCore();
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
- Files.delete(managedSchemaFile.toPath()); // Delete managed-schema so it won't block parsing a new schema
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
+ Files.delete(managedSchemaFile.toPath()); // Delete managed-schema.xml so it won't block parsing a new schema
System.setProperty("managed.schema.mutable", "true");
initCore("solrconfig-managed-schema.xml", "schema-one-field-no-dynamic-field.xml", tmpSolrHome.getPath());
@@ -355,20 +356,20 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
resetExceptionIgnores();
}
}
-
+
public void testAddWithSchemaCodecFactory() throws Exception {
deleteCore();
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
- Files.delete(managedSchemaFile.toPath()); // Delete managed-schema so it won't block parsing a new schema
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
+ Files.delete(managedSchemaFile.toPath()); // Delete managed-schema.xml so it won't block parsing a new schema
System.setProperty("managed.schema.mutable", "true");
initCore("solrconfig-managed-schema.xml", "schema_codec.xml", tmpSolrHome.getPath());
String uniqueKey = "string_f";
- assertNotNull("Unique key field '" + uniqueKey + "' is not present in the schema",
+ assertNotNull("Unique key field '" + uniqueKey + "' is not present in the schema",
h.getCore().getLatestSchema().getFieldOrNull(uniqueKey));
String fieldName = "string_disk_new_field";
- assertNull("Field '" + fieldName + "' is present in the schema",
+ assertNull("Field '" + fieldName + "' is present in the schema",
h.getCore().getLatestSchema().getFieldOrNull(fieldName));
Map<String,Object> options = new HashMap<>();
@@ -386,8 +387,8 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
public void testAddWithSchemaSimilarityFactory() throws Exception {
deleteCore();
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
- Files.delete(managedSchemaFile.toPath()); // Delete managed-schema so it won't block parsing a new schema
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
+ Files.delete(managedSchemaFile.toPath()); // Delete managed-schema.xml so it won't block parsing a new schema
System.setProperty("managed.schema.mutable", "true");
initCore("solrconfig-managed-schema.xml", "schema-bm25.xml", tmpSolrHome.getPath());
@@ -413,10 +414,10 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
}
public void testPersistUniqueKey() throws Exception {
- assertSchemaResource(collection, "managed-schema");
+ assertSchemaResource(collection, "managed-schema.xml");
deleteCore();
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
- Files.delete(managedSchemaFile.toPath()); // Delete managed-schema so it won't block parsing a new schema
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
+ Files.delete(managedSchemaFile.toPath()); // Delete managed-schema.xml so it won't block parsing a new schema
System.setProperty("managed.schema.mutable", "true");
initCore("solrconfig-managed-schema.xml", "schema-one-field-no-dynamic-field-unique-key.xml", tmpSolrHome.getPath());
@@ -451,8 +452,8 @@ public class TestManagedSchema extends AbstractBadConfigTestBase {
public void testAddFieldThenReload() throws Exception {
deleteCore();
- File managedSchemaFile = new File(tmpConfDir, "managed-schema");
- Files.delete(managedSchemaFile.toPath()); // Delete managed-schema so it won't block parsing a new schema
+ File managedSchemaFile = new File(tmpConfDir, "managed-schema.xml");
+ Files.delete(managedSchemaFile.toPath()); // Delete managed-schema.xml so it won't block parsing a new schema
System.setProperty("managed.schema.mutable", "true");
initCore("solrconfig-managed-schema.xml", "schema-one-field-no-dynamic-field.xml", tmpSolrHome.getPath());
diff --git a/solr/server/solr/configsets/_default/conf/managed-schema b/solr/server/solr/configsets/_default/conf/managed-schema.xml
similarity index 97%
rename from solr/server/solr/configsets/_default/conf/managed-schema
rename to solr/server/solr/configsets/_default/conf/managed-schema.xml
index 7d46d789a1f..5be18eb5d80 100644
--- a/solr/server/solr/configsets/_default/conf/managed-schema
+++ b/solr/server/solr/configsets/_default/conf/managed-schema.xml
@@ -40,34 +40,34 @@
<schema name="default-config" version="1.6">
<!-- attribute "name" is the name of this schema and is only used for display purposes.
- version="x.y" is Solr's version number for the schema syntax and
+ version="x.y" is Solr's version number for the schema syntax and
semantics. It should not normally be changed by applications.
- 1.0: multiValued attribute did not exist, all fields are multiValued
+ 1.0: multiValued attribute did not exist, all fields are multiValued
by nature
- 1.1: multiValued attribute introduced, false by default
- 1.2: omitTermFreqAndPositions attribute introduced, true by default
+ 1.1: multiValued attribute introduced, false by default
+ 1.2: omitTermFreqAndPositions attribute introduced, true by default
except for text fields.
1.3: removed optional field compress feature
1.4: autoGeneratePhraseQueries attribute introduced to drive QueryParser
- behavior when a single string produces multiple tokens. Defaults
+ behavior when a single string produces multiple tokens. Defaults
to off for version >= 1.4
- 1.5: omitNorms defaults to true for primitive field types
+ 1.5: omitNorms defaults to true for primitive field types
(int, float, boolean, string...)
1.6: useDocValuesAsStored defaults to true.
-->
<!-- Valid attributes for fields:
name: mandatory - the name for the field
- type: mandatory - the name of a field type from the
+ type: mandatory - the name of a field type from the
fieldTypes section
indexed: true if this field should be indexed (searchable or sortable)
stored: true if this field should be retrievable
docValues: true if this field should have doc values. Doc Values is
recommended (required, if you are using *Point fields) for faceting,
grouping, sorting and function queries. Doc Values will make the index
- faster to load, more NRT-friendly and more memory-efficient.
- They are currently only supported by StrField, UUIDField, all
+ faster to load, more NRT-friendly and more memory-efficient.
+ They are currently only supported by StrField, UUIDField, all
*PointFields, and depending on the field type, they might require
the field to be single-valued, be required or have a default value
(check the documentation of the field type you're interested in for
@@ -82,9 +82,9 @@
given field.
When using MoreLikeThis, fields used for similarity should be
stored for best performance.
- termPositions: Store position information with the term vector.
+ termPositions: Store position information with the term vector.
This will increase storage costs.
- termOffsets: Store offset information with the term vector. This
+ termOffsets: Store offset information with the term vector. This
will increase storage costs.
required: The field is required. It will throw an error if the
value does not exist
@@ -102,10 +102,10 @@
<!-- In this _default configset, only four fields are pre-declared:
id, _version_, and _text_ and _root_. All other fields will be type guessed and added via the
"add-unknown-fields-to-the-schema" update request processor chain declared in solrconfig.xml.
-
- Note that many dynamic fields are also defined - you can use them to specify a
+
+ Note that many dynamic fields are also defined - you can use them to specify a
field's type via field naming conventions - see below.
-
+
WARNING: The _text_ catch-all field will significantly increase your index size.
If you don't need it, consider removing it and the corresponding copyField directive.
-->
@@ -130,7 +130,7 @@
for fields via the specification of patterns to match field names.
EXAMPLE: name="*_i" will match any field ending in _i (like myid_i, z_i)
RESTRICTION: the glob-like pattern in the name attribute must have a "*" only at the start or the end. -->
-
+
<dynamicField name="*_i" type="pint" indexed="true" stored="true"/>
<dynamicField name="*_is" type="pints" indexed="true" stored="true"/>
<dynamicField name="*_s" type="string" indexed="true" stored="true" />
@@ -227,7 +227,7 @@
<!-- The format for this date field is of the form 1995-12-31T23:59:59Z, and
is a more restricted form of the canonical representation of dateTime
- http://www.w3.org/TR/xmlschema-2/#dateTime
+ http://www.w3.org/TR/xmlschema-2/#dateTime
The trailing "Z" designates UTC time and is mandatory.
Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z
All other components are mandatory.
@@ -242,20 +242,20 @@
NOW/DAY+6MONTHS+3DAYS
... 6 months and 3 days in the future from the start of
the current day
-
+
-->
<!-- KD-tree versions of date fields -->
<fieldType name="pdate" class="solr.DatePointField" docValues="true"/>
<fieldType name="pdates" class="solr.DatePointField" docValues="true" multiValued="true"/>
-
+
<!--Binary data type. The data should be sent/retrieved in as Base64 encoded Strings -->
<fieldType name="binary" class="solr.BinaryField"/>
-
- <!--
+
+ <!--
RankFields can be used to store scoring factors to improve document ranking. They should be used
in combination with RankQParserPlugin.
(experimental)
- -->
+ -->
<fieldType name="rank" class="solr.RankField"/>
<!-- solr.TextField allows the specification of custom text analyzers
@@ -288,10 +288,10 @@
<!-- A general text field that has reasonable, generic
cross-language defaults: it tokenizes with StandardTokenizer,
- removes stop words from case-insensitive "stopwords.txt"
- (empty by default), and down cases. At query time only, it
- also applies synonyms.
- -->
+ removes stop words from case-insensitive "stopwords.txt"
+ (empty by default), and down cases. At query time only, it
+ also applies synonyms.
+ -->
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100" multiValued="true">
<analyzer type="index">
<tokenizer name="standard"/>
@@ -310,15 +310,15 @@
</analyzer>
</fieldType>
-
+
<!-- SortableTextField generaly functions exactly like TextField,
except that it supports, and by default uses, docValues for sorting (or faceting)
on the first 1024 characters of the original field values (which is configurable).
-
+
This makes it a bit more useful then TextField in many situations, but the trade-off
is that it takes up more space on disk; which is why it's not used in place of TextField
for every fieldType in this _default schema.
- -->
+ -->
<dynamicField name="*_t_sort" type="text_gen_sort" indexed="true" stored="true" multiValued="false"/>
<dynamicField name="*_txt_sort" type="text_gen_sort" indexed="true" stored="true"/>
<fieldType name="text_gen_sort" class="solr.SortableTextField" positionIncrementGap="100" multiValued="true">
@@ -357,7 +357,7 @@
<filter name="keywordMarker" protected="protwords.txt"/>
<!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory:
<filter name="englishMinimalStem"/>
- -->
+ -->
<filter name="porterStem"/>
</analyzer>
<analyzer type="query">
@@ -372,7 +372,7 @@
<filter name="keywordMarker" protected="protwords.txt"/>
<!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory:
<filter name="englishMinimalStem"/>
- -->
+ -->
<filter name="porterStem"/>
</analyzer>
</fieldType>
@@ -451,7 +451,7 @@
</fieldType>
<!-- Just like text_general except it reverses the characters of
- each token, to enable more efficient leading wildcard queries.
+ each token, to enable more efficient leading wildcard queries.
-->
<dynamicField name="*_txt_rev" type="text_general_rev" indexed="true" stored="true"/>
<fieldType name="text_general_rev" class="solr.TextField" positionIncrementGap="100">
@@ -487,7 +487,7 @@
</analyzer>
</fieldType>
- <!--
+ <!--
Example of using PathHierarchyTokenizerFactory at index time, so
queries for paths match documents at that path, or in descendent paths
-->
@@ -517,7 +517,7 @@
<!-- This point type indexes the coordinates as separate fields (subFields)
If subFieldType is defined, it references a type, and a dynamic field
- definition is created matching *___<typename>. Alternately, if
+ definition is created matching *___<typename>. Alternately, if
subFieldSuffix is defined, that is used to create the subFields.
Example: if subFieldType="double", then the coordinates would be
indexed in fields myloc_0___double,myloc_1___double.
@@ -564,7 +564,7 @@
<!-- Arabic -->
<dynamicField name="*_txt_ar" type="text_ar" indexed="true" stored="true"/>
<fieldType name="text_ar" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<!-- for any non-arabic -->
<filter name="lowercase"/>
@@ -578,18 +578,18 @@
<!-- Bulgarian -->
<dynamicField name="*_txt_bg" type="text_bg" indexed="true" stored="true"/>
<fieldType name="text_bg" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_bg.txt" />
<filter name="bulgarianStem"/>
</analyzer>
</fieldType>
-
+
<!-- Catalan -->
<dynamicField name="*_txt_ca" type="text_ca" indexed="true" stored="true"/>
<fieldType name="text_ca" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<!-- removes l', etc -->
<filter name="elision" ignoreCase="true" articles="lang/contractions_ca.txt"/>
@@ -598,7 +598,7 @@
<filter name="snowballPorter" language="Catalan"/>
</analyzer>
</fieldType>
-
+
<!-- CJK bigram (see text_ja for a Japanese configuration using morphological analysis) -->
<dynamicField name="*_txt_cjk" type="text_cjk" indexed="true" stored="true"/>
<fieldType name="text_cjk" class="solr.TextField" positionIncrementGap="100">
@@ -615,29 +615,29 @@
<!-- Czech -->
<dynamicField name="*_txt_cz" type="text_cz" indexed="true" stored="true"/>
<fieldType name="text_cz" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_cz.txt" />
<filter name="czechStem"/>
</analyzer>
</fieldType>
-
+
<!-- Danish -->
<dynamicField name="*_txt_da" type="text_da" indexed="true" stored="true"/>
<fieldType name="text_da" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_da.txt" format="snowball" />
<filter name="snowballPorter" language="Danish"/>
</analyzer>
</fieldType>
-
+
<!-- German -->
<dynamicField name="*_txt_de" type="text_de" indexed="true" stored="true"/>
<fieldType name="text_de" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_de.txt" format="snowball" />
@@ -647,11 +647,11 @@
<!-- more aggressive: <filter name="snowballPorter" language="German2"/> -->
</analyzer>
</fieldType>
-
+
<!-- Greek -->
<dynamicField name="*_txt_el" type="text_el" indexed="true" stored="true"/>
<fieldType name="text_el" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<!-- greek specific lowercase for sigma -->
<filter name="greekLowercase"/>
@@ -659,11 +659,11 @@
<filter name="greekStem"/>
</analyzer>
</fieldType>
-
+
<!-- Spanish -->
<dynamicField name="*_txt_es" type="text_es" indexed="true" stored="true"/>
<fieldType name="text_es" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_es.txt" format="snowball" />
@@ -686,14 +686,14 @@
<!-- Basque -->
<dynamicField name="*_txt_eu" type="text_eu" indexed="true" stored="true"/>
<fieldType name="text_eu" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_eu.txt" />
<filter name="snowballPorter" language="Basque"/>
</analyzer>
</fieldType>
-
+
<!-- Persian -->
<dynamicField name="*_txt_fa" type="text_fa" indexed="true" stored="true"/>
<fieldType name="text_fa" class="solr.TextField" positionIncrementGap="100">
@@ -707,11 +707,11 @@
<filter name="stop" ignoreCase="true" words="lang/stopwords_fa.txt" />
</analyzer>
</fieldType>
-
+
<!-- Finnish -->
<dynamicField name="*_txt_fi" type="text_fi" indexed="true" stored="true"/>
<fieldType name="text_fi" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_fi.txt" format="snowball" />
@@ -719,11 +719,11 @@
<!-- less aggressive: <filter name="finnishLightStem"/> -->
</analyzer>
</fieldType>
-
+
<!-- French -->
<dynamicField name="*_txt_fr" type="text_fr" indexed="true" stored="true"/>
<fieldType name="text_fr" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<!-- removes l', etc -->
<filter name="elision" ignoreCase="true" articles="lang/contractions_fr.txt"/>
@@ -734,11 +734,11 @@
<!-- more aggressive: <filter name="snowballPorter" language="French"/> -->
</analyzer>
</fieldType>
-
+
<!-- Irish -->
<dynamicField name="*_txt_ga" type="text_ga" indexed="true" stored="true"/>
<fieldType name="text_ga" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<!-- removes d', etc -->
<filter name="elision" ignoreCase="true" articles="lang/contractions_ga.txt"/>
@@ -749,11 +749,11 @@
<filter name="snowballPorter" language="Irish"/>
</analyzer>
</fieldType>
-
+
<!-- Galician -->
<dynamicField name="*_txt_gl" type="text_gl" indexed="true" stored="true"/>
<fieldType name="text_gl" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_gl.txt" />
@@ -761,11 +761,11 @@
<!-- less aggressive: <filter name="galicianMinimalStem"/> -->
</analyzer>
</fieldType>
-
+
<!-- Hindi -->
<dynamicField name="*_txt_hi" type="text_hi" indexed="true" stored="true"/>
<fieldType name="text_hi" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<!-- normalizes unicode representation -->
@@ -776,11 +776,11 @@
<filter name="hindiStem"/>
</analyzer>
</fieldType>
-
+
<!-- Hungarian -->
<dynamicField name="*_txt_hu" type="text_hu" indexed="true" stored="true"/>
<fieldType name="text_hu" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_hu.txt" format="snowball" />
@@ -788,22 +788,22 @@
<!-- less aggressive: <filter name="hungarianLightStem"/> -->
</analyzer>
</fieldType>
-
+
<!-- Armenian -->
<dynamicField name="*_txt_hy" type="text_hy" indexed="true" stored="true"/>
<fieldType name="text_hy" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_hy.txt" />
<filter name="snowballPorter" language="Armenian"/>
</analyzer>
</fieldType>
-
+
<!-- Indonesian -->
<dynamicField name="*_txt_id" type="text_id" indexed="true" stored="true"/>
<fieldType name="text_id" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_id.txt" />
@@ -811,11 +811,11 @@
<filter name="indonesianStem" stemDerivational="true"/>
</analyzer>
</fieldType>
-
+
<!-- Italian -->
<dynamicField name="*_txt_it" type="text_it" indexed="true" stored="true"/>
<fieldType name="text_it" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<!-- removes l', etc -->
<filter name="elision" ignoreCase="true" articles="lang/contractions_it.txt"/>
@@ -825,7 +825,7 @@
<!-- more aggressive: <filter name="snowballPorter" language="Italian"/> -->
</analyzer>
</fieldType>
-
+
<!-- Japanese using morphological analysis (see text_cjk for a configuration using bigramming)
NOTE: If you want to optimize search for precision, use default operator AND in your request
@@ -876,7 +876,7 @@
<filter name="lowercase"/>
</analyzer>
</fieldType>
-
+
<!-- Korean morphological analysis -->
<dynamicField name="*_txt_ko" type="text_ko" indexed="true" stored="true"/>
<fieldType name="text_ko" class="solr.TextField" positionIncrementGap="100">
@@ -887,7 +887,7 @@
This dictionary was built with MeCab, it defines a format for the features adapted
for the Korean language.
-
+
Nori also has a convenient user dictionary feature that allows overriding the statistical
model with your own entries for segmentation, part-of-speech tags and readings without a need
to specify weights. Notice that user dictionaries have not been subject to extensive testing.
@@ -900,7 +900,7 @@
-->
<tokenizer name="korean" decompoundMode="discard" outputUnknownUnigrams="false"/>
<!-- Removes some part of speech stuff like EOMI (Pos.E), you can add a parameter 'tags',
- listing the tags to remove. By default it removes:
+ listing the tags to remove. By default it removes:
E, IC, J, MAG, MAJ, MM, SP, SSC, SSO, SC, SE, XPN, XSA, XSN, XSV, UNA, NA, VSV
This is basically an equivalent to stemming.
-->
@@ -914,18 +914,18 @@
<!-- Latvian -->
<dynamicField name="*_txt_lv" type="text_lv" indexed="true" stored="true"/>
<fieldType name="text_lv" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_lv.txt" />
<filter name="latvianStem"/>
</analyzer>
</fieldType>
-
+
<!-- Dutch -->
<dynamicField name="*_txt_nl" type="text_nl" indexed="true" stored="true"/>
<fieldType name="text_nl" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_nl.txt" format="snowball" />
@@ -933,11 +933,11 @@
<filter name="snowballPorter" language="Dutch"/>
</analyzer>
</fieldType>
-
+
<!-- Norwegian -->
<dynamicField name="*_txt_no" type="text_no" indexed="true" stored="true"/>
<fieldType name="text_no" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_no.txt" format="snowball" />
@@ -946,11 +946,11 @@
<!-- singular/plural: <filter name="norwegianMinimalStem"/> -->
</analyzer>
</fieldType>
-
+
<!-- Portuguese -->
<dynamicField name="*_txt_pt" type="text_pt" indexed="true" stored="true"/>
<fieldType name="text_pt" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_pt.txt" format="snowball" />
@@ -960,22 +960,22 @@
<!-- most aggressive: <filter name="portugueseStem"/> -->
</analyzer>
</fieldType>
-
+
<!-- Romanian -->
<dynamicField name="*_txt_ro" type="text_ro" indexed="true" stored="true"/>
<fieldType name="text_ro" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_ro.txt" />
<filter name="snowballPorter" language="Romanian"/>
</analyzer>
</fieldType>
-
+
<!-- Russian -->
<dynamicField name="*_txt_ru" type="text_ru" indexed="true" stored="true"/>
<fieldType name="text_ru" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_ru.txt" format="snowball" />
@@ -983,11 +983,11 @@
<!-- less aggressive: <filter name="russianLightStem"/> -->
</analyzer>
</fieldType>
-
+
<!-- Swedish -->
<dynamicField name="*_txt_sv" type="text_sv" indexed="true" stored="true"/>
<fieldType name="text_sv" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="lowercase"/>
<filter name="stop" ignoreCase="true" words="lang/stopwords_sv.txt" format="snowball" />
@@ -995,7 +995,7 @@
<!-- less aggressive: <filter name="swedishLightStem"/> -->
</analyzer>
</fieldType>
-
+
<!-- Thai -->
<dynamicField name="*_txt_th" type="text_th" indexed="true" stored="true"/>
<fieldType name="text_th" class="solr.TextField" positionIncrementGap="100">
@@ -1005,11 +1005,11 @@
<filter name="stop" ignoreCase="true" words="lang/stopwords_th.txt" />
</analyzer>
</fieldType>
-
+
<!-- Turkish -->
<dynamicField name="*_txt_tr" type="text_tr" indexed="true" stored="true"/>
<fieldType name="text_tr" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
+ <analyzer>
<tokenizer name="standard"/>
<filter name="turkishLowercase"/>
<filter name="stop" ignoreCase="false" words="lang/stopwords_tr.txt" />
@@ -1018,8 +1018,8 @@
</fieldType>
<!-- Similarity is the scoring routine for each document vs. a query.
- A custom Similarity or SimilarityFactory may be specified here, but
- the default is fine for most applications.
+ A custom Similarity or SimilarityFactory may be specified here, but
+ the default is fine for most applications.
For more info: http://lucene.apache.org/solr/guide/other-schema-elements.html#OtherSchemaElements-Similarity
-->
<!--
diff --git a/solr/solr-ref-guide/src/config-sets.adoc b/solr/solr-ref-guide/src/config-sets.adoc
index 1c566272a4b..ea736f97f4c 100644
--- a/solr/solr-ref-guide/src/config-sets.adoc
+++ b/solr/solr-ref-guide/src/config-sets.adoc
@@ -41,11 +41,11 @@ The structure should look something like this:
/<configSetBaseDir>
/configset1
/conf
- /managed-schema
+ /managed-schema.xml
/solrconfig.xml
/configset2
/conf
- /managed-schema
+ /managed-schema.xml
/solrconfig.xml
----
diff --git a/solr/solr-ref-guide/src/configuration-files.adoc b/solr/solr-ref-guide/src/configuration-files.adoc
index c84d4be983c..2c54c0634b5 100644
--- a/solr/solr-ref-guide/src/configuration-files.adoc
+++ b/solr/solr-ref-guide/src/configuration-files.adoc
@@ -40,13 +40,13 @@ The crucial parts of the Solr home directory are shown in these examples:
core.properties
conf/
solrconfig.xml
- managed-schema
+ managed-schema.xml
data/
core_name2/
core.properties
conf/
solrconfig.xml
- managed-schema
+ managed-schema.xml
data/
----
@@ -76,7 +76,7 @@ For more details on `core.properties`, see the section <<core-discovery.adoc#,Co
** `solrconfig.xml` controls high-level behavior.
You can, for example, specify an alternate location for the data directory.
For more information on `solrconfig.xml`, see <<configuring-solrconfig-xml.adoc#,Configuring solrconfig.xml>>.
-** `managed-schema` or `schema.xml` describes the documents you will ask Solr to index.
+** `managed-schema.xml` or `schema.xml` describes the documents you will ask Solr to index.
The schema defines a document as a collection of fields.
You can define both the field types and the fields themselves.
Field type definitions are powerful and include information about how Solr processes incoming field values and query values.
diff --git a/solr/solr-ref-guide/src/coreadmin-api.adoc b/solr/solr-ref-guide/src/coreadmin-api.adoc
index 0c266d84c80..60dec26c0b1 100644
--- a/solr/solr-ref-guide/src/coreadmin-api.adoc
+++ b/solr/solr-ref-guide/src/coreadmin-api.adoc
@@ -163,7 +163,7 @@ That said, if you're running SolrCloud, you should *NOT* use the CoreAdmin API a
Instead, use the <<collections-api.adoc#,Collections API>>.
With a user-managed cluster, if you have <<config-sets.adoc#,Configsets>> defined, you can use the `configSet` parameter as documented below.
-If there are no configsets, then the `instanceDir` specified in the CREATE call must already exist, and it must contain a `conf` directory which in turn must contain `solrconfig.xml`, your schema (usually named either `managed-schema` or `schema.xml`), and any files referenced by those configs.
+If there are no configsets, then the `instanceDir` specified in the CREATE call must already exist, and it must contain a `conf` directory which in turn must contain `solrconfig.xml`, your schema (usually named either `managed-schema.xml` or `schema.xml`), and any files referenced by those configs.
The config and schema filenames can be specified with the `config` and `schema` parameters, but these are expert options.
One thing you could do to avoid creating the `conf` directory is use `config` and `schema` parameters that point at absolute paths, but this can lead to confusing configurations unless you fully understand what you are doing.
diff --git a/solr/solr-ref-guide/src/documents-fields-schema-design.adoc b/solr/solr-ref-guide/src/documents-fields-schema-design.adoc
index 880bfaf7103..08c34438fc2 100644
--- a/solr/solr-ref-guide/src/documents-fields-schema-design.adoc
+++ b/solr/solr-ref-guide/src/documents-fields-schema-design.adoc
@@ -82,7 +82,7 @@ Field analysis is an important part of a field type.
== Solr's Schema File
Solr stores details about the field types and fields it is expected to understand in a schema file.
-This file is named either `managed-schema` or `schema.xml`.
+This file is named either `managed-schema.xml` or `schema.xml`.
The difference is determined by how you plan to manage Solr's schema in your installation: either programmatically or by hand-editing.
An important fact about the schema is that it is a Solr concept.
diff --git a/solr/solr-ref-guide/src/schema-api.adoc b/solr/solr-ref-guide/src/schema-api.adoc
index fc24ee905df..b73f082a920 100644
--- a/solr/solr-ref-guide/src/schema-api.adoc
+++ b/solr/solr-ref-guide/src/schema-api.adoc
@@ -29,15 +29,17 @@ See the section <<schema-factory.adoc#,Schema Factory Definition in SolrConfig>>
.Hand editing of the managed schema is discouraged
[NOTE]
====
-The file named "managed-schema" in the example configurations may include a note that recommends never hand-editing the file.
+The file named "managed-schema.xml" in the example configurations may include a note that recommends never hand-editing the file.
Before the Schema API existed, such edits were the only way to make changes to the schema, and users may have a strong desire to continue making changes this way.
The reason that this is discouraged is because hand-edits of the schema may be lost if the Schema API described here is later used to make a change, unless the core or collection is reloaded or Solr is restarted before using the Schema API.
If care is taken to always reload or restart after a manual edit, then there is no problem at all with doing those edits.
+
+Prior to Solr 9, this xml file was referred to as `managed-schema` with no file extension.
====
The API allows two output modes for all calls: JSON or XML.
-When requesting the complete schema, there is another output mode which is XML modeled after the managed-schema file itself, which is in XML format.
+When requesting the complete schema, there is another output mode which is XML modeled after the managed-schema.xml file itself, which is in XML format.
When modifying the schema with the API, a core reload will automatically occur in order for the changes to be available immediately for documents indexed thereafter.
Previously indexed documents will *not* be automatically updated - they *must* be reindexed if existing index data uses schema elements that you changed.
diff --git a/solr/solr-ref-guide/src/schema-elements.adoc b/solr/solr-ref-guide/src/schema-elements.adoc
index c2220fa34e4..cf99c57e5e0 100644
--- a/solr/solr-ref-guide/src/schema-elements.adoc
+++ b/solr/solr-ref-guide/src/schema-elements.adoc
@@ -21,7 +21,7 @@ Solr stores details about the field types and fields it is expected to understan
== Solr's Schema File
The name and location of Solr's schema file may vary depending on how you initially configured Solr or if you modified it later.
-* `managed-schema` is the name for the schema file Solr uses by default to support making schema changes at runtime via the <<schema-api.adoc#,Schema API>>, or <<schemaless-mode.adoc#,Schemaless Mode>> features.
+* `managed-schema.xml` is the name for the schema file Solr uses by default to support making schema changes at runtime via the <<schema-api.adoc#,Schema API>>, or <<schemaless-mode.adoc#,Schemaless Mode>> features.
+
You may <<schema-factory.adoc#,explicitly configure the managed schema features>> to use an alternative filename if you choose, but the contents of the files are still updated automatically by Solr.
* `schema.xml` is the traditional name for a schema file which can be edited manually by users who use the <<schema-factory.adoc#,`ClassicIndexSchemaFactory`>>.
diff --git a/solr/solr-ref-guide/src/schema-factory.adoc b/solr/solr-ref-guide/src/schema-factory.adoc
index 05b60b4f65d..3b80f3bb5d2 100644
--- a/solr/solr-ref-guide/src/schema-factory.adoc
+++ b/solr/solr-ref-guide/src/schema-factory.adoc
@@ -41,7 +41,7 @@ While the "read" features of the Schema API are supported for all schema types,
=== ManagedIndexSchemaFactory
-When a `<schemaFactory/>` is not explicitly declared in a `solrconfig.xml` file, Solr implicitly uses a `ManagedIndexSchemaFactory`, which is by default `"mutable"` (editable) and keeps schema information in a `managed-schema` file.
+When a `<schemaFactory/>` is not explicitly declared in a `solrconfig.xml` file, Solr implicitly uses a `ManagedIndexSchemaFactory`, which is by default `"mutable"` (editable) and keeps schema information in a `managed-schema.xml` file.
Using the Managed Schema is required to be able to use the Schema API to modify your schema.
However, using Managed Schema does not mean you are also using Solr in Schemaless Mode (or "schema guessing" mode).
@@ -54,7 +54,7 @@ Below is an example of a `schemaFactory` that reflects Solr's defaults:
----
<schemaFactory class="ManagedIndexSchemaFactory">
<bool name="mutable">true</bool>
- <str name="managedSchemaResourceName">managed-schema</str>
+ <str name="managedSchemaResourceName">managed-schema.xml</str>
</schemaFactory>
----
@@ -76,7 +76,7 @@ With the default configuration shown above, you could use the <<schema-api.adoc#
+
[%autowidth,frame=none]
|===
-|Optional |Default: `managed-schema`
+|Optional |Default: `managed-schema.xml`
|===
+
The name of the schema file.
@@ -101,7 +101,7 @@ This option takes no parameters.
If you have an existing Solr collection that uses `ClassicIndexSchemaFactory`, and you wish to convert to use a managed schema, you can simply modify the `solrconfig.xml` to specify the use of the `ManagedIndexSchemaFactory`.
-Once Solr is restarted and it detects that a `schema.xml` file exists, but the `managedSchemaResourceName` file (i.e., "`managed-schema`") does not exist, the existing `schema.xml` file will be renamed to `schema.xml.bak` and the contents re-written to the managed schema file.
+Once Solr is restarted and it detects that a `schema.xml` file exists, but the `managedSchemaResourceName` file (i.e., "`managed-schema.xml`") does not exist, the existing `schema.xml` file will be renamed to `schema.xml.bak` and the contents re-written to the managed schema file.
If you look at the resulting file, you'll see this at the top of the page:
@@ -116,7 +116,7 @@ You are now free to use the <<schema-api.adoc#,Schema API>> to make changes, and
If you have started Solr with managed schema enabled and you would like to switch to manually editing a `schema.xml` file, you should take the following steps:
-. Rename the `managed-schema` file to `schema.xml`.
+. Rename the `managed-schema.xml` file to `schema.xml`.
. Modify `solrconfig.xml` to replace the `schemaFactory` class.
.. Remove any `ManagedIndexSchemaFactory` definition if it exists.
.. Add a `ClassicIndexSchemaFactory` definition as shown above
diff --git a/solr/solr-ref-guide/src/schemaless-mode.adoc b/solr/solr-ref-guide/src/schemaless-mode.adoc
index 4dcbd7f466c..311b6779041 100644
--- a/solr/solr-ref-guide/src/schemaless-mode.adoc
+++ b/solr/solr-ref-guide/src/schemaless-mode.adoc
@@ -82,7 +82,7 @@ You can configure the `ManagedIndexSchemaFactory` (and control the resource file
----
<schemaFactory class="ManagedIndexSchemaFactory">
<bool name="mutable">true</bool>
- <str name="managedSchemaResourceName">managed-schema</str>
+ <str name="managedSchemaResourceName">managed-schema.xml</str>
</schemaFactory>
----
diff --git a/solr/solr-ref-guide/src/solr-glossary.adoc b/solr/solr-ref-guide/src/solr-glossary.adoc
index ad16513cd99..842bc1ee8aa 100644
--- a/solr/solr-ref-guide/src/solr-glossary.adoc
+++ b/solr/solr-ref-guide/src/solr-glossary.adoc
@@ -186,9 +186,9 @@ See also <<solrclouddef,SolrCloud>>.
[[solrclouddef]]<<cluster-types.adoc#solrcloud-mode,SolrCloud>>::
Umbrella term for a suite of functionality in Solr which allows managing a <<cluster,Cluster>> of Solr <<node,Nodes>> for scalability, fault tolerance, and high availability.
-[[schema]]<<solr-schema.adoc#,Solr Schema (managed-schema or schema.xml)>>::
+[[schema]]<<solr-schema.adoc#,Solr Schema (managed-schema.xml or schema.xml)>>::
The Solr index Schema defines the fields to be indexed and the type for the field (text, integers, etc.).
-By default schema data can be "managed" at run time using the <<schema-api.adoc#,Schema API>> and is typically kept in a file named `managed-schema` which Solr modifies as needed, but a collection may be configured to use a static Schema, which is only loaded on startup from a human edited configuration file - typically named `schema.xml`.
+By default schema data can be "managed" at run time using the <<schema-api.adoc#,Schema API>> and is typically kept in a file named `managed-schema.xml` which Solr modifies as needed, but a collection may be configured to use a static Schema, which is only loaded on startup from a human edited configuration file - typically named `schema.xml`.
See <<schema-factory.adoc#,Schema Factory Definition in SolrConfig>> for details.
[[solrconfig]]<<configuring-solrconfig-xml.adoc#,SolrConfig (solrconfig.xml)>>::
diff --git a/solr/solr-ref-guide/src/solrcloud-with-legacy-configuration-files.adoc b/solr/solr-ref-guide/src/solrcloud-with-legacy-configuration-files.adoc
index fc3e56c0881..dc6af6c3ca5 100644
--- a/solr/solr-ref-guide/src/solrcloud-with-legacy-configuration-files.adoc
+++ b/solr/solr-ref-guide/src/solrcloud-with-legacy-configuration-files.adoc
@@ -22,7 +22,7 @@ All of the required configuration is already set up in the sample configurations
You only need to add the following if you are migrating old configuration files.
Do not remove these files and parameters from a new Solr instance if you intend to use Solr in SolrCloud mode.
-These properties exist in 3 files: `schema.xml` or `managed-schema`, `solrconfig.xml`, and `solr.xml`.
+These properties exist in 3 files: `schema.xml` or `managed-schema.xml`, `solrconfig.xml`, and `solr.xml`.
. In the schema file, you must have a `\_version_` field defined:
+
diff --git a/solr/solr-ref-guide/src/tutorial-diy.adoc b/solr/solr-ref-guide/src/tutorial-diy.adoc
index dafc4fa8f27..2f961a8d60e 100644
--- a/solr/solr-ref-guide/src/tutorial-diy.adoc
+++ b/solr/solr-ref-guide/src/tutorial-diy.adoc
@@ -72,7 +72,7 @@ Click on the btn:[Submit Document] button below the form to index your document.
=== Updating Data
You may notice that even if you index content in this tutorial more than once, it does not duplicate the results found.
-This is because the example Solr schema (a file named either `managed-schema` or `schema.xml`) specifies a `uniqueKey` field called `id`.
+This is because the example Solr schema (a file named either `managed-schema.xml` or `schema.xml`) specifies a `uniqueKey` field called `id`.
Whenever you POST commands to Solr to add a document with the same value for the `uniqueKey` as an existing document, it automatically replaces it for you.
You can see that has happened by looking at the values for `numDocs` and `maxDoc` in the core-specific Overview section of the Solr Admin UI.
diff --git a/solr/solr-ref-guide/src/tutorial-techproducts.adoc b/solr/solr-ref-guide/src/tutorial-techproducts.adoc
index a95f41d3373..97fe3c940fd 100644
--- a/solr/solr-ref-guide/src/tutorial-techproducts.adoc
+++ b/solr/solr-ref-guide/src/tutorial-techproducts.adoc
@@ -125,7 +125,7 @@ _default or sample_techproducts_configs [_default]
We've reached another point where we will deviate from the default option.
Solr has two sample sets of configuration files (called a configset) available out-of-the-box.
-A collection must have a configset, which at a minimum includes the two main configuration files for Solr: the schema file (named either `managed-schema` or `schema.xml`), and `solrconfig.xml`.
+A collection must have a configset, which at a minimum includes the two main configuration files for Solr: the schema file (named either `managed-schema.xml` or `schema.xml`), and `solrconfig.xml`.
The question here is which configset you would like to start with.
The `_default` is a bare-bones option, but note there's one whose name includes "techproducts", the same as we named our collection.
This configset is specifically designed to support the sample data we want to use, so enter `sample_techproducts_configs` at the prompt and hit kbd:[enter].
diff --git a/solr/solr-ref-guide/src/user-managed-index-replication.adoc b/solr/solr-ref-guide/src/user-managed-index-replication.adoc
index d3beb166752..287066de155 100644
--- a/solr/solr-ref-guide/src/user-managed-index-replication.adoc
+++ b/solr/solr-ref-guide/src/user-managed-index-replication.adoc
@@ -124,7 +124,7 @@ A line like the following would ensure that the local configuration `solrconfig_
+
[source,xml]
----
-<str name="confFiles">solrconfig_follower.xml:solrconfig.xml,managed-schema,stopwords.txt</str>
+<str name="confFiles">solrconfig_follower.xml:solrconfig.xml,managed-schema.xml,stopwords.txt</str>
----
+
On the leader server, the file name of the follower configuration file can be anything, as long as the name is correctly identified in the `confFiles` string; then it will be saved as whatever file name appears after the colon ':'.
diff --git a/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig-managed-schema.xml b/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig-managed-schema.xml
index 9db6a577f20..92bf388520c 100644
--- a/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig-managed-schema.xml
+++ b/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig-managed-schema.xml
@@ -17,16 +17,15 @@
-->
<!--
- This is a stripped down config file used for a simple example...
- It is *not* a good example to work from.
+ This is a stripped down config file used for a simple example...
+ It is *not* a good example to work from.
-->
<config>
<luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
<schemaFactory class="ManagedIndexSchemaFactory">
<bool name="mutable">true</bool>
- <str name="managedSchemaResourceName">managed-schema</str>
+ <str name="managedSchemaResourceName">managed-schema.xml</str>
</schemaFactory>
</config>
-