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.
  • Method Details

    • isMutable

      public boolean isMutable()
      Overrides:
      isMutable in class IndexSchema
    • 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.
    • 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 by IndexSchema.getSchemaUpdateLock().
      Overrides:
      addFields in class IndexSchema
      Parameters:
      newFields - the SchemaFields to add
      copyFieldNames - 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:
    • 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 class IndexSchema
      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 class IndexSchema
      Parameters:
      fieldName - The name of the field to be replaced
      replacementFieldType - The field type of the replacement field
      replacementArgs - 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 by IndexSchema.getSchemaUpdateLock().
      Overrides:
      addDynamicFields in class IndexSchema
      Parameters:
      newDynamicFields - the SchemaFields to add
      copyFieldNames - 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:
    • 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 class IndexSchema
      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 class IndexSchema
      Parameters:
      fieldNamePattern - The glob for the dynamic field to be replaced
      replacementFieldType - The field type of the replacement dynamic field
      replacementArgs - 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 by IndexSchema.getSchemaUpdateLock().
      Overrides:
      addCopyFields in class IndexSchema
      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:
    • 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 by IndexSchema.getSchemaUpdateLock()

      Overrides:
      addCopyFields in class IndexSchema
      Parameters:
      source - source field name
      destinations - collection of target field names
      maxChars - max number of characters to copy from the source to each of the destinations. Use CopyField.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 class IndexSchema
      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 by IndexSchema.getSchemaUpdateLock().
      Overrides:
      addFieldTypes in class IndexSchema
      Parameters:
      fieldTypeList - a list of FieldTypes to add
      persist - to persist the schema or not
      Returns:
      a new IndexSchema based on this schema with the new types added
      See Also:
    • 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 class IndexSchema
      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 class IndexSchema
      Parameters:
      typeName - The name of the field type to be replaced
      replacementClassName - The class name of the replacement field type
      replacementArgs - Initialization params for the replacement field type
      Returns:
      a new IndexSchema based on this schema with the named field type replaced
    • 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 to IndexSchema.addField(SchemaField).
      Overrides:
      newField in class IndexSchema
      Parameters:
      fieldName - the name of the field to add
      fieldType - the field type for the new field
      options - the options to use when creating the SchemaField
      Returns:
      The created SchemaField
      See Also:
    • 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 to IndexSchema.addField(SchemaField).
      Overrides:
      newDynamicField in class IndexSchema
      Parameters:
      fieldNamePattern - the pattern for the dynamic field to add
      fieldType - the field type for the new field
      options - the options to use when creating the SchemaField
      Returns:
      The created SchemaField
      See Also:
    • 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 to IndexSchema.addFieldTypes(java.util.List, boolean).
      Overrides:
      newFieldType in class IndexSchema
      Parameters:
      typeName - the name of the type to add
      className - the name of the FieldType class
      options - the options to use when creating the FieldType
      Returns:
      The created FieldType
      See Also:
    • 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 class IndexSchema
      Returns:
      the schema update lock object to synchronize on