Class 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 Detail

      • 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.
      • 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
      • 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​(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
      • 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
      • 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 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:
        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 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:
        IndexSchema.addField(SchemaField)
      • 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 class IndexSchema
        Returns:
        the schema update lock object to synchronize on