org.terrier.querying
Interface SearchRequest

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
Request

public interface SearchRequest
extends java.io.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 = new Index()
 Manager manager = new Manager(index);
 SearchRequest srq = manager.newSearchRequest();
 //parse the query
 TerrierLexer lexer = new TerrierLexer(new StringReader(query));
 TerrierFloatLexer flexer = new TerrierFloatLexer(lexer.getInputState());

 TokenStreamSelector selector = new TokenStreamSelector();
 selector.addInputStream(lexer, "main");
 selector.addInputStream(flexer, "numbers");
 selector.select("main");
 TerrierQueryParser parser = new TerrierQueryParser(selector);
 parser.setSelector(selector);

 srq.setQuery(parser.query());
 srq.setQuery(query);
 //run the query
 m.runPreProcessing(srq);
 manager.runMatching(srq);
 manager.runPostProcess(srq);
 manager.runPostFilters(srq);
 

NB:Controls (name, value tuples ) are used to control the retrieval prcoess. 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.


Method Summary
 void addMatchingModel(java.lang.String MatchingModelName, java.lang.String WeightingModelName)
          Set the matching model and weighting model that the Manager should use for this query.
 java.lang.String getControl(java.lang.String Name)
          Returns the value of the control.
 int getNumberOfDocumentsAfterFiltering()
          gets the number of documents returned for a search request, after applying post filtering
 java.lang.String getOriginalQuery()
          gets the original query, before any preprocessing
 Query getQuery()
          Get the Query syntax tree
 java.lang.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 setControl(java.lang.String Name, java.lang.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(java.lang.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(java.lang.String qid)
          Set a unique identifier for this query request.
 void setStartedProcessingTime(long time)
          Sets the started processing time.
 

Method Detail

addMatchingModel

void addMatchingModel(java.lang.String MatchingModelName,
                      java.lang.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(java.lang.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(java.lang.String Name,
                java.lang.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

java.lang.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

java.lang.String getControl(java.lang.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(java.lang.String q)
sets the original query, before any preprocessing


getOriginalQuery

java.lang.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 -


Terrier 3.5. Copyright © 2004-2011 University of Glasgow