IndexSchema (Solr 3.6.2 API)
Keywords: org.apache.solr.schema.IndexSchema class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.solr.schema
Class IndexSchema

    java.lang.Object
      org.apache.solr.schema.IndexSchema

    public final class IndexSchema

extends Object

`IndexSchema` contains information about the valid fields in an index and the types of those fields.

Version:
  $Id: IndexSchema.java 1306155 2012-03-28 04:35:45Z dsmiley $

Field Summary
`static String` | `DEFAULT_SCHEMA_FILE`
`static String` | `LUCENE_MATCH_VERSION_PARAM`

Constructor Summary
`IndexSchema(SolrConfig solrConfig, String name)` Deprecated. Use `IndexSchema(SolrConfig, String, InputSource)` instead.
`IndexSchema(SolrConfig solrConfig, String name, InputSource is)` Constructs a schema using the specified resource name and stream.

Method Summary
`Analyzer` | `getAnalyzer()` Returns the Analyzer used when indexing documents for this index
`SchemaField[]` | `getCopyFields(String sourceField)` Deprecated. Use `getCopyFieldsList(String)` instead.
`List<CopyField>` | `getCopyFieldsList(String sourceField)` Get all copy fields for a specified source field, both static and dynamic ones.
`SchemaField[]` | `getCopySources(String destField)` Get all copy fields, both the static and the dynamic ones.
`String` | `getDefaultSearchFieldName()` Name of the default search field specified in the schema file
`SchemaField[]` | `getDynamicFieldPrototypes()`
`FieldType` | `getDynamicFieldType(String fieldName)` Returns the FieldType of the best matching dynamic field for the specified field name
`String` | `getDynamicPattern(String fieldName)`
`SchemaField` | `getField(String fieldName)` Returns the SchemaField that should be used for the specified field name
`SchemaField` | `getFieldOrNull(String fieldName)` Returns the SchemaField that should be used for the specified field name, or null if none exists.
`Map<String,SchemaField>` | `getFields()` Provides direct access to the Map containing all explicit (ie: non-dynamic) fields in the index, keyed on field name.
`List<SchemaField>` | `getFieldsWithDefaultValue()` Provides direct access to the List containing all fields with a default value
`FieldType` | `getFieldType(String fieldName)` Returns the FieldType for the specified field name.
`FieldType` | `getFieldTypeByName(String fieldTypeName)` Given the name of a `FieldType` (not to be confused with `getFieldType(String)` which takes in the name of a field), return the `FieldType`.
`FieldType` | `getFieldTypeNoEx(String fieldName)` Returns the FieldType for the specified field name.
`Map<String,FieldType>` | `getFieldTypes()` Provides direct access to the Map containing all Field Types in the index, keyed on field type name.
`InputStream` | `getInputStream()` Deprecated. Use `getSolrConfig()` and open a resource input stream for `getResourceName()` instead.
`String` | `getName()` Deprecated. Use `getSchemaName()` instead.
`Analyzer` | `getQueryAnalyzer()` Returns the Analyzer used when searching this index
`String` | `getQueryParserDefaultOperator()` Deprecated. use getSolrQueryParser().getDefaultOperator()
`Collection<SchemaField>` | `getRequiredFields()` Provides direct access to the List containing all required fields.
`SolrResourceLoader` | `getResourceLoader()`
`String` | `getResourceName()` Gets the name of the resource used to instantiate this schema.
`String` | `getSchemaFile()` Deprecated. Use `getResourceName()` instead.
`String` | `getSchemaName()` Gets the name of the schema as specified in the schema resource.
`Similarity` | `getSimilarity()` Returns the Similarity used for this index
`SimilarityFactory` | `getSimilarityFactory()` Returns the SimilarityFactory used for this index
`SolrConfig` | `getSolrConfig()` Deprecated. -- get access to SolrConfig some other way...
`SolrQueryParser` | `getSolrQueryParser(String defaultField)` Deprecated.
`SchemaField` | `getUniqueKeyField()` Unique Key field specified in the schema file
`Fieldable` | `getUniqueKeyField(Document doc)` The raw (field type encoded) value of the Unique Key field for the specified Document
`boolean` | `hasExplicitField(String fieldName)` Does the schema have the specified field defined explicitly, i.e.
`boolean` | `isCopyFieldTarget(SchemaField f)` Check if a field is used as the destination of a copyField operation
`boolean` | `isDynamicField(String fieldName)` Is the specified field dynamic or not.
`String` | `printableUniqueKey(Document doc)` The printable value of the Unique Key field for the specified Document
`void` | `refreshAnalyzers()` This will re-create the Analyzers.
`void` | `registerCopyField(String source, String dest)`
`void` | `registerCopyField(String source, String dest, int maxChars)` NOTE: this function is not thread safe.
`void` | `registerDynamicField(SchemaField... f)` Register one or more new Dynamic Field with the Schema.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_SCHEMA_FILE

    public static final String DEFAULT_SCHEMA_FILE

See Also:
  Constant Field Values

### LUCENE_MATCH_VERSION_PARAM

    public static final String LUCENE_MATCH_VERSION_PARAM

See Also:
  Constant Field Values

Constructor Detail

### IndexSchema

    @Deprecated
    public IndexSchema(SolrConfig solrConfig,
                                  String name)

  Deprecated. Use `IndexSchema(SolrConfig, String, InputSource)` instead.

  Constructs a schema using the specified file name using the normal Config path directory searching rules.

  See Also:
    `Config.openResource(java.lang.String)`

### IndexSchema

    public IndexSchema(SolrConfig solrConfig,
                       String name,
                       InputSource is)

  Constructs a schema using the specified resource name and stream. If the is stream is null, the resource loader will load the schema resource by name.

  See Also:
    `By default, this follows the normal config path directory searching rules.`, `SolrResourceLoader.openResource(java.lang.String)`

Method Detail

### getSolrConfig

    @Deprecated
    public SolrConfig getSolrConfig()

  Deprecated. -- get access to SolrConfig some other way...

### getResourceLoader

    public SolrResourceLoader getResourceLoader()

  Since:
    solr 1.4

### getResourceName

    public String getResourceName()

  Gets the name of the resource used to instantiate this schema.

### getSchemaName

    public String getSchemaName()

  Gets the name of the schema as specified in the schema resource.

### getInputStream

    @Deprecated
    public InputStream getInputStream()

  Deprecated. Use `getSolrConfig()` and open a resource input stream for `getResourceName()` instead.

  Direct access to the InputStream for the schemaFile used by this instance.

  See Also:
    `Config.openResource(java.lang.String)`

### getSchemaFile

    @Deprecated
    public String getSchemaFile()

  Deprecated. Use `getResourceName()` instead.

  Gets the name of the schema file.

### getName

    @Deprecated
    public String getName()

  Deprecated. Use `getSchemaName()` instead.

  The Name of this schema (as specified in the schema file)

### getFields

    public Map<String,SchemaField> getFields()

  Provides direct access to the Map containing all explicit (ie: non-dynamic) fields in the index, keyed on field name.

  Modifying this Map (or any item in it) will affect the real schema

  NOTE: this function is not thread safe. However, it is safe to use within the standard `inform( SolrCore core )` function for `SolrCoreAware` classes. Outside `inform`, this could potentially throw a ConcurrentModificationException

### getFieldTypes

    public Map<String,FieldType> getFieldTypes()

  Provides direct access to the Map containing all Field Types in the index, keyed on field type name.

  Modifying this Map (or any item in it) will affect the real schema. However if you make any modifications, be sure to call `refreshAnalyzers()` to update the Analyzers for the registered fields.

  NOTE: this function is not thread safe. However, it is safe to use within the standard `inform( SolrCore core )` function for `SolrCoreAware` classes. Outside `inform`, this could potentially throw a ConcurrentModificationException

### getFieldsWithDefaultValue

    public List<SchemaField> getFieldsWithDefaultValue()

  Provides direct access to the List containing all fields with a default value

### getRequiredFields

    public Collection<SchemaField> getRequiredFields()

  Provides direct access to the List containing all required fields. This list contains all fields with default values.

### getSimilarity

    public Similarity getSimilarity()

  Returns the Similarity used for this index

### getSimilarityFactory

    public SimilarityFactory getSimilarityFactory()

  Returns the SimilarityFactory used for this index

### getAnalyzer

    public Analyzer getAnalyzer()

  Returns the Analyzer used when indexing documents for this index

  This Analyzer is field (and dynamic field) name aware, and delegates to a field specific Analyzer based on the field type.

### getQueryAnalyzer

    public Analyzer getQueryAnalyzer()

  Returns the Analyzer used when searching this index

  This Analyzer is field (and dynamic field) name aware, and delegates to a field specific Analyzer based on the field type.

### getSolrQueryParser

    @Deprecated
    public SolrQueryParser getSolrQueryParser(String defaultField)

  Deprecated.

  A SolrQueryParser linked to this IndexSchema for field datatype information, and populated with default options from the <solrQueryParser> configuration for this IndexSchema.

  Parameters:
    `defaultField` - if non-null overrides the schema default

### getDefaultSearchFieldName

    public String getDefaultSearchFieldName()

  Name of the default search field specified in the schema file

### getQueryParserDefaultOperator

    @Deprecated
    public String getQueryParserDefaultOperator()

  Deprecated. use getSolrQueryParser().getDefaultOperator()

  default operator ("AND" or "OR") for QueryParser

### getUniqueKeyField

    public SchemaField getUniqueKeyField()

  Unique Key field specified in the schema file

  Returns:
    null if this schema has no unique key field

### getUniqueKeyField

    public Fieldable getUniqueKeyField(Document doc)

  The raw (field type encoded) value of the Unique Key field for the specified Document

  Returns:
    null if this schema has no unique key field
  See Also:
    `printableUniqueKey(org.apache.lucene.document.Document)`

### printableUniqueKey

    public String printableUniqueKey(Document doc)

  The printable value of the Unique Key field for the specified Document

  Returns:
    null if this schema has no unique key field

### refreshAnalyzers

    public void refreshAnalyzers()

  This will re-create the Analyzers. If you make any modifications to the Field map (`getFields()`, this function is required to synch the internally cached field analyzers.

  Since:
    solr 1.3

### registerDynamicField

    public void registerDynamicField(SchemaField... f)

  Register one or more new Dynamic Field with the Schema.

  Parameters:
    `f` - The `SchemaField`

### registerCopyField

    public void registerCopyField(String source,
                                  String dest)

### registerCopyField

    public void registerCopyField(String source,
                                  String dest,
                                  int maxChars)

  NOTE: this function is not thread safe. However, it is safe to use within the standard `inform( SolrCore core )` function for `SolrCoreAware` classes. Outside `inform`, this could potentially throw a ConcurrentModificationException

  See Also:
    `SolrCoreAware`

### getDynamicFieldPrototypes

    public SchemaField[] getDynamicFieldPrototypes()

### getDynamicPattern

    public String getDynamicPattern(String fieldName)

### hasExplicitField

    public boolean hasExplicitField(String fieldName)

  Does the schema have the specified field defined explicitly, i.e. not as a result of a copyField declaration with a wildcard? We consider it explicitly defined if it matches a field or dynamicField declaration.

  Parameters:
    `fieldName` -
  Returns:
    true if explicitly declared in the schema.

### isDynamicField

    public boolean isDynamicField(String fieldName)

  Is the specified field dynamic or not.

  Parameters:
    `fieldName` -
  Returns:
    true if the specified field is dynamic

### getFieldOrNull

    public SchemaField getFieldOrNull(String fieldName)

  Returns the SchemaField that should be used for the specified field name, or null if none exists.

  Parameters:
    `fieldName` - may be an explicitly defined field or a name that matches a dynamic field.
  Returns:
    The `SchemaField`
  See Also:
    `getFieldType(java.lang.String)`, `getField(String)`

### getField

    public SchemaField getField(String fieldName)

  Returns the SchemaField that should be used for the specified field name

  Parameters:
    `fieldName` - may be an explicitly defined field or a name that matches a dynamic field.
  Returns:
    The `SchemaField`
  Throws:
    `SolrException` - if no such field exists
  See Also:
    `getFieldType(java.lang.String)`, `getFieldOrNull(String)`

### getFieldType

    public FieldType getFieldType(String fieldName)

  Returns the FieldType for the specified field name.

  This method exists because it can be more efficient then `getField(java.lang.String)` for dynamic fields if a full SchemaField isn't needed.

  Parameters:
    `fieldName` - may be an explicitly created field, or a name that excercies a dynamic field.
  Throws:
    `SolrException` - if no such field exists
  See Also:
    `getField(String)`, `getFieldTypeNoEx(java.lang.String)`

### getFieldTypeByName

    public FieldType getFieldTypeByName(String fieldTypeName)

  Given the name of a `FieldType` (not to be confused with `getFieldType(String)` which takes in the name of a field), return the `FieldType`.

  Parameters:
    `fieldTypeName` - The name of the `FieldType`
  Returns:
    The `FieldType` or null.

### getFieldTypeNoEx

    public FieldType getFieldTypeNoEx(String fieldName)

  Returns the FieldType for the specified field name.

  This method exists because it can be more efficient then `getField(java.lang.String)` for dynamic fields if a full SchemaField isn't needed.

  Parameters:
    `fieldName` - may be an explicitly created field, or a name that excercies a dynamic field.
  Returns:
    null if field is not defined.
  See Also:
    `getField(String)`, `getFieldTypeNoEx(java.lang.String)`

### getDynamicFieldType

    public FieldType getDynamicFieldType(String fieldName)

  Returns the FieldType of the best matching dynamic field for the specified field name

  Parameters:
    `fieldName` - may be an explicitly created field, or a name that excercies a dynamic field.
  Throws:
    `SolrException` - if no such field exists
  See Also:
    `getField(String)`, `getFieldTypeNoEx(java.lang.String)`

### getCopySources

    public SchemaField[] getCopySources(String destField)

  Get all copy fields, both the static and the dynamic ones.

  Parameters:
    `destField` -
  Returns:
    Array of fields copied into this field

### getCopyFields

    @Deprecated
    public SchemaField[] getCopyFields(String sourceField)

  Deprecated. Use `getCopyFieldsList(String)` instead.

  Get all copy fields, both the static and the dynamic ones.

  Parameters:
    `sourceField` -
  Returns:
    Array of fields to copy to.

### getCopyFieldsList

    public List<CopyField> getCopyFieldsList(String sourceField)

  Get all copy fields for a specified source field, both static and dynamic ones.

  Parameters:
    `sourceField` -
  Returns:
    List of CopyFields to copy to.
  Since:
    solr 1.4

### isCopyFieldTarget

    public boolean isCopyFieldTarget(SchemaField f)

  Check if a field is used as the destination of a copyField operation

  Since:
    solr 1.3

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD