Class ManagedIndexSchema
- java.lang.Object
-
- org.apache.solr.schema.IndexSchema
-
- org.apache.solr.schema.ManagedIndexSchema
-
public final class ManagedIndexSchema extends IndexSchema
Solr-managed schema - non-user-editable, but can be mutable via internal and external REST API requests.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ManagedIndexSchema.FieldExistsException
static class
ManagedIndexSchema.SchemaChangedInZkException
-
Nested classes/interfaces inherited from class org.apache.solr.schema.IndexSchema
IndexSchema.DynamicCopy, IndexSchema.DynamicField, IndexSchema.DynamicReplacement, IndexSchema.SchemaProps
-
-
Field Summary
-
Fields inherited from class org.apache.solr.schema.IndexSchema
COPY_FIELD, COPY_FIELDS, copyFieldsMap, copyFieldTargetCounts, DEFAULT_SCHEMA_FILE, DESTINATION, DYNAMIC_FIELD, DYNAMIC_FIELDS, dynamicCopyFields, dynamicFieldCache, dynamicFields, FIELD, FIELD_TYPE, FIELD_TYPES, fields, FIELDS, fieldsWithDefaultValue, fieldTypes, INTERNAL_POLY_FIELD_PREFIX, isExplicitSimilarity, loader, LUCENE_MATCH_VERSION_PARAM, luceneVersion, MAX_CHARS, name, NAME, nameMapping, NEST_PARENT_FIELD_NAME, NEST_PATH_FIELD_NAME, REQUIRED, requiredFields, resourceName, ROOT_FIELD_NAME, SCHEMA, schemaAware, similarity, SIMILARITY, similarityFactory, SLASH, SOURCE, TYPE, TYPES, UNIQUE_KEY, uniqueKeyField, uniqueKeyFieldName, uniqueKeyFieldType, version, VERSION
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ManagedIndexSchema
addCopyFields(String source, Collection<String> destinations, int maxChars)
Copies this schema and adds the new copy fields to the copy.ManagedIndexSchema
addCopyFields(Map<String,Collection<String>> copyFields, boolean persist)
Copies this schema and adds the new copy fields to the copy Requires synchronizing on the object returned byIndexSchema.getSchemaUpdateLock()
.ManagedIndexSchema
addDynamicFields(Collection<SchemaField> newDynamicFields, Map<String,Collection<String>> copyFieldNames, boolean persist)
Copies this schema, adds the given dynamic fields to the copy, Requires synchronizing on the object returned byIndexSchema.getSchemaUpdateLock()
.ManagedIndexSchema
addFields(Collection<SchemaField> newFields, Map<String,Collection<String>> copyFieldNames, boolean persist)
Copies this schema, adds the given fields to the copy Requires synchronizing on the object returned byIndexSchema.getSchemaUpdateLock()
.ManagedIndexSchema
addFieldTypes(List<FieldType> fieldTypeList, boolean persist)
Copies this schema, adds the given field type to the copy, Requires synchronizing on the object returned byIndexSchema.getSchemaUpdateLock()
.ManagedIndexSchema
deleteCopyFields(Map<String,Collection<String>> copyFields)
Copies this schema and deletes the given copy fields from the copy.ManagedIndexSchema
deleteDynamicFields(Collection<String> fieldNamePatterns)
Copies this schema, deletes the named dynamic fields from the copy.ManagedIndexSchema
deleteFields(Collection<String> names)
Copies this schema, deletes the named fields from the copy.ManagedIndexSchema
deleteFieldTypes(Collection<String> names)
Copies this schema, deletes the named field types from the copy.protected static List<String>
getActiveReplicaCoreUrls(ZkController zkController, String collection, String localCoreNodeName)
Object
getSchemaUpdateLock()
Returns the schema update lock that should be synchronized on to update the schema.int
getSchemaZkVersion()
protected void
informResourceLoaderAwareObjectsForFieldType(FieldType fieldType)
Informs analyzers used by a fieldType.protected void
informResourceLoaderAwareObjectsInChain(TokenizerChain chain)
After creating a new FieldType, it may contain components that implement the ResourceLoaderAware interface, which need to be informed after they are loaded (as they depend on this callback to complete initialization work)boolean
isMutable()
SchemaField
newDynamicField(String fieldNamePattern, String fieldType, Map<String,?> options)
Returns a SchemaField if the given dynamic field glob does not already exist in this schema, and does not match any dynamic fields in this schema.SchemaField
newField(String fieldName, String fieldType, Map<String,?> options)
Returns a SchemaField if the given fieldName does not already exist in this schema, and does not match any dynamic fields in this schema.FieldType
newFieldType(String typeName, String className, Map<String,?> options)
Returns a FieldType if the given typeName does not already exist in this schema.boolean
persistManagedSchema(boolean createOnly)
Persist the schema to local storage or to ZooKeeperprotected void
postReadInform()
ManagedIndexSchema
replaceDynamicField(String fieldNamePattern, FieldType replacementFieldType, Map<String,?> replacementArgs)
Copies this schema, deletes the named dynamic field from the copy, creates a new dynamic field with the same field name pattern using the given args, then rebinds any referring dynamic copy fields to the replacement dynamic field.ManagedIndexSchema
replaceField(String fieldName, FieldType replacementFieldType, Map<String,?> replacementArgs)
Copies this schema, deletes the named field from the copy, creates a new field with the same name using the given args, then rebinds any referring copy fields to the replacement field.ManagedIndexSchema
replaceFieldType(String typeName, String replacementClassName, Map<String,Object> replacementArgs)
Copies this schema, deletes the named field type from the copy, creates a new field type with the same name using the given args, rebuilds fields and dynamic fields of the given type, then rebinds any referring copy fields to the rebuilt fields.static void
waitForSchemaZkVersionAgreement(String collection, String localCoreNodeName, int schemaZkVersion, ZkController zkController, int maxWaitSecs)
Block up to a specified maximum time until we see agreement on the schema version in ZooKeeper across all replicas for a collection.-
Methods inherited from class org.apache.solr.schema.IndexSchema
addField, addField, addField, addFields, dynamicFieldListToSortedArray, getCopyFieldProperties, getCopyFieldsList, getCopyFieldsMap, getCopySources, getDefaultLuceneMatchVersion, getDynamicCopyFields, getDynamicFieldPrototypes, getDynamicFields, getDynamicFieldType, getDynamicPattern, getField, getFieldOrNull, getFields, getFieldsWithDefaultValue, getFieldType, getFieldTypeByName, getFieldTypeNoEx, getFieldTypes, getFieldTypeXPathExpressions, getIndexAnalyzer, getNamedPropertyValues, getNamedPropertyValues, getPayloadDecoder, getQueryAnalyzer, getRequiredFields, getResourceLoader, getResourceName, getSchemaName, getSimilarity, getSimilarityFactory, getUninversionMapper, getUniqueKeyField, getUniqueKeyField, getVersion, hasExplicitField, isCopyFieldTarget, isDuplicateDynField, isDynamicField, isUsableForChildDocs, isValidDynamicField, isValidFieldGlob, loadCopyFields, loadFields, printableUniqueKey, readSchema, refreshAnalyzers, registerCopyField, registerCopyField, registerDynamicFields, registerExplicitSrcAndDestFields, savesChildDocRelations, setResourceName
-
-
-
-
Method Detail
-
isMutable
public boolean isMutable()
- Overrides:
isMutable
in classIndexSchema
-
persistManagedSchema
public boolean persistManagedSchema(boolean createOnly)
Persist the schema to local storage or to ZooKeeper- Parameters:
createOnly
- set to false to allow update of existing schema
-
waitForSchemaZkVersionAgreement
public static void waitForSchemaZkVersionAgreement(String collection, String localCoreNodeName, int schemaZkVersion, ZkController zkController, int maxWaitSecs)
Block up to a specified maximum time until we see agreement on the schema version in ZooKeeper across all replicas for a collection.
-
getActiveReplicaCoreUrls
protected static List<String> getActiveReplicaCoreUrls(ZkController zkController, String collection, String localCoreNodeName)
-
addFields
public ManagedIndexSchema addFields(Collection<SchemaField> newFields, Map<String,Collection<String>> copyFieldNames, boolean persist)
Description copied from class:IndexSchema
Copies this schema, adds the given fields to the copy Requires synchronizing on the object returned byIndexSchema.getSchemaUpdateLock()
.- Overrides:
addFields
in classIndexSchema
- Parameters:
newFields
- the SchemaFields to addcopyFieldNames
- 0 or more names of targets to copy this field to. The target fields must already exist.persist
- Persist the schema or not- Returns:
- a new IndexSchema based on this schema with newFields added
- See Also:
IndexSchema.newField(String, String, Map)
-
deleteFields
public ManagedIndexSchema deleteFields(Collection<String> names)
Description copied from class:IndexSchema
Copies this schema, deletes the named fields from the copy.The schema will not be persisted.
Requires synchronizing on the object returned by
IndexSchema.getSchemaUpdateLock()
.- Overrides:
deleteFields
in classIndexSchema
- Parameters:
names
- the names of the fields to delete- Returns:
- a new IndexSchema based on this schema with the named fields deleted
-
replaceField
public ManagedIndexSchema replaceField(String fieldName, FieldType replacementFieldType, Map<String,?> replacementArgs)
Description copied from class:IndexSchema
Copies this schema, deletes the named field from the copy, creates a new field with the same name using the given args, then rebinds any referring copy fields to the replacement field.The schema will not be persisted.
Requires synchronizing on the object returned by
IndexSchema.getSchemaUpdateLock()
.- Overrides:
replaceField
in classIndexSchema
- Parameters:
fieldName
- The name of the field to be replacedreplacementFieldType
- The field type of the replacement fieldreplacementArgs
- Initialization params for the replacement field- Returns:
- a new IndexSchema based on this schema with the named field replaced
-
addDynamicFields
public ManagedIndexSchema addDynamicFields(Collection<SchemaField> newDynamicFields, Map<String,Collection<String>> copyFieldNames, boolean persist)
Description copied from class:IndexSchema
Copies this schema, adds the given dynamic fields to the copy, Requires synchronizing on the object returned byIndexSchema.getSchemaUpdateLock()
.- Overrides:
addDynamicFields
in classIndexSchema
- Parameters:
newDynamicFields
- the SchemaFields to addcopyFieldNames
- 0 or more names of targets to copy this field to. The target fields must already exist.persist
- to persist the schema or not- Returns:
- a new IndexSchema based on this schema with newDynamicFields added
- See Also:
IndexSchema.newDynamicField(String, String, Map)
-
deleteDynamicFields
public ManagedIndexSchema deleteDynamicFields(Collection<String> fieldNamePatterns)
Description copied from class:IndexSchema
Copies this schema, deletes the named dynamic fields from the copy.The schema will not be persisted.
Requires synchronizing on the object returned by
IndexSchema.getSchemaUpdateLock()
.- Overrides:
deleteDynamicFields
in classIndexSchema
- Parameters:
fieldNamePatterns
- the names of the dynamic fields to delete- Returns:
- a new IndexSchema based on this schema with the named dynamic fields deleted
-
replaceDynamicField
public ManagedIndexSchema replaceDynamicField(String fieldNamePattern, FieldType replacementFieldType, Map<String,?> replacementArgs)
Description copied from class:IndexSchema
Copies this schema, deletes the named dynamic field from the copy, creates a new dynamic field with the same field name pattern using the given args, then rebinds any referring dynamic copy fields to the replacement dynamic field.The schema will not be persisted.
Requires synchronizing on the object returned by
IndexSchema.getSchemaUpdateLock()
.- Overrides:
replaceDynamicField
in classIndexSchema
- Parameters:
fieldNamePattern
- The glob for the dynamic field to be replacedreplacementFieldType
- The field type of the replacement dynamic fieldreplacementArgs
- Initialization params for the replacement dynamic field- Returns:
- a new IndexSchema based on this schema with the named dynamic field replaced
-
addCopyFields
public ManagedIndexSchema addCopyFields(Map<String,Collection<String>> copyFields, boolean persist)
Description copied from class:IndexSchema
Copies this schema and adds the new copy fields to the copy Requires synchronizing on the object returned byIndexSchema.getSchemaUpdateLock()
.- Overrides:
addCopyFields
in classIndexSchema
- Parameters:
copyFields
- Key is the name of the source field name, value is a collection of target field names. Fields must exist.persist
- to persist the schema or not- Returns:
- The new Schema with the copy fields added
- See Also:
to limit the number of copied characters.
-
addCopyFields
public ManagedIndexSchema addCopyFields(String source, Collection<String> destinations, int maxChars)
Description copied from class:IndexSchema
Copies this schema and adds the new copy fields to the copy. Requires synchronizing on the object returned byIndexSchema.getSchemaUpdateLock()
- Overrides:
addCopyFields
in classIndexSchema
- Parameters:
source
- source field namedestinations
- collection of target field namesmaxChars
- max number of characters to copy from the source to each of the destinations. UseCopyField.UNLIMITED
if you don't want to limit the number of copied chars.- Returns:
- The new Schema with the copy fields added
-
deleteCopyFields
public ManagedIndexSchema deleteCopyFields(Map<String,Collection<String>> copyFields)
Description copied from class:IndexSchema
Copies this schema and deletes the given copy fields from the copy.The schema will not be persisted.
Requires synchronizing on the object returned by
IndexSchema.getSchemaUpdateLock()
.- Overrides:
deleteCopyFields
in classIndexSchema
- Parameters:
copyFields
- Key is the name of the source field name, value is a collection of target field names. Each corresponding copy field directives must exist.- Returns:
- The new Schema with the copy fields deleted
-
addFieldTypes
public ManagedIndexSchema addFieldTypes(List<FieldType> fieldTypeList, boolean persist)
Description copied from class:IndexSchema
Copies this schema, adds the given field type to the copy, Requires synchronizing on the object returned byIndexSchema.getSchemaUpdateLock()
.- Overrides:
addFieldTypes
in classIndexSchema
- Parameters:
fieldTypeList
- a list of FieldTypes to addpersist
- to persist the schema or not- Returns:
- a new IndexSchema based on this schema with the new types added
- See Also:
IndexSchema.newFieldType(String, String, Map)
-
deleteFieldTypes
public ManagedIndexSchema deleteFieldTypes(Collection<String> names)
Description copied from class:IndexSchema
Copies this schema, deletes the named field types from the copy.The schema will not be persisted.
Requires synchronizing on the object returned by
IndexSchema.getSchemaUpdateLock()
.- Overrides:
deleteFieldTypes
in classIndexSchema
- Parameters:
names
- the names of the field types to delete- Returns:
- a new IndexSchema based on this schema with the named field types deleted
-
replaceFieldType
public ManagedIndexSchema replaceFieldType(String typeName, String replacementClassName, Map<String,Object> replacementArgs)
Description copied from class:IndexSchema
Copies this schema, deletes the named field type from the copy, creates a new field type with the same name using the given args, rebuilds fields and dynamic fields of the given type, then rebinds any referring copy fields to the rebuilt fields.The schema will not be persisted.
Requires synchronizing on the object returned by
IndexSchema.getSchemaUpdateLock()
.- Overrides:
replaceFieldType
in classIndexSchema
- Parameters:
typeName
- The name of the field type to be replacedreplacementClassName
- The class name of the replacement field typereplacementArgs
- Initialization params for the replacement field type- Returns:
- a new IndexSchema based on this schema with the named field type replaced
-
postReadInform
protected void postReadInform()
- Overrides:
postReadInform
in classIndexSchema
-
informResourceLoaderAwareObjectsForFieldType
protected void informResourceLoaderAwareObjectsForFieldType(FieldType fieldType)
Informs analyzers used by a fieldType.
-
newField
public SchemaField newField(String fieldName, String fieldType, Map<String,?> options)
Description copied from class:IndexSchema
Returns a SchemaField if the given fieldName does not already exist in this schema, and does not match any dynamic fields in this schema. The resulting SchemaField can be used in a call toIndexSchema.addField(SchemaField)
.- Overrides:
newField
in classIndexSchema
- Parameters:
fieldName
- the name of the field to addfieldType
- the field type for the new fieldoptions
- the options to use when creating the SchemaField- Returns:
- The created SchemaField
- See Also:
IndexSchema.addField(SchemaField)
-
getSchemaZkVersion
public int getSchemaZkVersion()
-
newDynamicField
public SchemaField newDynamicField(String fieldNamePattern, String fieldType, Map<String,?> options)
Description copied from class:IndexSchema
Returns a SchemaField if the given dynamic field glob does not already exist in this schema, and does not match any dynamic fields in this schema. The resulting SchemaField can be used in a call toIndexSchema.addField(SchemaField)
.- Overrides:
newDynamicField
in classIndexSchema
- Parameters:
fieldNamePattern
- the pattern for the dynamic field to addfieldType
- the field type for the new fieldoptions
- the options to use when creating the SchemaField- Returns:
- The created SchemaField
- See Also:
IndexSchema.addField(SchemaField)
-
newFieldType
public FieldType newFieldType(String typeName, String className, Map<String,?> options)
Description copied from class:IndexSchema
Returns a FieldType if the given typeName does not already exist in this schema. The resulting FieldType can be used in a call toIndexSchema.addFieldTypes(java.util.List, boolean)
.- Overrides:
newFieldType
in classIndexSchema
- Parameters:
typeName
- the name of the type to addclassName
- the name of the FieldType classoptions
- the options to use when creating the FieldType- Returns:
- The created FieldType
- See Also:
IndexSchema.addFieldTypes(java.util.List, boolean)
-
informResourceLoaderAwareObjectsInChain
protected void informResourceLoaderAwareObjectsInChain(TokenizerChain chain)
After creating a new FieldType, it may contain components that implement the ResourceLoaderAware interface, which need to be informed after they are loaded (as they depend on this callback to complete initialization work)
-
getSchemaUpdateLock
public Object getSchemaUpdateLock()
Description copied from class:IndexSchema
Returns the schema update lock that should be synchronized on to update the schema. Only applicable to mutable schemas.- Overrides:
getSchemaUpdateLock
in classIndexSchema
- Returns:
- the schema update lock object to synchronize on
-
-