org.terrier.querying
Interface SearchRequest

All Superinterfaces:
Serializable
All Known Implementing Classes:
Request

public interface SearchRequest
extends Serializable

SearchRequest is the one of two main classes of which are made available to client code by the Terrier framework at retrieval time. Each search query, whether entered by a user or in batch mode retrieval creates a search request. Each search request is then passed to 4 methods of the Manager that is handling each search request: runPreProcessing, runMatching, runPostProcess and runPostFilters Example usage:

 Index index = Index.createIndex();
 Manager manager = new Manager(index);
 SearchRequest srq = manager.newSearchRequest("my query");
 //run the query
 m.runPreProcessing(srq);
 manager.runMatching(srq);
 manager.runPostProcess(srq);
 manager.runPostFilters(srq);
 

NB:Controls (name, value String tuples) are used to control the retrieval process. You may want to set controls in your application code. However, default controls can be set using the querying.default.controls property in the terrier.properties file.

Context Objects (name, value object tuples) are used to pass arbitrary information to classes within Terrier.


Method Summary
 void addMatchingModel(String MatchingModelName, String WeightingModelName)
          Set the matching model and weighting model that the Manager should use for this query.
 Object getContextObject(String key)
          Returns the value of a context object.
 String getControl(String Name)
          Returns the value of the control.
 int getNumberOfDocumentsAfterFiltering()
          gets the number of documents returned for a search request, after applying post filtering
 String getOriginalQuery()
          gets the original query, before any preprocessing
 Query getQuery()
          Get the Query syntax tree
 String getQueryID()
          Returns the query id as set by setQueryID(String).
 ResultSet getResultSet()
          Returns the resultset generated by the query.
 long getStartedProcessingTime()
          Returns the time the process start.
 boolean isEmpty()
          Set if the query input had no terms.
 void setContextObject(String key, Object value)
          Set a value of a context object.
 void setControl(String Name, String Value)
          Set a control named to have value Value.
 void setNumberOfDocumentsAfterFiltering(int n)
          Sets the number of documents returned for a search request, after applying post filtering
 void setOriginalQuery(String q)
          sets the original query, before any preprocessing
 void setQuery(Query q)
          Set the query to be a parsed Query syntax tree, as generated by the Terrier query parser
 void setQueryID(String qid)
          Set a unique identifier for this query request.
 void setStartedProcessingTime(long time)
          Sets the started processing time.
 

Method Detail

addMatchingModel

void addMatchingModel(String MatchingModelName,
                      String WeightingModelName)
Set the matching model and weighting model that the Manager should use for this query. The Matching model should be a subclass of org.terrier.matching.Matching, and the weighting model should implement org.terrier.matching.Model.
Example: request.addMatchingModel("Matching", "PL2")

Parameters:
MatchingModelName - the String class name that should be used
WeightingModelName - the String class name that should be used

setQuery

void setQuery(Query q)
Set the query to be a parsed Query syntax tree, as generated by the Terrier query parser

Parameters:
q - The Query object syntax tree

setQueryID

void setQueryID(String qid)
Set a unique identifier for this query request.

Parameters:
qid - the unique string identifier

getQuery

Query getQuery()
Get the Query syntax tree

Returns:
The query object as set with setQuery.

setControl

void setControl(String Name,
                String Value)
Set a control named to have value Value. This is essentially a hashtable wrappers. Controls are used to set properties of the retrieval process.

Parameters:
Name - the name of the control to set the value of.
Value - the value that the control should take.

getQueryID

String getQueryID()
Returns the query id as set by setQueryID(String).

Returns:
the query Id as a string.

getResultSet

ResultSet getResultSet()
Returns the resultset generated by the query. Before retrieving this you probably need to have run Manager.runMatching, and (optionally, at your own risk) Manager.runPostProcesses() and Manager.runPostFiltering().

Returns:
ResultSet the resultset - ie the set of document Ids and their scores.

getControl

String getControl(String Name)
Returns the value of the control. Null or empty string if not set.

Returns:
the value.

isEmpty

boolean isEmpty()
Set if the query input had no terms.

Returns:
true if the query has no terms. Used by Manager.runMatching() to short circuit the matching process - if this is set, then a resultset with 0 documents is created automatically. - return true if the query has no terms

setOriginalQuery

void setOriginalQuery(String q)
sets the original query, before any preprocessing


getOriginalQuery

String getOriginalQuery()
gets the original query, before any preprocessing


setNumberOfDocumentsAfterFiltering

void setNumberOfDocumentsAfterFiltering(int n)
Sets the number of documents returned for a search request, after applying post filtering

Parameters:
n -

getNumberOfDocumentsAfterFiltering

int getNumberOfDocumentsAfterFiltering()
gets the number of documents returned for a search request, after applying post filtering

Returns:
the number of documents returned for a search request. integer.

getStartedProcessingTime

long getStartedProcessingTime()
Returns the time the process start.

Returns:
time long

setStartedProcessingTime

void setStartedProcessingTime(long time)
Sets the started processing time.

Parameters:
time -

setContextObject

void setContextObject(String key,
                      Object value)
Set a value of a context object.

Parameters:
key - the key of the context object
value - the value of the context object
Since:
3.6

getContextObject

Object getContextObject(String key)
Returns the value of a context object.

Parameters:
key - the key of the context object to get
Returns:
the value of the context object for the given key
Since:
3.6


Terrier 3.6. Copyright © 2004-2011 University of Glasgow