Class Search
- java.lang.Object
-
- com.yahoo.searchdefinition.Search
-
- All Implemented Interfaces:
ImmutableSearch
- Direct Known Subclasses:
DocumentOnlySearch
public class Search extends java.lang.Object implements ImmutableSearch
A search definition describes (or uses) some document types, defines how these are turned into a relevancy tuned index through indexing and how data from documents should be served at search time. The identity of this class is its name.- Author:
- bratseth
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Search()
Creates a search definition which just holds a set of documents which should not (here, directly) be searchableSearch(java.lang.String name, com.yahoo.config.application.api.ApplicationPackage applicationPackage)
Creates a proper search definition
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Search
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 definitionSearch
addType(SDDocumentType dt)
For adding structs defined in document scopejava.util.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.java.util.Collection<SDField>
allExtraFields()
java.util.List<ImmutableSDField>
allFieldsList()
java.util.stream.Stream<ImmutableSDField>
allImportedFields()
com.yahoo.config.application.api.ApplicationPackage
applicationPackage()
boolean
equals(java.lang.Object o)
boolean
existsIndex(java.lang.String name)
java.util.Collection<SDField>
extraFieldList()
FieldSets
fieldSets()
The field set settings for this searchAttribute
getAttribute(java.lang.String name)
Returns the first occurrence of an attribute having this name, or null if noneSDField
getConcreteField(java.lang.String name)
Returns a field defined in this search definition or one if its documents.SDDocumentType
getDocument()
SDDocumentType
getDocument(java.lang.String name)
Gets a document from this search definitionSDField
getDocumentField(java.lang.String name)
Returns a field defined in one of the documents of this search definition.java.util.List<Index>
getExplicitIndices()
All explicitly defined indices, both on this search definition itself (returned first) and all its fieldsSummaryField
getExplicitSummaryField(java.lang.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(java.lang.String fieldName)
Returns a field by name, or null if it is not presentImmutableSDField
getField(java.lang.String name)
Index
getIndex(java.lang.String name)
Returns an index, or null if no index with this name has had some explicit settings applied.java.lang.String
getName()
java.io.Reader
getRankingExpression(java.lang.String fileName)
Returns the content of a ranking expression fileStemming
getStemming()
Returns whether fields should be stemmed by default or not.java.util.Map<java.lang.String,DocumentSummary>
getSummaries()
Summaries defined by fields of this search definition.DocumentSummary
getSummary(java.lang.String name)
Returns a summary class defined by this search definition, or null if no summary with this name is defined.SummaryField
getSummaryField(java.lang.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.java.util.Map<java.lang.String,SummaryField>
getSummaryFields(ImmutableSDField field)
Returns all summary fields, of all document summaries, which has the given field as source.java.util.Map<java.lang.String,SummaryField>
getUniqueNamedSummaryFields()
Returns one summary field for each summary field name.boolean
hasDocument()
int
hashCode()
java.util.Optional<ImportedFields>
importedFields()
boolean
isAccessingDiskSummary(SummaryField field)
boolean
isDocumentsOnly()
Returns true if this doesn't define a search, just some documentsstatic boolean
isReservedName(java.lang.String name)
Returns true if the given field name is a reserved nameRankingConstants
rankingConstants()
void
setImportedFields(ImportedFields importedFields)
protected void
setName(java.lang.String name)
void
setStemming(Stemming stemming)
Sets the stemming default of fields.java.util.Optional<TemporaryImportedFields>
temporaryImportedFields()
java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.yahoo.searchdefinition.ImmutableSearch
allFields
-
-
-
-
Constructor Detail
-
Search
protected Search()
Creates a search definition which just holds a set of documents which should not (here, directly) be searchable
-
Search
public Search(java.lang.String name, com.yahoo.config.application.api.ApplicationPackage applicationPackage)
Creates a proper search definition- Parameters:
name
- of the the searchdefinitionapplicationPackage
- the application containing this
-
-
Method Detail
-
isReservedName
public static boolean isReservedName(java.lang.String name)
Returns true if the given field name is a reserved name
-
setName
protected void setName(java.lang.String name)
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceImmutableSearch
-
isDocumentsOnly
public boolean isDocumentsOnly()
Returns true if this doesn't define a search, just some documents- Returns:
- if the searchdefinition only has documents
-
setStemming
public void setStemming(Stemming stemming)
Sets the stemming default of fields. Default is ALL- Parameters:
stemming
- set default stemming for this searchdefinition- Throws:
java.lang.NullPointerException
- if this is attempted set to null
-
getStemming
public Stemming getStemming()
Returns whether fields should be stemmed by default or not. Default is ALL. This is never null.- Returns:
- the default stemming for this searchdefinition
-
addDocument
public void addDocument(SDDocumentType document)
Adds a document type which is defined in this search definition- Parameters:
document
- the document type to add
-
rankingConstants
public RankingConstants rankingConstants()
- Specified by:
rankingConstants
in interfaceImmutableSearch
-
temporaryImportedFields
public java.util.Optional<TemporaryImportedFields> temporaryImportedFields()
-
importedFields
public java.util.Optional<ImportedFields> importedFields()
-
setImportedFields
public void setImportedFields(ImportedFields importedFields)
-
allImportedFields
public java.util.stream.Stream<ImmutableSDField> allImportedFields()
- Specified by:
allImportedFields
in interfaceImmutableSearch
-
getField
public ImmutableSDField getField(java.lang.String name)
- Specified by:
getField
in interfaceImmutableSearch
-
allFieldsList
public java.util.List<ImmutableSDField> allFieldsList()
- Specified by:
allFieldsList
in interfaceImmutableSearch
-
getDocument
public SDDocumentType getDocument(java.lang.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()
- Returns:
- The document in this search.
-
allConcreteFields
public java.util.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 interfaceImmutableSearch
-
getRankingExpression
public java.io.Reader getRankingExpression(java.lang.String fileName)
Returns the content of a ranking expression file- Specified by:
getRankingExpression
in interfaceImmutableSearch
-
applicationPackage
public com.yahoo.config.application.api.ApplicationPackage applicationPackage()
- Specified by:
applicationPackage
in interfaceImmutableSearch
-
getConcreteField
public SDField getConcreteField(java.lang.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 interfaceImmutableSearch
- Parameters:
name
- of the field- Returns:
- the SDField representing the field
-
getDocumentField
public SDField getDocumentField(java.lang.String name)
Returns a field defined in one of the documents of this search definition. This does not include the extra fields defined outside of a 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 java.util.Collection<SDField> extraFieldList()
-
allExtraFields
public java.util.Collection<SDField> allExtraFields()
-
getExtraField
public SDField getExtraField(java.lang.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(java.lang.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 search or on one of its fields
- Specified by:
getIndex
in interfaceImmutableSearch
- Parameters:
name
- the name of the index to get- Returns:
- the index requested
-
existsIndex
public boolean existsIndex(java.lang.String name)
-
getExplicitIndices
public java.util.List<Index> getExplicitIndices()
All explicitly defined indices, both on this search definition itself (returned first) and all its fields- Specified by:
getExplicitIndices
in interfaceImmutableSearch
- Returns:
- The list of explicit defined indexes.
-
addSummary
public void addSummary(DocumentSummary summary)
Adds an explicitly defined summary to this search definition- Parameters:
summary
- The summary to add.
-
getSummary
public DocumentSummary getSummary(java.lang.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.
- Parameters:
name
- the name of the summary to get.- Returns:
- Summary found.
-
getSummaryField
public SummaryField getSummaryField(java.lang.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.- Parameters:
name
- The name of the summaryfield to get.- Returns:
- SummaryField to return.
-
getExplicitSummaryField
public SummaryField getExplicitSummaryField(java.lang.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
- Thge name of the explicit summary field to get.- Returns:
- The SummaryField found.
-
getSummaries
public java.util.Map<java.lang.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.- Returns:
- The map of document summaries.
-
getSummaryFields
public java.util.Map<java.lang.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 gets owned by the receiver.
- Specified by:
getSummaryFields
in interfaceImmutableSearch
- Parameters:
field
- The source field.- Returns:
- The map of summary fields found.
-
getUniqueNamedSummaryFields
public java.util.Map<java.lang.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 gets owned by the receiver.
- Returns:
- Map of unique summary fields
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getAttribute
public Attribute getAttribute(java.lang.String name)
Returns the first occurrence of an attribute having this name, or null if none- Parameters:
name
- Name of attribute- Returns:
- The Attribute with given name.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isAccessingDiskSummary
public boolean isAccessingDiskSummary(SummaryField field)
-
fieldSets
public FieldSets fieldSets()
The field set settings for this search
-
addType
public Search addType(SDDocumentType dt)
For adding structs defined in document scope- Parameters:
dt
- the struct to add- Returns:
- self, for chaining
-
addAnnotation
public Search addAnnotation(SDAnnotationType dt)
-
-