Package com.yahoo.schema
Class Schema
java.lang.Object
com.yahoo.schema.Schema
- All Implemented Interfaces:
ImmutableSchema
- Direct Known Subclasses:
DocumentOnlySchema
A schema contains a document type, additional fields, rank profiles and document summaries.
- Author:
- bratseth
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSchema(com.yahoo.config.application.api.ApplicationPackage applicationPackage, com.yahoo.config.application.api.FileRegistry fileRegistry, com.yahoo.config.application.api.DeployLogger deployLogger, com.yahoo.config.model.api.ModelContext.Properties properties) Testing onlySchema(String name, com.yahoo.config.application.api.ApplicationPackage applicationPackage, com.yahoo.config.application.api.FileRegistry fileRegistry, com.yahoo.config.application.api.DeployLogger deployLogger, com.yahoo.config.model.api.ModelContext.Properties properties) Schema(String name, com.yahoo.config.application.api.ApplicationPackage applicationPackage, Optional<String> inherited, com.yahoo.config.application.api.FileRegistry fileRegistry, com.yahoo.config.application.api.DeployLogger deployLogger, com.yahoo.config.model.api.ModelContext.Properties properties) Creates a schema -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidadd(RankProfile.Constant constant) voidaddDocument(SDDocumentType document) Adds a document type which is defined in this search definitionvoidaddExtraField(SDField field) Adds an extra field of this search definition not contained in a documentvoidAdds an explicitly defined index to this search definitionvoidaddSummary(DocumentSummary summary) Adds an explicitly defined summary to this search definitionReturns a list of all the fields of this schema, that is all fields in all documents, in the documents they inherit, and all extra fields.as allConcreteFields, but includes sub-fields for arrays of structs etc.com.yahoo.config.application.api.ApplicationPackageMap<com.yahoo.searchlib.rankingexpression.Reference,RankProfile.Constant> Returns an unmodifiable map of the constants available in this.Map<com.yahoo.searchlib.rankingexpression.Reference,RankProfile.Constant> Returns an unmodifiable map of the constants declared in this.Returns an unmodifiable map of the onnx models declared in this.voidenableRawAsBase64(boolean value) booleanbooleanexistsIndex(String name) Returns a map of the fields defined explicitly in this schema (that is, not including inherited fields).getAttribute(String name) Returns the first occurrence of an attribute having this name, or null if nonegetConcreteField(String name) Returns a field defined in this search definition or one if its documents.com.yahoo.config.application.api.DeployLoggercom.yahoo.config.model.api.ModelContext.PropertiesReturns the document in this search.getDocument(String name) Gets a document from this search definitiongetDocumentField(String name) Returns a field defined in one of the documents of this schema.All explicitly defined indices, both on this schema itself (returned first) and all its fieldsReturns the first explicit instance found of a summary field with this name, or null if not present explicitly in any summary classgetExtraField(String fieldName) Returns a field by name, or null if it is not presentReturns an index, or null if no index with this name has had some explicit settings applied.getName()getRankingExpression(String fileName) Returns the content of a ranking expression fileReturns whether fields should be stemmed by default or not.Summaries defined by fields of this search definition.Returns the summaries defines in this only, not any that are inherited.getSummary(String name) Returns a summary class defined by this search definition, or null if no summary with this name is defined.getSummaryField(String name) Returns the first explicit instance found of a summary field with this name, or null if not present (implicitly or explicitly) in any summary class.getSummaryFields(ImmutableSDField field) Returns all summary fields, of all document summaries, which has the given field as source.Returns one summary field for each summary field name.booleanReturns true if the document has been added.inthashCode()booleanbooleanReturns true if this only defines a document type, not a full schemabooleanReturns true if 'raw' fields shall be presented as base64 in summary Note that this is temporary and will disappear on Vespa 8 as it will become default, and only option.static booleanisReservedName(String name) Returns true if the given field name is a reserved nameReturns an unmodifiable map of the onnx models available in this.voidsetImportedFields(ImportedFields importedFields) voidsetInheritedSchema(Schema value) protected voidvoidsetOwner(Application owner) Assigns the owner of thisvoidsetStemming(Stemming stemming) Sets the stemming default of fields.toString()voidvalidate(com.yahoo.config.application.api.DeployLogger logger) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.yahoo.schema.ImmutableSchema
allFields
-
Constructor Details
-
Schema
Testing only -
Schema
public Schema(String name, com.yahoo.config.application.api.ApplicationPackage applicationPackage, com.yahoo.config.application.api.FileRegistry fileRegistry, com.yahoo.config.application.api.DeployLogger deployLogger, com.yahoo.config.model.api.ModelContext.Properties properties) -
Schema
public Schema(String name, com.yahoo.config.application.api.ApplicationPackage applicationPackage, Optional<String> inherited, com.yahoo.config.application.api.FileRegistry fileRegistry, com.yahoo.config.application.api.DeployLogger deployLogger, com.yahoo.config.model.api.ModelContext.Properties properties) Creates a schema- Parameters:
name- of the schemainherited- the schema this inherits, if any
-
Schema
protected Schema(com.yahoo.config.application.api.ApplicationPackage applicationPackage, com.yahoo.config.application.api.FileRegistry fileRegistry, com.yahoo.config.application.api.DeployLogger deployLogger, com.yahoo.config.model.api.ModelContext.Properties properties)
-
-
Method Details
-
setOwner
Assigns the owner of this- Throws:
IllegalStateException- if an owner is already assigned
-
setName
-
getName
- Specified by:
getNamein interfaceImmutableSchema
-
isDocumentsOnly
public boolean isDocumentsOnly()Returns true if this only defines a document type, not a full schema -
inherited
- Specified by:
inheritedin interfaceImmutableSchema
-
isRawAsBase64
public boolean isRawAsBase64()Returns true if 'raw' fields shall be presented as base64 in summary Note that this is temporary and will disappear on Vespa 8 as it will become default, and only option.- Returns:
- true if raw shall be encoded as base64 in summary
-
enableRawAsBase64
public void enableRawAsBase64(boolean value) -
setStemming
Sets the stemming default of fields. Default is ALL- Parameters:
stemming- set default stemming for this schema- Throws:
NullPointerException- if this is attempted set to null
-
getStemming
Returns whether fields should be stemmed by default or not. Default is BEST. This is never null. -
addDocument
Adds a document type which is defined in this search definition- Parameters:
document- the document type to add
-
rankExpressionFiles
- Specified by:
rankExpressionFilesin interfaceImmutableSchema
-
add
-
declaredConstants
public Map<com.yahoo.searchlib.rankingexpression.Reference,RankProfile.Constant> declaredConstants()Returns an unmodifiable map of the constants declared in this. -
constants
Returns an unmodifiable map of the constants available in this.- Specified by:
constantsin interfaceImmutableSchema
-
add
-
declaredOnnxModels
Returns an unmodifiable map of the onnx models declared in this. -
onnxModels
Returns an unmodifiable map of the onnx models available in this.- Specified by:
onnxModelsin interfaceImmutableSchema
-
temporaryImportedFields
-
importedFields
-
setImportedFields
-
allImportedFields
- Specified by:
allImportedFieldsin interfaceImmutableSchema
-
getField
- Specified by:
getFieldin interfaceImmutableSchema
-
fieldsOfThis
Returns a map of the fields defined explicitly in this schema (that is, not including inherited fields). -
allFieldsList
- Specified by:
allFieldsListin interfaceImmutableSchema
-
getDocument
Gets a document from this search definition- Parameters:
name- the name of the document to return- Returns:
- the contained or used document type, or null if there is no such document
-
hasDocument
public boolean hasDocument()Returns true if the document has been added. -
getDocument
Returns the document in this search.- Specified by:
getDocumentin interfaceImmutableSchema
-
allConcreteFields
Returns a list of all the fields of this schema, that is all fields in all documents, in the documents they inherit, and all extra fields. The caller receives ownership to the list - subsequent changes to it will not impact this.- Specified by:
allConcreteFieldsin interfaceImmutableSchema
-
allConcreteFieldsWithSubFields
as allConcreteFields, but includes sub-fields for arrays of structs etc. -
getRankingExpression
Returns the content of a ranking expression file- Specified by:
getRankingExpressionin interfaceImmutableSchema
-
application
-
applicationPackage
public com.yahoo.config.application.api.ApplicationPackage applicationPackage()- Specified by:
applicationPackagein interfaceImmutableSchema
-
getDeployLogger
public com.yahoo.config.application.api.DeployLogger getDeployLogger()- Specified by:
getDeployLoggerin interfaceImmutableSchema
-
getDeployProperties
public com.yahoo.config.model.api.ModelContext.Properties getDeployProperties()- Specified by:
getDeployPropertiesin interfaceImmutableSchema
-
getConcreteField
Returns a field defined in this search definition or one if its documents. Fields in this search definition takes precedence over document fields having the same name- Specified by:
getConcreteFieldin interfaceImmutableSchema- Parameters:
name- of the field- Returns:
- the SDField representing the field
-
getDocumentField
Returns a field defined in one of the documents of this schema. This does not include the extra fields defined outside the document (those accessible through the getExtraField() method).- Parameters:
name- the name of the field to return- Returns:
- the named field, or null if not found
-
addExtraField
Adds an extra field of this search definition not contained in a document- Parameters:
field- to add to the schemas list of external fields
-
extraFieldList
-
allExtraFields
-
getExtraField
Returns a field by name, or null if it is not present- Parameters:
fieldName- the name of the external field to get- Returns:
- the SDField of this name
-
addIndex
Adds an explicitly defined index to this search definition- Parameters:
index- the index to add
-
getIndex
Returns an index, or null if no index with this name has had some explicit settings applied. Even if this returns null, the index may be implicitly defined by an indexing statement. This will return the index whether it is defined on this schema or on one of its fields.- Specified by:
getIndexin interfaceImmutableSchema- Parameters:
name- the name of the index to get- Returns:
- the index requested
-
existsIndex
-
getExplicitIndices
All explicitly defined indices, both on this schema itself (returned first) and all its fields- Specified by:
getExplicitIndicesin interfaceImmutableSchema
-
addSummary
Adds an explicitly defined summary to this search definition -
getSummary
Returns a summary class defined by this search definition, or null if no summary with this name is defined. The default summary, named "default" is always present. -
getSummaryField
Returns the first explicit instance found of a summary field with this name, or null if not present (implicitly or explicitly) in any summary class. -
getExplicitSummaryField
Returns the first explicit instance found of a summary field with this name, or null if not present explicitly in any summary class- Parameters:
name- the name of the explicit summary field to get.- Returns:
- the SummaryField found.
-
getSummaries
Summaries defined by fields of this search definition. The default summary, named "default", is always the first one in the returned iterator. -
getSummariesInThis
Returns the summaries defines in this only, not any that are inherited. -
getSummaryFields
Returns all summary fields, of all document summaries, which has the given field as source. The list becomes owned by the receiver.- Specified by:
getSummaryFieldsin interfaceImmutableSchema- Parameters:
field- the source field- Returns:
- the list of summary fields found
-
getUniqueNamedSummaryFields
Returns one summary field for each summary field name. If there are multiple summary fields with the same name, the last one will be used. Multiple fields of the same name should all have the same content in a valid search definition, except from the destination set. So this method can be used for all summary handling except processing the destination set. The map becomes owned by the receiver. -
getAttribute
Returns the first occurrence of an attribute having this name, or null if none -
equals
-
hashCode
public int hashCode() -
toString
-
isAccessingDiskSummary
-
fieldSets
-
setInheritedSchema
-
validate
public void validate(com.yahoo.config.application.api.DeployLogger logger) -
isReservedName
Returns true if the given field name is a reserved name
-