Package com.yahoo.schema
Class ApplicationBuilder
java.lang.Object
com.yahoo.schema.ApplicationBuilder
Application builder. Usage:
1) Add all schemas, using the addXXX() methods,
2) provide the available rank types and ranking expressions, using the setRankXXX() methods,
3) invoke the
build(boolean)
method- Author:
- bratseth
-
Constructor Summary
ConstructorDescriptionFor testing onlyApplicationBuilder
(boolean documentsOnly) Used for generating documents for typed access to document fields in JavaApplicationBuilder
(com.yahoo.config.application.api.ApplicationPackage app, com.yahoo.config.application.api.DeployLogger deployLogger) For testing onlyApplicationBuilder
(com.yahoo.config.application.api.ApplicationPackage app, com.yahoo.config.application.api.DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry) For testing onlyApplicationBuilder
(com.yahoo.config.application.api.ApplicationPackage app, com.yahoo.config.application.api.FileRegistry fileRegistry, com.yahoo.config.application.api.DeployLogger deployLogger, com.yahoo.config.model.api.ModelContext.Properties properties, RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry) Regular constructorApplicationBuilder
(com.yahoo.config.application.api.DeployLogger deployLogger) For testing onlyApplicationBuilder
(com.yahoo.config.application.api.DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry) For testing onlyApplicationBuilder
(com.yahoo.config.model.api.ModelContext.Properties properties) For testing onlyApplicationBuilder
(RankProfileRegistry rankProfileRegistry) For testing onlyApplicationBuilder
(RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry) For testing onlyApplicationBuilder
(RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry, com.yahoo.config.model.api.ModelContext.Properties properties) For testing only -
Method Summary
Modifier and TypeMethodDescriptionRegisters the given schema to the application to be built duringbuild(boolean)
.void
addSchema
(com.yahoo.io.reader.NamedReader reader) Reads and parses the schema string provided by the given reader.void
Adds a schema to thisvoid
addSchemaFile
(String fileName) Adds a schema to this application.build
(boolean validate) Processes and finalizes the schemas of this.static Schema
buildFromFile
(String fileName) Convenience factory method to import and build aSchema
object from a file.static Schema
buildFromFile
(String fileName, com.yahoo.config.application.api.DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry) Convenience factory method to import and build aSchema
from a file.static Schema
buildFromFile
(String fileName, RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry) Convenience factory method to import and build aSchema
object from a file.static Schema
buildFromRawSchema
(Schema rawSchema, RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry) Convenience factory method to import and build aSchema
object from a raw object.static ApplicationBuilder
createFromDirectory
(String dir, com.yahoo.config.application.api.FileRegistry fileRegistry, com.yahoo.config.application.api.DeployLogger logger, com.yahoo.config.model.api.ModelContext.Properties properties) static ApplicationBuilder
createFromDirectory
(String dir, com.yahoo.config.application.api.FileRegistry fileRegistry, com.yahoo.config.application.api.DeployLogger logger, com.yahoo.config.model.api.ModelContext.Properties properties, RankProfileRegistry rankProfileRegistry) static ApplicationBuilder
createFromFile
(String fileName) Convenience factory method to import and build aSchema
object from a file.static ApplicationBuilder
createFromFile
(String fileName, com.yahoo.config.application.api.DeployLogger logger) static ApplicationBuilder
createFromFiles
(Collection<String> fileNames) Convenience factory methods to create a SearchBuilder from multiple SD files.static ApplicationBuilder
createFromRawSchema
(Schema rawSchema, RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry) Convenience factory method to import and build aSchema
object from a raw object.static ApplicationBuilder
Convenience factory method to import and build aSchema
object from a string.static ApplicationBuilder
createFromString
(String sd, com.yahoo.config.application.api.DeployLogger logger) static ApplicationBuilder
createFromStrings
(com.yahoo.config.application.api.DeployLogger logger, String... schemas) com.yahoo.config.application.api.DeployLogger
getModel()
com.yahoo.config.model.api.ModelContext.Properties
com.yahoo.search.query.profile.QueryProfileRegistry
Convenience method to callgetSchema(String)
when there is only a singleSchema
object built.Returns the builtSchema
object that has the given name.Convenience method to return a list of all builtSchema
objects.Returns a modifiable set of processors we should skip for these schemas.
-
Constructor Details
-
ApplicationBuilder
public ApplicationBuilder()For testing only -
ApplicationBuilder
public ApplicationBuilder(com.yahoo.config.application.api.DeployLogger deployLogger) For testing only -
ApplicationBuilder
public ApplicationBuilder(com.yahoo.config.application.api.DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry) For testing only -
ApplicationBuilder
public ApplicationBuilder(boolean documentsOnly) Used for generating documents for typed access to document fields in Java -
ApplicationBuilder
public ApplicationBuilder(com.yahoo.config.application.api.ApplicationPackage app, com.yahoo.config.application.api.DeployLogger deployLogger) For testing only -
ApplicationBuilder
public ApplicationBuilder(com.yahoo.config.application.api.ApplicationPackage app, com.yahoo.config.application.api.DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry) For testing only -
ApplicationBuilder
For testing only -
ApplicationBuilder
public ApplicationBuilder(RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry) For testing only -
ApplicationBuilder
public ApplicationBuilder(com.yahoo.config.model.api.ModelContext.Properties properties) For testing only -
ApplicationBuilder
public ApplicationBuilder(RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry, com.yahoo.config.model.api.ModelContext.Properties properties) For testing only -
ApplicationBuilder
public ApplicationBuilder(com.yahoo.config.application.api.ApplicationPackage app, com.yahoo.config.application.api.FileRegistry fileRegistry, com.yahoo.config.application.api.DeployLogger deployLogger, com.yahoo.config.model.api.ModelContext.Properties properties, RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry) Regular constructor
-
-
Method Details
-
addSchemaFile
Adds a schema to this application.- Parameters:
fileName
- the name of the file to import- Throws:
IOException
- thrown if the file can not be read for some reasonParseException
- thrown if the file does not contain a valid search definition
-
addSchema
public void addSchema(com.yahoo.io.reader.NamedReader reader) Reads and parses the schema string provided by the given reader. Once all schemas have been imported, callbuild(boolean)
.- Parameters:
reader
- the reader whose content to import
-
addSchema
Adds a schema to this- Parameters:
schemaString
- the content of the schema- Throws:
ParseException
-
add
Registers the given schema to the application to be built duringbuild(boolean)
. ASchema
object is considered to be "raw" if it has not already been processed. This is the case for most programmatically constructed schemas used in unit tests.- Parameters:
schema
- the object to import- Throws:
IllegalArgumentException
- if the given search object has already been processed
-
build
Processes and finalizes the schemas of this.- Throws:
IllegalStateException
- thrown if this method has already been called
-
processorsToSkip
Returns a modifiable set of processors we should skip for these schemas. Useful for testing. -
getSchema
Convenience method to callgetSchema(String)
when there is only a singleSchema
object built. This method will never return null.- Returns:
- the built object
- Throws:
IllegalStateException
- if there is not exactly one search.
-
getModel
-
getSchema
Returns the builtSchema
object that has the given name. If the name is unknown, this method will simply return null.- Parameters:
name
- the name of the schema to return, or null to return the only one or throw an exception if there are multiple to choose from- Returns:
- the built object, or null if none with this name
- Throws:
IllegalStateException
- ifbuild(boolean)
has not been called.
-
application
-
getSchemaList
Convenience method to return a list of all builtSchema
objects.- Returns:
- the list of built searches
-
createFromString
Convenience factory method to import and build aSchema
object from a string.- Parameters:
sd
- the string to build from- Returns:
- the built
ApplicationBuilder
object - Throws:
ParseException
- thrown if there is a problem parsing the string
-
createFromString
public static ApplicationBuilder createFromString(String sd, com.yahoo.config.application.api.DeployLogger logger) throws ParseException - Throws:
ParseException
-
createFromStrings
public static ApplicationBuilder createFromStrings(com.yahoo.config.application.api.DeployLogger logger, String... schemas) throws ParseException - Throws:
ParseException
-
createFromFile
Convenience factory method to import and build aSchema
object from a file. Only for testing.- Parameters:
fileName
- the file to build from- Returns:
- the built
ApplicationBuilder
object - Throws:
IOException
- if there was a problem reading the file.ParseException
- if there was a problem parsing the file content.
-
createFromFiles
public static ApplicationBuilder createFromFiles(Collection<String> fileNames) throws IOException, ParseException Convenience factory methods to create a SearchBuilder from multiple SD files. Only for testing.- Throws:
IOException
ParseException
-
createFromFile
public static ApplicationBuilder createFromFile(String fileName, com.yahoo.config.application.api.DeployLogger logger) throws IOException, ParseException - Throws:
IOException
ParseException
-
createFromDirectory
public static ApplicationBuilder createFromDirectory(String dir, com.yahoo.config.application.api.FileRegistry fileRegistry, com.yahoo.config.application.api.DeployLogger logger, com.yahoo.config.model.api.ModelContext.Properties properties) throws IOException, ParseException - Throws:
IOException
ParseException
-
createFromDirectory
public static ApplicationBuilder createFromDirectory(String dir, com.yahoo.config.application.api.FileRegistry fileRegistry, com.yahoo.config.application.api.DeployLogger logger, com.yahoo.config.model.api.ModelContext.Properties properties, RankProfileRegistry rankProfileRegistry) throws IOException, ParseException - Throws:
IOException
ParseException
-
buildFromFile
Convenience factory method to import and build aSchema
object from a file. Only for testing.- Parameters:
fileName
- the file to build from- Returns:
- the built
Schema
object - Throws:
IOException
- thrown if there was a problem reading the fileParseException
- thrown if there was a problem parsing the file content
-
buildFromFile
public static Schema buildFromFile(String fileName, RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException Convenience factory method to import and build aSchema
object from a file.- Parameters:
fileName
- the file to build fromrankProfileRegistry
- registry for rank profiles- Returns:
- the built
Schema
object - Throws:
IOException
- thrown if there was a problem reading the fileParseException
- thrown if there was a problem parsing the file content
-
buildFromFile
public static Schema buildFromFile(String fileName, com.yahoo.config.application.api.DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException Convenience factory method to import and build aSchema
from a file.- Parameters:
fileName
- the file to build fromdeployLogger
- logger for deploy messagesrankProfileRegistry
- registry for rank profiles- Returns:
- the built
Schema
object - Throws:
IOException
- thrown if there was a problem reading the fileParseException
- thrown if there was a problem parsing the file content
-
createFromRawSchema
public static ApplicationBuilder createFromRawSchema(Schema rawSchema, RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry) Convenience factory method to import and build aSchema
object from a raw object.- Parameters:
rawSchema
- the raw object to build from- Returns:
- the built
ApplicationBuilder
object - See Also:
-
buildFromRawSchema
public static Schema buildFromRawSchema(Schema rawSchema, RankProfileRegistry rankProfileRegistry, com.yahoo.search.query.profile.QueryProfileRegistry queryProfileRegistry) Convenience factory method to import and build aSchema
object from a raw object.- Parameters:
rawSchema
- the raw object to build from- Returns:
- the built
Schema
object - See Also:
-
getRankProfileRegistry
-
getQueryProfileRegistry
public com.yahoo.search.query.profile.QueryProfileRegistry getQueryProfileRegistry() -
getProperties
public com.yahoo.config.model.api.ModelContext.Properties getProperties() -
getDeployLogger
public com.yahoo.config.application.api.DeployLogger getDeployLogger()
-