Class PageTemplateSearcher
- java.lang.Object
-
- com.yahoo.component.AbstractComponent
-
- com.yahoo.component.chain.ChainedComponent
-
- com.yahoo.processing.Processor
-
- com.yahoo.search.Searcher
-
- com.yahoo.search.pagetemplates.PageTemplateSearcher
-
- All Implemented Interfaces:
com.yahoo.component.Component
,com.yahoo.component.Deconstructable
,java.lang.Comparable<com.yahoo.component.Component>
public class PageTemplateSearcher extends Searcher
Enables page optimization templates. This searcher should be placed before federation points in the search chain.Input query properties:
page.idList
- a List<String> of id strings of the page templates this should choose betweenpage.id
- a space-separated string of ids of the page templates this should choose between. This property is ignored ifpage.idList
is setpage.resolver
the id of the resolver to use to resolve choices. This is either the component id of a deployed resolver component, or one of the stringsnative.deterministic
(which always pics the last choice) ornative.random
page.ListOfPageTemplate
A List<PageTemplate> containing a list of the page templates used for this query
The set of page templates chosen for the query specifies a list of sources to be queried (the page template sources). In addition, the query may contain
- a set of sources set explicitly in the Request, a query property or a searcher (the query model sources)
- a set of sources specified in the
IntentModel
(the intent model sources)
- If the query model sources is set (not empty), it is not changed
- If the page template sources contains the ANY source AND there is an intent model the query model sources is set to the union of the page template sources and the intent model sources
- If the page template sources contains the ANY source AND there is no intent model, the query model sources is left empty (causing all sources to be queried)
- Otherwise, the query model sources is set to the page template sources
- Author:
- bratseth
-
-
Field Summary
Fields Modifier and Type Field Description static com.yahoo.processing.request.CompoundName
pageIdListName
The name of the query property containing a list of candidate pages to considerstatic com.yahoo.processing.request.CompoundName
pageIdName
The name of the query property containing the page id to usestatic com.yahoo.processing.request.CompoundName
pagePageTemplateListName
The name of the query property containing the resolved candidate page template liststatic com.yahoo.processing.request.CompoundName
pageResolverName
The name of the query property containing the resolver id to use
-
Constructor Summary
Constructors Constructor Description PageTemplateSearcher(PageTemplateRegistry templateRegistry, Resolver... resolvers)
Creates this from an existing page template registry, using only built-in resolversPageTemplateSearcher(PageTemplatesConfig pageTemplatesConfig, com.yahoo.component.provider.ComponentRegistry<Resolver> resolverRegistry)
Creates this from a configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Result
search(Query query, Execution execution)
Override this to implement your searcher.-
Methods inherited from class com.yahoo.search.Searcher
ensureFilled, fill, getLogger, process, toString
-
Methods inherited from class com.yahoo.component.chain.ChainedComponent
getAnnotatedDependencies, getDefaultAnnotatedDependencies, getDependencies, initDependencies
-
-
-
-
Field Detail
-
pagePageTemplateListName
public static final com.yahoo.processing.request.CompoundName pagePageTemplateListName
The name of the query property containing the resolved candidate page template list
-
pageIdListName
public static final com.yahoo.processing.request.CompoundName pageIdListName
The name of the query property containing a list of candidate pages to consider
-
pageIdName
public static final com.yahoo.processing.request.CompoundName pageIdName
The name of the query property containing the page id to use
-
pageResolverName
public static final com.yahoo.processing.request.CompoundName pageResolverName
The name of the query property containing the resolver id to use
-
-
Constructor Detail
-
PageTemplateSearcher
@Inject public PageTemplateSearcher(PageTemplatesConfig pageTemplatesConfig, com.yahoo.component.provider.ComponentRegistry<Resolver> resolverRegistry)
Creates this from a configuration. This will be called by the container.
-
PageTemplateSearcher
public PageTemplateSearcher(PageTemplateRegistry templateRegistry, Resolver... resolvers)
Creates this from an existing page template registry, using only built-in resolvers- Parameters:
templateRegistry
- the page template registry. This will be frozen by this call.resolvers
- the resolvers to use, in addition to the default resolvers
-
-
Method Detail
-
search
public Result search(Query query, Execution execution)
Description copied from class:Searcher
Override this to implement your searcher.Searcher implementation subclasses will, depending on their type of logic, do one of the following:
- Query processors: Access the query, then call execution.search and return the result
- Result processors: Call execution.search to get the result, access it and return
- Sources (which produces results): Create a result, add the desired hits and return it.
- Federators (which forwards the search to multiple subchains): Call search on the desired subchains in parallel and get the results. Combine the results to one and return it.
- Workflows: Call execution.search as many times as desired, using different queries. Eventually return a result.
Hits come in two kinds - concrete hits are actual content of the kind requested by the user, meta hits are hits which provides information about the collection of hits, on the query, the service and so on.
The query specifies a window into a larger result list that must be returned from the searcher through hits and offset; Searchers which returns list of hits in the top level in the result must return at least hits number of hits (or if impossible; all that are available), starting at the given offset. In addition, searchers are allowed to return any number of meta hits (although this number is expected to be low). For hits contained in nested hit groups, the concept of a window defined by hits and offset is not well defined and does not apply.
Error handling in searchers:
- Unexpected events: Throw any RuntimeException. This query will fail with the exception message, and the error will be logged
- Expected events: Create (new Result(Query, ErrorMessage) or add result.setErrorIfNoOtherErrors(ErrorMessage) an error message to the Result.
- Recoverable user errors: Add a FeedbackHit explaining the condition and how to correct it.
-
-