public abstract class Searcher
extends com.yahoo.processing.Processor
Components
which produces Results in response to
Queries by calling the search
method.
Searchers are participants in chain of responsibility search chains
where they passes the Queries downwards by synchroneously calling the next Searcher in the chain, and returns the
Results back up as the response.
Any Searcher may
Execution
for each chain), or in parallel (by creating a
AsyncExecution
) (a federator)
...or some combination of the above of course. Note that as Searchers work synchronously, any information can be retained on the stack in the Searcher from the Query is received until the Result is returned simply by declaring variables for the data in the search method (or whatever it calls), and for the same reason workflows are implemented as Java code. However, searchers are executed by many threads, for different Queries, in parallell, so any mutable data shared between queries (and hence stored as instance members must be accessed multithread safely. In many cases, shared data can simply be instantiated in the constructor and used in read-only mode afterwards
Searcher lifecycle: A searcher has a simple life-cycle:
ConfigInstance
) as arguments.
Constructor and Description |
---|
Searcher() |
Searcher(com.yahoo.component.ComponentId id)
Creates a searcher from an id
|
Modifier and Type | Method and Description |
---|---|
void |
ensureFilled(Result result,
String summaryClass,
Execution execution)
Fills the result if it is not already filled for the given summary class.
|
void |
fill(Result result,
String summaryClass,
Execution execution)
Fill hit properties with data using the given summary class.
|
protected Logger |
getLogger()
Returns a logger unique for the instance subclass
|
com.yahoo.processing.Response |
process(com.yahoo.processing.Request request,
com.yahoo.processing.execution.Execution execution)
Use the search method in Searcher processors.
|
abstract Result |
search(Query query,
Execution execution)
Override this to implement your searcher.
|
String |
toString()
Returns "searcher 'getId()'"
|
getAnnotatedDependencies, getDefaultAnnotatedDependencies, getDependencies, initDependencies
private final Logger logger
public Searcher()
public Searcher(com.yahoo.component.ComponentId id)
public abstract Result search(Query query, Execution execution)
Searcher implementation subclasses will, depending on their type of logic, do one of the following:
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:
query
- the querypublic final com.yahoo.processing.Response process(com.yahoo.processing.Request request, com.yahoo.processing.execution.Execution execution)
process
in class com.yahoo.processing.Processor
public void fill(Result result, String summaryClass, Execution execution)
This needs to be overridden by federating searchers to contact search sources again by propagating the fill call down through the search chain, and by source searchers which talks to fill capable backends to request the data to be filled. Other searchers do not need to override this.
result
- the result to fillsummaryClass
- the name of the collection of fields to fetch the values of, or null to use the defaultpublic final void ensureFilled(Result result, String summaryClass, Execution execution)
protected Logger getLogger()
public String toString()
toString
in class com.yahoo.component.AbstractComponent
Copyright © 2018. All rights reserved.