public final class IndexSchema
extends java.lang.Object
IndexSchema
contains information about the valid fields in an index
and the types of those fields.Modifier and Type | Class and Description |
---|---|
(package private) static class |
IndexSchema.DynamicCopy |
(package private) static class |
IndexSchema.DynamicDestCopy |
(package private) static class |
IndexSchema.DynamicField |
(package private) static class |
IndexSchema.DynamicReplacement |
private static class |
IndexSchema.MultiTermChainBuilder |
private class |
IndexSchema.SolrIndexAnalyzer |
private class |
IndexSchema.SolrQueryAnalyzer |
Modifier and Type | Field and Description |
---|---|
private org.apache.lucene.analysis.Analyzer |
analyzer |
private java.util.Map<java.lang.String,java.util.List<CopyField>> |
copyFieldsMap |
private java.util.Map<SchemaField,java.lang.Integer> |
copyFieldTargetCounts
keys are all fields copied to, count is num of copyField
directives that target them.
|
static java.lang.String |
DEFAULT_SCHEMA_FILE |
private java.lang.String |
defaultSearchFieldName |
private IndexSchema.DynamicCopy[] |
dynamicCopyFields |
private IndexSchema.DynamicField[] |
dynamicFields |
private java.util.HashMap<java.lang.String,SchemaField> |
fields |
private java.util.List<SchemaField> |
fieldsWithDefaultValue |
private java.util.HashMap<java.lang.String,FieldType> |
fieldTypes |
private SolrResourceLoader |
loader |
(package private) static org.slf4j.Logger |
log |
static java.lang.String |
LUCENE_MATCH_VERSION_PARAM |
private java.lang.String |
name |
private org.apache.lucene.analysis.Analyzer |
queryAnalyzer |
private java.lang.String |
queryParserDefaultOperator |
private java.util.Collection<SchemaField> |
requiredFields |
private java.lang.String |
resourceName |
private SimilarityFactory |
similarityFactory |
private SolrConfig |
solrConfig |
private SchemaField |
uniqueKeyField |
private java.lang.String |
uniqueKeyFieldName |
private FieldType |
uniqueKeyFieldType |
private float |
version |
Constructor and Description |
---|
IndexSchema(SolrConfig solrConfig,
java.lang.String name)
Deprecated.
Use
IndexSchema(SolrConfig, String, InputSource) instead. |
IndexSchema(SolrConfig solrConfig,
java.lang.String name,
org.xml.sax.InputSource is)
Constructs a schema using the specified resource name and stream.
|
Modifier and Type | Method and Description |
---|---|
private void |
addDynamicField(java.util.List<IndexSchema.DynamicField> dFields,
SchemaField f) |
private void |
addDynamicFieldNoDupCheck(java.util.List<IndexSchema.DynamicField> dFields,
SchemaField f) |
private static java.lang.Object[] |
append(java.lang.Object[] orig,
java.lang.Object item) |
private org.apache.lucene.analysis.Analyzer |
constructMultiTermAnalyzer(org.apache.lucene.analysis.Analyzer queryAnalyzer) |
private FieldType |
dynFieldType(java.lang.String fieldName) |
org.apache.lucene.analysis.Analyzer |
getAnalyzer()
Returns the Analyzer used when indexing documents for this index
|
SchemaField[] |
getCopyFields(java.lang.String sourceField)
Deprecated.
Use
getCopyFieldsList(String) instead. |
java.util.List<CopyField> |
getCopyFieldsList(java.lang.String sourceField)
Get all copy fields for a specified source field, both static
and dynamic ones.
|
SchemaField[] |
getCopySources(java.lang.String destField)
Get all copy fields, both the static and the dynamic ones.
|
java.lang.String |
getDefaultSearchFieldName()
Name of the default search field specified in the schema file
|
SchemaField[] |
getDynamicFieldPrototypes() |
FieldType |
getDynamicFieldType(java.lang.String fieldName)
Returns the FieldType of the best matching dynamic field for
the specified field name
|
java.lang.String |
getDynamicPattern(java.lang.String fieldName) |
SchemaField |
getField(java.lang.String fieldName)
Returns the SchemaField that should be used for the specified field name
|
SchemaField |
getFieldOrNull(java.lang.String fieldName)
Returns the SchemaField that should be used for the specified field name, or
null if none exists.
|
java.util.Map<java.lang.String,SchemaField> |
getFields()
Provides direct access to the Map containing all explicit
(ie: non-dynamic) fields in the index, keyed on field name.
|
java.util.List<SchemaField> |
getFieldsWithDefaultValue()
Provides direct access to the List containing all fields with a default value
|
FieldType |
getFieldType(java.lang.String fieldName)
Returns the FieldType for the specified field name.
|
FieldType |
getFieldTypeByName(java.lang.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(java.lang.String fieldName)
Returns the FieldType for the specified field name.
|
java.util.Map<java.lang.String,FieldType> |
getFieldTypes()
Provides direct access to the Map containing all Field Types
in the index, keyed on field type name.
|
private SchemaField |
getIndexedField(java.lang.String fname) |
java.io.InputStream |
getInputStream()
Deprecated.
Use
getSolrConfig() and open a resource input stream
for getResourceName() instead. |
java.lang.String |
getName()
Deprecated.
Use
getSchemaName() instead. |
org.apache.lucene.analysis.Analyzer |
getQueryAnalyzer()
Returns the Analyzer used when searching this index
|
java.lang.String |
getQueryParserDefaultOperator()
Deprecated.
use getSolrQueryParser().getDefaultOperator()
|
java.util.Collection<SchemaField> |
getRequiredFields()
Provides direct access to the List containing all required fields.
|
SolrResourceLoader |
getResourceLoader() |
java.lang.String |
getResourceName()
Gets the name of the resource used to instantiate this schema.
|
java.lang.String |
getSchemaFile()
Deprecated.
Use
getResourceName() instead. |
java.lang.String |
getSchemaName()
Gets the name of the schema as specified in the schema resource.
|
org.apache.lucene.search.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(java.lang.String defaultField)
Deprecated.
|
SchemaField |
getUniqueKeyField()
Unique Key field specified in the schema file
|
org.apache.lucene.document.Fieldable |
getUniqueKeyField(org.apache.lucene.document.Document doc)
The raw (field type encoded) value of the Unique Key field for
the specified Document
|
(package private) float |
getVersion() |
boolean |
hasExplicitField(java.lang.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
|
private boolean |
isDuplicateDynField(java.util.List<IndexSchema.DynamicField> dFields,
SchemaField f) |
boolean |
isDynamicField(java.lang.String fieldName)
Is the specified field dynamic or not.
|
private static boolean |
isWildCard(java.lang.String name)
Is the given field name a wildcard? I.e.
|
java.lang.String |
printableUniqueKey(org.apache.lucene.document.Document doc)
The printable value of the Unique Key field for
the specified Document
|
private org.apache.lucene.analysis.Analyzer |
readAnalyzer(org.w3c.dom.Node node) |
private void |
readSchema(org.xml.sax.InputSource is) |
void |
refreshAnalyzers()
This will re-create the Analyzers.
|
void |
registerCopyField(java.lang.String source,
java.lang.String dest) |
void |
registerCopyField(java.lang.String source,
java.lang.String dest,
int maxChars)
NOTE: this function is not thread safe.
|
private void |
registerDynamicCopyField(IndexSchema.DynamicCopy dcopy) |
void |
registerDynamicField(SchemaField... f)
Register one or more new Dynamic Field with the Schema.
|
public static final java.lang.String DEFAULT_SCHEMA_FILE
public static final java.lang.String LUCENE_MATCH_VERSION_PARAM
static final org.slf4j.Logger log
private final SolrConfig solrConfig
private final java.lang.String resourceName
private java.lang.String name
private float version
private final SolrResourceLoader loader
private final java.util.HashMap<java.lang.String,SchemaField> fields
private final java.util.HashMap<java.lang.String,FieldType> fieldTypes
private final java.util.List<SchemaField> fieldsWithDefaultValue
private final java.util.Collection<SchemaField> requiredFields
private IndexSchema.DynamicField[] dynamicFields
private org.apache.lucene.analysis.Analyzer analyzer
private org.apache.lucene.analysis.Analyzer queryAnalyzer
private java.lang.String defaultSearchFieldName
private java.lang.String queryParserDefaultOperator
private final java.util.Map<java.lang.String,java.util.List<CopyField>> copyFieldsMap
private IndexSchema.DynamicCopy[] dynamicCopyFields
private java.util.Map<SchemaField,java.lang.Integer> copyFieldTargetCounts
private SimilarityFactory similarityFactory
private SchemaField uniqueKeyField
private java.lang.String uniqueKeyFieldName
private FieldType uniqueKeyFieldType
@Deprecated public IndexSchema(SolrConfig solrConfig, java.lang.String name)
IndexSchema(SolrConfig, String, InputSource)
instead.Config.openResource(java.lang.String)
public IndexSchema(SolrConfig solrConfig, java.lang.String name, org.xml.sax.InputSource is)
@Deprecated public SolrConfig getSolrConfig()
public SolrResourceLoader getResourceLoader()
public java.lang.String getResourceName()
public java.lang.String getSchemaName()
float getVersion()
@Deprecated public java.io.InputStream getInputStream()
getSolrConfig()
and open a resource input stream
for getResourceName()
instead.Config.openResource(java.lang.String)
@Deprecated public java.lang.String getSchemaFile()
getResourceName()
instead.@Deprecated public java.lang.String getName()
getSchemaName()
instead.public java.util.Map<java.lang.String,SchemaField> getFields()
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
public java.util.Map<java.lang.String,FieldType> getFieldTypes()
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
public java.util.List<SchemaField> getFieldsWithDefaultValue()
public java.util.Collection<SchemaField> getRequiredFields()
public org.apache.lucene.search.Similarity getSimilarity()
public SimilarityFactory getSimilarityFactory()
public org.apache.lucene.analysis.Analyzer getAnalyzer()
This Analyzer is field (and dynamic field) name aware, and delegates to a field specific Analyzer based on the field type.
public org.apache.lucene.analysis.Analyzer getQueryAnalyzer()
This Analyzer is field (and dynamic field) name aware, and delegates to a field specific Analyzer based on the field type.
@Deprecated public SolrQueryParser getSolrQueryParser(java.lang.String defaultField)
defaultField
- if non-null overrides the schema defaultpublic java.lang.String getDefaultSearchFieldName()
@Deprecated public java.lang.String getQueryParserDefaultOperator()
public SchemaField getUniqueKeyField()
public org.apache.lucene.document.Fieldable getUniqueKeyField(org.apache.lucene.document.Document doc)
printableUniqueKey(org.apache.lucene.document.Document)
public java.lang.String printableUniqueKey(org.apache.lucene.document.Document doc)
private SchemaField getIndexedField(java.lang.String fname)
public void refreshAnalyzers()
getFields()
, this function is required
to synch the internally cached field analyzers.private void readSchema(org.xml.sax.InputSource is)
private void addDynamicField(java.util.List<IndexSchema.DynamicField> dFields, SchemaField f)
private org.apache.lucene.analysis.Analyzer constructMultiTermAnalyzer(org.apache.lucene.analysis.Analyzer queryAnalyzer)
public void registerDynamicField(SchemaField... f)
f
- The SchemaField
private void addDynamicFieldNoDupCheck(java.util.List<IndexSchema.DynamicField> dFields, SchemaField f)
private boolean isDuplicateDynField(java.util.List<IndexSchema.DynamicField> dFields, SchemaField f)
public void registerCopyField(java.lang.String source, java.lang.String dest)
public void registerCopyField(java.lang.String source, java.lang.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
SolrCoreAware
private void registerDynamicCopyField(IndexSchema.DynamicCopy dcopy)
private static java.lang.Object[] append(java.lang.Object[] orig, java.lang.Object item)
private org.apache.lucene.analysis.Analyzer readAnalyzer(org.w3c.dom.Node node) throws javax.xml.xpath.XPathExpressionException
javax.xml.xpath.XPathExpressionException
public SchemaField[] getDynamicFieldPrototypes()
public java.lang.String getDynamicPattern(java.lang.String fieldName)
public boolean hasExplicitField(java.lang.String fieldName)
fieldName
- public boolean isDynamicField(java.lang.String fieldName)
fieldName
- public SchemaField getFieldOrNull(java.lang.String fieldName)
fieldName
- may be an explicitly defined field or a name that
matches a dynamic field.SchemaField
getFieldType(java.lang.String)
,
getField(String)
public SchemaField getField(java.lang.String fieldName)
fieldName
- may be an explicitly defined field or a name that
matches a dynamic field.SchemaField
SolrException
- if no such field existsgetFieldType(java.lang.String)
,
getFieldOrNull(String)
public FieldType getFieldType(java.lang.String fieldName)
This method exists because it can be more efficient then
getField(java.lang.String)
for dynamic fields if a full SchemaField isn't needed.
fieldName
- may be an explicitly created field, or a name that
excercies a dynamic field.SolrException
- if no such field existsgetField(String)
,
getFieldTypeNoEx(java.lang.String)
public FieldType getFieldTypeByName(java.lang.String fieldTypeName)
FieldType
(not to be confused with getFieldType(String)
which
takes in the name of a field), return the FieldType
.public FieldType getFieldTypeNoEx(java.lang.String fieldName)
This method exists because it can be more efficient then
getField(java.lang.String)
for dynamic fields if a full SchemaField isn't needed.
fieldName
- may be an explicitly created field, or a name that
excercies a dynamic field.getField(String)
,
getFieldTypeNoEx(java.lang.String)
public FieldType getDynamicFieldType(java.lang.String fieldName)
fieldName
- may be an explicitly created field, or a name that
excercies a dynamic field.SolrException
- if no such field existsgetField(String)
,
getFieldTypeNoEx(java.lang.String)
private FieldType dynFieldType(java.lang.String fieldName)
public SchemaField[] getCopySources(java.lang.String destField)
destField
- @Deprecated public SchemaField[] getCopyFields(java.lang.String sourceField)
getCopyFieldsList(String)
instead.sourceField
- public java.util.List<CopyField> getCopyFieldsList(java.lang.String sourceField)
sourceField
- public boolean isCopyFieldTarget(SchemaField f)
private static boolean isWildCard(java.lang.String name)
name
-