public static final class Execution.Context extends Object
The Context class simply carries a set of objects which define the environment for the search. Important: All objects available through context need to be either truly immutable or support the freeze pattern.
If you are implementing a searcher where you need to create a new Context
instance to create an Execution, you should use the context from the
execution the searcher was invoked from. You can also copy
(Context.shallowCopy()) the incoming context if it is necessary to do
more. In other words, a minimal example would be:
new Execution(searchChain, execution.context())
Constructor and Description |
---|
Context(SearchChainRegistry searchChainRegistry,
IndexFacts indexFacts,
SpecialTokenRegistry tokenRegistry,
RendererRegistry rendererRegistry,
com.yahoo.language.Linguistics linguistics)
Creates a context from arguments, all of which may be null, though
this can be risky.
|
Modifier and Type | Method and Description |
---|---|
static Execution.Context |
createContextStub()
Creates a context stub with no information.
|
static Execution.Context |
createContextStub(IndexFacts indexFacts)
Create a Context instance where only the index related settings are
initialized.
|
static Execution.Context |
createContextStub(SearchChainRegistry searchChainRegistry,
IndexFacts indexFacts)
Create a Context instance where only the search chain registry and index facts are
initialized.
|
static Execution.Context |
createContextStub(SearchChainRegistry searchChainRegistry,
IndexFacts indexFacts,
com.yahoo.language.Linguistics linguistics)
Create a Context instance where only the search chain registry, index facts and linguistics are
initialized.
|
boolean |
equals(Execution.Context other) |
boolean |
equals(Object other) |
boolean |
getBreakdown()
If too many queries time out, the search handler will assume the
system is in a breakdown state.
|
boolean |
getDetailedDiagnostics()
The container has some internal diagnostics mechanisms which may be
costly, and therefore not active by default.
|
IndexFacts |
getIndexFacts()
Returns information about the indexes specified by the search definitions
used in this system, or null if not know.
|
com.yahoo.language.Linguistics |
getLinguistics()
Returns the
Linguistics object assigned to this Context. |
SpecialTokenRegistry |
getTokenRegistry() |
int |
hashCode() |
void |
populateFrom(Execution.Context sourceContext)
Populate missing values in this from the given context.
|
RendererRegistry |
rendererRegistry()
Returns the template registry to use with this execution.
|
SearchChainRegistry |
searchChainRegistry()
Returns the search chain registry to use with this execution.
|
void |
setBreakdown(boolean breakdown) |
void |
setDetailedDiagnostics(boolean breakdown) |
void |
setIndexFacts(IndexFacts indexFacts)
Use this to override index settings for the searchers below
a given searcher, the easiest way to do this is to wrap the incoming
IndexFacts instance in a subclass.
|
void |
setLinguistics(com.yahoo.language.Linguistics linguistics) |
void |
setTokenRegistry(SpecialTokenRegistry tokenRegistry)
Wrapping the incoming special token registry and then setting the
wrapper as the token registry, can be used for changing the set of
special tokens used by succeeding searchers.
|
Execution.Context |
shallowCopy()
Standard shallow copy, the new instance will carry the same
references as this.
|
public Context(SearchChainRegistry searchChainRegistry, IndexFacts indexFacts, SpecialTokenRegistry tokenRegistry, RendererRegistry rendererRegistry, com.yahoo.language.Linguistics linguistics)
This context is never attached to an execution but is used to carry state into another context.
public static Execution.Context createContextStub()
public static Execution.Context createContextStub(IndexFacts indexFacts)
public static Execution.Context createContextStub(SearchChainRegistry searchChainRegistry, IndexFacts indexFacts)
public static Execution.Context createContextStub(SearchChainRegistry searchChainRegistry, IndexFacts indexFacts, com.yahoo.language.Linguistics linguistics)
public void populateFrom(Execution.Context sourceContext)
sourceContext
- the context from which to get the parameterspublic boolean equals(Execution.Context other)
public Execution.Context shallowCopy()
public IndexFacts getIndexFacts()
public void setIndexFacts(IndexFacts indexFacts)
indexFacts
- an instance to override the following searcher's view of
the indexes.public SearchChainRegistry searchChainRegistry()
public RendererRegistry rendererRegistry()
public SpecialTokenRegistry getTokenRegistry()
public void setTokenRegistry(SpecialTokenRegistry tokenRegistry)
tokenRegistry
- a new registry for overriding behavior of following searcherspublic void setDetailedDiagnostics(boolean breakdown)
public boolean getDetailedDiagnostics()
public boolean getBreakdown()
public void setBreakdown(boolean breakdown)
public com.yahoo.language.Linguistics getLinguistics()
Linguistics
object assigned to this Context. This object provides access to all the
linguistic-related APIs, and comes pre-configured with the Execution given.public void setLinguistics(com.yahoo.language.Linguistics linguistics)
Copyright © 2018. All rights reserved.