Package com.yahoo.searchdefinition
Class Schema
- java.lang.Object
-
- com.yahoo.searchdefinition.Schema
-
- All Implemented Interfaces:
ImmutableSchema
- Direct Known Subclasses:
DocumentOnlySchema
public class Schema extends Object implements ImmutableSchema
A schema contains a document type, additional fields, rank profiles and document summaries.- Author:
- bratseth
-
-
Constructor Summary
Constructors Modifier Constructor Description 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)
Schema(String name, com.yahoo.config.application.api.ApplicationPackage applicationPackage)
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Schema
addAnnotation(SDAnnotationType dt)
void
addDocument(SDDocumentType document)
Adds a document type which is defined in this search definitionvoid
addExtraField(SDField field)
Adds an extra field of this search definition not contained in a documentvoid
addIndex(Index index)
Adds an explicitly defined index to this search definitionvoid
addSummary(DocumentSummary summary)
Adds an explicitly defined summary to this search definitionSchema
addType(SDDocumentType dt)
For adding structs defined in document scopeList<SDField>
allConcreteFields()
Returns a list of all the fields of this search definition, that is all fields in all documents, in the documents they inherit, and all extra fields.Collection<SDField>
allExtraFields()
List<ImmutableSDField>
allFieldsList()
Stream<ImmutableSDField>
allImportedFields()
Application
application()
com.yahoo.config.application.api.ApplicationPackage
applicationPackage()
void
enableRawAsBase64(boolean value)
boolean
equals(Object o)
boolean
existsIndex(String name)
Collection<SDField>
extraFieldList()
FieldSets
fieldSets()
Attribute
getAttribute(String name)
Returns the first occurrence of an attribute having this name, or null if noneSDField
getConcreteField(String name)
Returns a field defined in this search definition or one if its documents.com.yahoo.config.application.api.DeployLogger
getDeployLogger()
com.yahoo.config.model.api.ModelContext.Properties
getDeployProperties()
SDDocumentType
getDocument()
SDDocumentType
getDocument(String name)
Gets a document from this search definitionSDField
getDocumentField(String name)
Returns a field defined in one of the documents of this search definition.List<Index>
getExplicitIndices()
All explicitly defined indices, both on this schema itself (returned first) and all its fieldsSummaryField
getExplicitSummaryField(String name)
Returns the first explicit instance found of a summary field with this name, or null if not present explicitly in any summary classSDField
getExtraField(String fieldName)
Returns a field by name, or null if it is not presentImmutableSDField
getField(String name)
Index
getIndex(String name)
Returns an index, or null if no index with this name has had some explicit settings applied.String
getName()
Reader
getRankingExpression(String fileName)
Returns the content of a ranking expression fileStemming
getStemming()
Returns whether fields should be stemmed by default or not.Map<String,DocumentSummary>
getSummaries()
Summaries defined by fields of this search definition.Map<String,DocumentSummary>
getSummariesInThis()
Returns the summaries defines in this only, not any that are inherited.DocumentSummary
getSummary(String name)
Returns a summary class defined by this search definition, or null if no summary with this name is defined.SummaryField
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.Map<String,SummaryField>
getSummaryFields(ImmutableSDField field)
Returns all summary fields, of all document summaries, which has the given field as source.Map<String,SummaryField>
getUniqueNamedSummaryFields()
Returns one summary field for each summary field name.boolean
hasDocument()
int
hashCode()
Optional<ImportedFields>
importedFields()
Optional<Schema>
inherited()
boolean
isAccessingDiskSummary(SummaryField field)
boolean
isDocumentsOnly()
Returns true if this only defines a document type, not a full schemaboolean
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.static boolean
isReservedName(String name)
Returns true if the given field name is a reserved nameOnnxModels
onnxModels()
LargeRankExpressions
rankExpressionFiles()
RankingConstants
rankingConstants()
void
setImportedFields(ImportedFields importedFields)
protected void
setName(String name)
void
setOwner(Application owner)
Assigns the owner of thisvoid
setStemming(Stemming stemming)
Sets the stemming default of fields.Optional<TemporaryImportedFields>
temporaryImportedFields()
String
toString()
void
validate(com.yahoo.config.application.api.DeployLogger logger)
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.yahoo.searchdefinition.ImmutableSchema
allFields
-
-
-
-
Constructor Detail
-
Schema
public Schema(String name, com.yahoo.config.application.api.ApplicationPackage applicationPackage)
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 Detail
-
setOwner
public void setOwner(Application owner)
Assigns the owner of this- Throws:
IllegalStateException
- if an owner is already assigned
-
setName
protected void setName(String name)
-
getName
public String getName()
- Specified by:
getName
in interfaceImmutableSchema
-
isDocumentsOnly
public boolean isDocumentsOnly()
Returns true if this only defines a document type, not a full schema
-
inherited
public Optional<Schema> inherited()
- Specified by:
inherited
in 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
public void setStemming(Stemming stemming)
Sets the stemming default of fields. Default is ALL- Parameters:
stemming
- set default stemming for this searchdefinition- Throws:
NullPointerException
- if this is attempted set to null
-
getStemming
public Stemming getStemming()
Returns whether fields should be stemmed by default or not. Default is BEST. This is never null.
-
addDocument
public void addDocument(SDDocumentType document)
Adds a document type which is defined in this search definition- Parameters:
document
- the document type to add
-
rankExpressionFiles
public LargeRankExpressions rankExpressionFiles()
- Specified by:
rankExpressionFiles
in interfaceImmutableSchema
-
rankingConstants
public RankingConstants rankingConstants()
- Specified by:
rankingConstants
in interfaceImmutableSchema
-
onnxModels
public OnnxModels onnxModels()
- Specified by:
onnxModels
in interfaceImmutableSchema
-
temporaryImportedFields
public Optional<TemporaryImportedFields> temporaryImportedFields()
-
importedFields
public Optional<ImportedFields> importedFields()
-
setImportedFields
public void setImportedFields(ImportedFields importedFields)
-
allImportedFields
public Stream<ImmutableSDField> allImportedFields()
- Specified by:
allImportedFields
in interfaceImmutableSchema
-
getField
public ImmutableSDField getField(String name)
- Specified by:
getField
in interfaceImmutableSchema
-
allFieldsList
public List<ImmutableSDField> allFieldsList()
- Specified by:
allFieldsList
in interfaceImmutableSchema
-
getDocument
public SDDocumentType getDocument(String name)
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
public SDDocumentType getDocument()
- Specified by:
getDocument
in interfaceImmutableSchema
- Returns:
- The document in this search.
-
allConcreteFields
public List<SDField> allConcreteFields()
Returns a list of all the fields of this search definition, 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:
allConcreteFields
in interfaceImmutableSchema
-
getRankingExpression
public Reader getRankingExpression(String fileName)
Returns the content of a ranking expression file- Specified by:
getRankingExpression
in interfaceImmutableSchema
-
application
public Application application()
-
applicationPackage
public com.yahoo.config.application.api.ApplicationPackage applicationPackage()
- Specified by:
applicationPackage
in interfaceImmutableSchema
-
getDeployLogger
public com.yahoo.config.application.api.DeployLogger getDeployLogger()
- Specified by:
getDeployLogger
in interfaceImmutableSchema
-
getDeployProperties
public com.yahoo.config.model.api.ModelContext.Properties getDeployProperties()
- Specified by:
getDeployProperties
in interfaceImmutableSchema
-
getConcreteField
public SDField getConcreteField(String name)
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:
getConcreteField
in interfaceImmutableSchema
- Parameters:
name
- of the field- Returns:
- the SDField representing the field
-
getDocumentField
public SDField getDocumentField(String name)
Returns a field defined in one of the documents of this search definition. 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
public void addExtraField(SDField field)
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
public Collection<SDField> extraFieldList()
-
allExtraFields
public Collection<SDField> allExtraFields()
-
getExtraField
public SDField getExtraField(String fieldName)
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
public void addIndex(Index index)
Adds an explicitly defined index to this search definition- Parameters:
index
- the index to add
-
getIndex
public Index getIndex(String name)
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:
getIndex
in interfaceImmutableSchema
- Parameters:
name
- the name of the index to get- Returns:
- the index requested
-
existsIndex
public boolean existsIndex(String name)
-
getExplicitIndices
public List<Index> getExplicitIndices()
All explicitly defined indices, both on this schema itself (returned first) and all its fields- Specified by:
getExplicitIndices
in interfaceImmutableSchema
-
addSummary
public void addSummary(DocumentSummary summary)
Adds an explicitly defined summary to this search definition
-
getSummary
public DocumentSummary getSummary(String name)
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
public SummaryField 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.
-
getExplicitSummaryField
public SummaryField getExplicitSummaryField(String name)
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
public Map<String,DocumentSummary> getSummaries()
Summaries defined by fields of this search definition. The default summary, named "default", is always the first one in the returned iterator.
-
getSummariesInThis
public Map<String,DocumentSummary> getSummariesInThis()
Returns the summaries defines in this only, not any that are inherited.
-
getSummaryFields
public Map<String,SummaryField> getSummaryFields(ImmutableSDField field)
Returns all summary fields, of all document summaries, which has the given field as source. If there are multiple summary fields with the same name, the last one will be used (they should all have the same content, if this is a valid search definition).The map becomes owned by the receiver.- Specified by:
getSummaryFields
in interfaceImmutableSchema
- Parameters:
field
- the source field- Returns:
- the map of summary fields found
-
getUniqueNamedSummaryFields
public Map<String,SummaryField> 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
public Attribute getAttribute(String name)
Returns the first occurrence of an attribute having this name, or null if none
-
isAccessingDiskSummary
public boolean isAccessingDiskSummary(SummaryField field)
-
fieldSets
public FieldSets fieldSets()
-
addType
public Schema addType(SDDocumentType dt)
For adding structs defined in document scope- Parameters:
dt
- the struct to add- Returns:
- self, for chaining
-
addAnnotation
public Schema addAnnotation(SDAnnotationType dt)
-
validate
public void validate(com.yahoo.config.application.api.DeployLogger logger)
-
isReservedName
public static boolean isReservedName(String name)
Returns true if the given field name is a reserved name
-
-