Package org.terrier.querying
Class LocalManager
- java.lang.Object
-
- org.terrier.querying.LocalManager
-
- All Implemented Interfaces:
Manager
- Direct Known Subclasses:
ThreadSafeManager
public class LocalManager extends java.lang.Object implements Manager
This class is responsible for handling/co-ordinating the main high-level operations of a query. These are:- Processing (Term Pipeline, Control finding, term aggregation, Matching) @see org.terrier.querying.Process
- Post-filtering @see org.terrier.querying.PostFilter
IndexRef indexRef = IndexRef.of("/path/to/data.properties"); Manager m = ManagerFactory.from(indexRef); SearchRequest srq = m.newSearchRequest("Q1", "term1 title:term2"); m.runSearchRequest(srq);
Properties
- querying.default.controls - sets the default controls for each query
- querying.allowed.controls - sets the controls which a users is allowed to set in a query
- querying.processes - mappings between controls and the processes they should cause, in order that they should execute
- querying.postfilters - mappings between controls and the post filters they should cause, in order that they should execute
Controls
- start : The result number to start at - defaults to 0 (1st result)
- end : the result number to end at - defaults to 0 (display all results)
- c : the c parameter for the DFR models, or more generally, the parameters for weighting models
- c_set : "yes" if the c control has been set
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LocalManager.Builder
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<java.lang.String>
Allowed_Controls
This contains a list of controls that may be set in the querying APIprotected java.util.Map<java.lang.String,java.lang.String>
Default_Controls
This contains the mapping of controls and their values that should be set identically for each query created by this Managerprotected int
Defaults_Size
How many default controls exist.protected Index
index
The index this querying comes fromprotected static org.slf4j.Logger
logger
static java.lang.String
NAMESPACE_MATCHING
The default namespace for Matching models to be loaded fromstatic java.lang.String
NAMESPACE_POSTFILTER
The default namespace for PostFilters to be loaded fromstatic java.lang.String
NAMESPACE_PROCESS
The default namespace for Process instances to be loaded fromstatic java.lang.String
NAMESPACE_WEIGHTING
The default namespace for Weighting models to be loaded fromprotected java.lang.String
pipelineOutput
This class is used as a TermPipelineAccessor, and this variable stores the result of the TermPipeline run for that term.protected TermPipelineAccessor
tpa
TermPipeline processing
-
Constructor Summary
Constructors Constructor Description LocalManager(Index _index)
Construct a Manager using the specified Index Throws IllegalArgumentException if the specified index is null
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Index
getIndex()
Returns the index used by the manager.IndexRef
getIndexRef()
java.lang.String
getInfo(SearchRequest srq)
Returns information about the weighting models and the post processors used for the given search request.protected static Model
getWeightingModel(Request rq)
Returns the weighting model requested by the Request from the WeightingModel factory.protected void
load_controls_allowed()
load in the controls that user is allowed to setprotected void
load_controls_default()
load in the control defaultsprotected void
load_pipeline()
load in the term pipelineSearchRequest
newSearchRequest()
Ask for new SearchRequest object to be made.SearchRequest
newSearchRequest(java.lang.String QueryID)
Ask for new SearchRequest object to be made.SearchRequest
newSearchRequest(java.lang.String QueryID, java.lang.String query)
Ask for new SearchRequest object to be made, instantiated using the specified query id, and that the specified query should be parsed.SearchRequest
newSearchRequestFromQuery(java.lang.String query)
Ask for new SearchRequest object to be made given a query to be parsedvoid
runNamedProcess(java.lang.String processName, Request q)
this allows processes to invoke other processes.void
runSearchRequest(SearchRequest srq)
This runs a given SearchRequest through the four retrieval stages and adds the ResultSet to the SearchRequest object.protected void
setDefaults(Request srq)
Set the default values for the controls of this new search requestvoid
setProperties(java.util.Properties p)
Set all these properties.void
setProperty(java.lang.String key, java.lang.String value)
Provide a common interface for changing property values.protected void
useThisIndex(Index i)
use the index specified for the Manager
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
NAMESPACE_PROCESS
public static final java.lang.String NAMESPACE_PROCESS
The default namespace for Process instances to be loaded from- See Also:
- Constant Field Values
-
NAMESPACE_POSTFILTER
public static final java.lang.String NAMESPACE_POSTFILTER
The default namespace for PostFilters to be loaded from- See Also:
- Constant Field Values
-
NAMESPACE_MATCHING
public static final java.lang.String NAMESPACE_MATCHING
The default namespace for Matching models to be loaded from- See Also:
- Constant Field Values
-
NAMESPACE_WEIGHTING
public static final java.lang.String NAMESPACE_WEIGHTING
The default namespace for Weighting models to be loaded from- See Also:
- Constant Field Values
-
tpa
protected TermPipelineAccessor tpa
TermPipeline processing
-
index
protected Index index
The index this querying comes from
-
Allowed_Controls
protected java.util.Set<java.lang.String> Allowed_Controls
This contains a list of controls that may be set in the querying API
-
Default_Controls
protected java.util.Map<java.lang.String,java.lang.String> Default_Controls
This contains the mapping of controls and their values that should be set identically for each query created by this Manager
-
Defaults_Size
protected int Defaults_Size
How many default controls exist. Directly corresponds to Default_Controls.size()
-
pipelineOutput
protected java.lang.String pipelineOutput
This class is used as a TermPipelineAccessor, and this variable stores the result of the TermPipeline run for that term.
-
-
Constructor Detail
-
LocalManager
public LocalManager(Index _index)
Construct a Manager using the specified Index Throws IllegalArgumentException if the specified index is null- Parameters:
_index
- The index to use in this manage
-
-
Method Detail
-
useThisIndex
protected void useThisIndex(Index i)
use the index specified for the Manager
-
load_controls_allowed
protected void load_controls_allowed()
load in the controls that user is allowed to set
-
load_controls_default
protected void load_controls_default()
load in the control defaults
-
load_pipeline
protected void load_pipeline()
load in the term pipeline
-
runNamedProcess
public void runNamedProcess(java.lang.String processName, Request q)
this allows processes to invoke other processes. E.g. QueryExpansion can ask for matching to be re-run
-
newSearchRequest
public SearchRequest newSearchRequest()
Description copied from interface:Manager
Ask for new SearchRequest object to be made. This is internally a Request object- Specified by:
newSearchRequest
in interfaceManager
-
newSearchRequest
public SearchRequest newSearchRequest(java.lang.String QueryID)
Description copied from interface:Manager
Ask for new SearchRequest object to be made. This is internally a Request object- Specified by:
newSearchRequest
in interfaceManager
- Parameters:
QueryID
- The request should be identified by QueryID
-
newSearchRequest
public SearchRequest newSearchRequest(java.lang.String QueryID, java.lang.String query)
Description copied from interface:Manager
Ask for new SearchRequest object to be made, instantiated using the specified query id, and that the specified query should be parsed.- Specified by:
newSearchRequest
in interfaceManager
- Parameters:
QueryID
- The request should be identified by QueryIDquery
- The actual user query- Returns:
- The fully init'd search request for use in the manager
-
newSearchRequestFromQuery
public SearchRequest newSearchRequestFromQuery(java.lang.String query)
Description copied from interface:Manager
Ask for new SearchRequest object to be made given a query to be parsed- Specified by:
newSearchRequestFromQuery
in interfaceManager
- Parameters:
query
- The actual user query- Returns:
- The fully init'd search request for use in the manager
-
setDefaults
protected void setDefaults(Request srq)
Set the default values for the controls of this new search request- Parameters:
srq
- The search request to have the default set to. This is done using the Default_Controls table, which is loaded by the load_controls_default method. The default are set in the properties file, by the querying.default.controls
-
getIndex
public Index getIndex()
Returns the index used by the manager. It is used for matching and possibly post-processing.- Returns:
- Index the index used by the manager.
-
getIndexRef
public IndexRef getIndexRef()
- Specified by:
getIndexRef
in interfaceManager
-
setProperty
public void setProperty(java.lang.String key, java.lang.String value)
Description copied from interface:Manager
Provide a common interface for changing property values.- Specified by:
setProperty
in interfaceManager
- Parameters:
key
- Key of property to setvalue
- Value of property to set
-
setProperties
public void setProperties(java.util.Properties p)
Description copied from interface:Manager
Set all these properties. Implemented using setProperty(String,String).- Specified by:
setProperties
in interfaceManager
- Parameters:
p
- All properties to set
-
runSearchRequest
public void runSearchRequest(SearchRequest srq)
Description copied from interface:Manager
This runs a given SearchRequest through the four retrieval stages and adds the ResultSet to the SearchRequest object.- Specified by:
runSearchRequest
in interfaceManager
- Parameters:
srq
- - the SearchRequest to be processed
-
getWeightingModel
protected static Model getWeightingModel(Request rq)
Returns the weighting model requested by the Request from the WeightingModel factory.- Parameters:
rq
- The name of the weighting model to instantiate
-
getInfo
public java.lang.String getInfo(SearchRequest srq)
Returns information about the weighting models and the post processors used for the given search request.- Parameters:
srq
- the search request for which we obtain the information.- Returns:
- String information about the weighting models and the post processors used.
-
-