org.apache.solr.schema
Class IndexSchema

java.lang.Object
  extended by 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 542679 2007-05-29 22:28:21Z ryan $
Author:
yonik

Constructor Summary
IndexSchema(String schemaFile)
          Constructs a schema using the specified file name using the normal Config path directory searching rules.
 
Method Summary
 Analyzer getAnalyzer()
          Returns the Analyzer used when indexing documents for this index
 SchemaField[] getCopyFields(String sourceField)
          Get all copy fields, both the static and the dynamic ones.
 String getDefaultSearchFieldName()
          Deprecated. use getSolrQueryParser().getField()
 FieldType getDynamicFieldType(String fieldName)
          Returns the FieldType of the best matching dynamic field for the specified field name
 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 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 fild type name.
 InputStream getInputStream()
          Direct acess to the InputStream for the schemaFile used by this instance.
 String getName()
          The Name of this schema (as specified in the schema file)
 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.
 Similarity getSimilarity()
          Returns the Similarity used for this index
 SolrQueryParser getSolrQueryParser(String defaultField)
          A SolrQueryParser linked to this IndexSchema for field datatype information, and populated with default options from the <solrQueryParser> configuration for this IndexSchema.
 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.
 String printableUniqueKey(Document doc)
          The printable value of the Unique Key field for the specified Document
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexSchema

public IndexSchema(String schemaFile)
Constructs a schema using the specified file name using the normal Config path directory searching rules.

See Also:
Config.openResource(java.lang.String)
Method Detail

getInputStream

public InputStream getInputStream()
Direct acess to the InputStream for the schemaFile used by this instance.

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

getName

public String getName()
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


getFieldTypes

public Map<String,FieldType> getFieldTypes()
Provides direct access to the Map containing all Field Types in the index, keyed on fild type name.

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


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


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

public SolrQueryParser getSolrQueryParser(String defaultField)
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()
Deprecated. use getSolrQueryParser().getField()

Name of the default search field specified in the schema file


getQueryParserDefaultOperator

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

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.

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.
See Also:
getFieldType(java.lang.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.
Throws:
SolrException - if no such field exists
See Also:
getFieldType(java.lang.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)

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)

getCopyFields

public SchemaField[] getCopyFields(String sourceField)
Get all copy fields, both the static and the dynamic ones.

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


Copyright © 2006 - 2009 The Apache Software Foundation