Class Schema

  • All Implemented Interfaces:
    SchemaFieldProperties, java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<SchemaField>

    public class Schema
    extends java.lang.Object
    implements java.lang.Iterable<SchemaField>, SchemaFieldProperties, java.io.Externalizable, java.lang.Cloneable
    Contains all information about a particular data set.

    A schema informs various transformers, services and any other interested parties (clients for example) about the underlying data structure of the information available.

    For example a transformer might look at the fields in the schema and convert fields to various data types based on their field types as a means of content checking.

    They might also use properties stored on fields to enable or disable certain features like linguistics.

    See Also:
    Serialized Form
    • Field Detail

      • DEFAULT_SCHEMA_NAME

        public static final java.lang.String DEFAULT_SCHEMA_NAME
        The name of the default system schema.
        See Also:
        Constant Field Values
      • UID_FIELD

        public static final java.lang.String UID_FIELD
        The reserved ID field for documents.
        See Also:
        Constant Field Values
      • PROP_CACHE_DYNAMIC_FIELD_LOOKUPS

        @Deprecated
        public static final java.lang.String PROP_CACHE_DYNAMIC_FIELD_LOOKUPS
        Deprecated.
        property name for changing whether dynamic fields which are looked up are cached in the schema.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Schema

        public Schema()
      • Schema

        public Schema​(java.lang.String name)
        Construct a new Schema.
        Parameters:
        name - the schema name
    • Method Detail

      • isDefaultSearchField

        public static boolean isDefaultSearchField​(java.lang.String field)
        Return true if field is the '*' field.
      • resolveFieldName

        public java.lang.String resolveFieldName​(java.lang.String field)
        Resolve field.

        If field is null or "*", the default search field will be returned, otherwise field will be returned.

      • addField

        public SchemaField addField​(java.lang.String fieldName)
        Adds a new field by name to the schema.
        Parameters:
        fieldName - the name of the field to add
        Returns:
        the newly created Field with default configuration
      • addField

        public SchemaField addField​(SchemaField field)
        Adds field to the schema.
        Parameters:
        field - the schema field
      • removeField

        public void removeField​(java.lang.String fieldName)
        Remove a field from the schema. Does nothing if no field with the given name exists in the schema.
        Parameters:
        fieldName - the name of the field to remove1
      • getField

        public SchemaField getField​(java.lang.String fieldName)
        Gets a field by name, handling dynamic fields if necessary.
        Parameters:
        fieldName - the field name
        Returns:
        null if no field or the dynamic field that matches this name
      • removeUserDefinedField

        public void removeUserDefinedField​(java.lang.String name)
      • getUserDefinedField

        public UserDefinedFieldDef getUserDefinedField​(java.lang.String name)
        Get a user defined field by name (case insensitive).

        Returns null if user defined field does not exist.

      • getUserDefinedFields

        public java.util.List<UserDefinedFieldDef> getUserDefinedFields()
        Get the user defined fields.
      • setUserDefinedFields

        public void setUserDefinedFields​(java.util.List<UserDefinedFieldDef> value)
        Set the user defined fields.
      • getFieldNameByIndex

        public java.lang.String getFieldNameByIndex​(int index)
        Returns the field name based on its index position.
        Parameters:
        index - starting at 0
        Returns:
        the schema field found or null if no schema field at the supplied index
      • getNumberOfFields

        public int getNumberOfFields()
        Retrieves the number of fields in this schema.
        Returns:
        the number of fields
      • getName

        public java.lang.String getName()
      • getDefaultSearchField

        public java.lang.String getDefaultSearchField()
        The default field to search in if a field name is not otherwise specified.
      • setDefaultSearchField

        public void setDefaultSearchField​(java.lang.String dsf)
      • iterator

        public java.util.Iterator<SchemaField> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<SchemaField>
      • containsRealTimeFields

        public boolean containsRealTimeFields()
        Returns true if one or more fields contain real time attributes.
      • containsUserDefinedFields

        public boolean containsUserDefinedFields()
        Returns true if the schema contains user defined fields.
      • containsField

        public boolean containsField​(java.lang.String fieldName)
        Determines if the schema contains a field with this name or name pattern for dynamic fields.
        Parameters:
        fieldName - the field name
        Returns:
        true if the schema has the field with this name
      • containsProperty

        public boolean containsProperty​(java.lang.String property)
        Determine if the field has a given property.
      • setProperty

        public void setProperty​(java.lang.String property,
                                java.lang.String value)
        Sets a property on this schema.
        Parameters:
        property - the property name
        value - the property value
      • getProperty

        public java.lang.String getProperty​(java.lang.String property)
        Get a field property by name.
      • getProperty

        public java.lang.String getProperty​(java.lang.String property,
                                            java.lang.String defaultValue)
        Get a field property by name with a default value.
      • getProperty

        public boolean getProperty​(java.lang.String property,
                                   boolean defaultValue)
        Get a field property by name with a default value.
      • getProperty

        public int getProperty​(java.lang.String property,
                               int defaultValue)
        Get a field property by name with a default value.
      • getProperty

        public long getProperty​(java.lang.String property,
                                long defaultValue)
        Get a field property by name with a default value.
      • getProperty

        public float getProperty​(java.lang.String property,
                                 float defaultValue)
        Get a field property by name with a default value.
      • getProperty

        public double getProperty​(java.lang.String property,
                                  double defaultValue)
        Get a field property by name with a default value.
      • getProperties

        public BaseTypesMap<java.lang.String,​java.lang.String> getProperties()
        Get all the properties associated with this schema.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • isCacheDynamicFieldLookups

        @Deprecated
        public boolean isCacheDynamicFieldLookups()
        Deprecated.
      • setCacheDynamicFieldLookups

        @Deprecated
        public void setCacheDynamicFieldLookups​(boolean value)
        Deprecated.
      • clone

        public Schema clone()
        Overrides:
        clone in class java.lang.Object
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException