Class Request

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, SearchRequest

    public class Request
    extends java.lang.Object
    implements SearchRequest, java.lang.Cloneable
    Request contains the details of the search engine for one query, including the query itself, the resultset, the controls and the context objects. Controls set application specific parameters, which often load post processes, and postfilters, or set matching parameter. Context objects are arbitrary objects which you are passing to the post processes or postfilters. Controls often depict modules to be used for each stage of a query:
    • The matching and weighting modules to be used
    • Process modules to apply transforms to the query or resultset
    • postFilter modules to apply transforms to the resultset
    A Request is an implementation of the SearchRequest interface. Additionally, the Request holds all the controls set for this query.
    Author:
    Craig Macdonald, Dyaa Albakour
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​java.lang.Object> contextObjects
      Context object Map that can hold object values.
      protected java.util.Map<java.lang.String,​java.lang.String> Control
      Controls are querying stage flags and variables.
      protected boolean EmptyQuery
      does the query have any terms.
      protected Index index
      index will not be passed across RMI
      protected MatchingQueryTerms matchingTerms
      This is an aggregated form of the query terms, suitable for matching, which requires term frequencies for each term.
      protected int numOfDocsAfterFiltering
      The number of documents returned after performing post filtering
      protected java.lang.String originalQuery
      The query text, before applying any pre-processsing
      protected Query q
      This contains the parsed syntax tree of the query, as generated by the Antlr parser
      protected java.lang.String QueryID
      QueryID - used by TREC querying and output format for supporting relevance assessments
      protected ResultSet resultSet
      This is the resultset of the query.
    • Constructor Summary

      Constructors 
      Constructor Description
      Request()  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      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
      Request clone()  
      java.lang.Object getContextObject​(java.lang.String key)
      Returns the value of a context object.
      java.lang.String getControl​(java.lang.String Name)
      Returns the value of the control.
      java.lang.String getControl​(java.lang.String Name, java.lang.String Default)
      Returns the value of the control.
      java.util.Map<java.lang.String,​java.lang.String> getControls()
      Get the entire hashtable used for storing controls for this query
      Index getIndex()
      Returns the index to be used for this query
      java.lang.String getMatchingModel()
      Deprecated.
      MatchingQueryTerms getMatchingQueryTerms()
      Return the MatchingQueryTerms object to use for matching
      int getNumberOfDocumentsAfterFiltering()
      returns the number of documents in the result set after applying post filters.
      java.lang.String getOriginalQuery()
      gets the string of the original query, before applying any pre-processing.
      Query getQuery()
      Get the Query syntax tree
      java.lang.String getQueryID()
      Returns the query id as set by setQueryID(String).
      ScoredDocList getResults()
      Get the results
      ResultSet getResultSet()
      Returns the resultset generated by the query.
      long getStartedProcessingTime()
      returns the time when the processing of the request started.
      java.lang.String getWeightingModel()
      Deprecated.
      boolean isEmpty()
      Set if the query input had no terms.
      void setContextObject​(java.lang.String key, java.lang.Object value)
      Set a value of a context object.
      void setControl​(java.lang.String Name, java.lang.String Value)
      Set a control named to have value Value.
      void setControls​(java.util.Map<java.lang.String,​java.lang.String> controls)
      Use this hashtable to store controls and their values in
      void setEmpty​(boolean in)
      force this query to be seen as containing (no) terms.
      void setIndex​(Index _index)
      Set the index to be used for this query
      void setMatchingQueryTerms​(MatchingQueryTerms mqts)
      Used by runPreProcessing after the query tree has been aggregated into a list of terms, each containing frequencies.
      void setNumberOfDocumentsAfterFiltering​(int n)
      sets the number of documents in the result set, after applying post filters.
      void setOriginalQuery​(java.lang.String _q)
      sets the string of the original query, before applying any pre-processing
      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 setResultSet​(ResultSet results)
      Set the result set returned by this object to be this results.
      void setStartedProcessingTime​(long _startedProcessingTime)
      sets the time when the processing of the request started
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EmptyQuery

        protected boolean EmptyQuery
        does the query have any terms. Used by Manager.runMatching() to short circuit the matching process - if this is set, then a resultset with 0 documents is created automatically.
      • QueryID

        protected java.lang.String QueryID
        QueryID - used by TREC querying and output format for supporting relevance assessments
      • Control

        protected java.util.Map<java.lang.String,​java.lang.String> Control
        Controls are querying stage flags and variables. These are typically set by defaults in the configuration file, or by flags in the query itself (if querying.HTTPSearchEngine is used). They often depict which pre, matching, post and output modules will be used.
      • contextObjects

        protected java.util.Map<java.lang.String,​java.lang.Object> contextObjects
        Context object Map that can hold object values.
      • q

        protected Query q
        This contains the parsed syntax tree of the query, as generated by the Antlr parser
      • originalQuery

        protected java.lang.String originalQuery
        The query text, before applying any pre-processsing
      • numOfDocsAfterFiltering

        protected int numOfDocsAfterFiltering
        The number of documents returned after performing post filtering
      • resultSet

        protected ResultSet resultSet
        This is the resultset of the query. It is provided by the matching/weighting stage, and may be operated on (eg decorated) by PostProcesses and PostFilters
      • matchingTerms

        protected MatchingQueryTerms matchingTerms
        This is an aggregated form of the query terms, suitable for matching, which requires term frequencies for each term.
      • index

        protected transient Index index
        index will not be passed across RMI
    • Constructor Detail

      • Request

        public Request()
    • Method Detail

      • addMatchingModel

        public 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
        Specified by:
        addMatchingModel in interface SearchRequest
        Parameters:
        MatchingModelName - the String class name that should be used
        WeightingModelName - the String class name that should be used
      • setQuery

        public 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

        public void setQueryID​(java.lang.String qid)
        Set a unique identifier for this query request.
        Specified by:
        setQueryID in interface SearchRequest
        Parameters:
        qid - the unique string identifier
      • setIndex

        public void setIndex​(Index _index)
        Set the index to be used for this query
      • getIndex

        public Index getIndex()
        Returns the index to be used for this query
      • setControl

        public 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.
        Specified by:
        setControl in interface SearchRequest
        Parameters:
        Name - the name of the control to set the value of.
        Value - the value that the control should take.
      • getControl

        public java.lang.String getControl​(java.lang.String Name)
        Returns the value of the control. Null or empty string if not set.
        Specified by:
        getControl in interface SearchRequest
        Returns:
        the value.
      • getControl

        public java.lang.String getControl​(java.lang.String Name,
                                           java.lang.String Default)
        Returns the value of the control. Null or empty string if not set.
        Specified by:
        getControl in interface SearchRequest
        Returns:
        the value.
      • getResultSet

        public ResultSet getResultSet()
        Returns the resultset generated by the query. Before retrieving this you probably need to have run Manager.runSearchRequest().
        Returns:
        ResultSet the raw matching resultset - ie the set of document Ids and their scores.
      • getQueryID

        public java.lang.String getQueryID()
        Returns the query id as set by setQueryID(String).
        Specified by:
        getQueryID in interface SearchRequest
        Returns:
        the query Id as a string.
      • getQuery

        public Query getQuery()
        Get the Query syntax tree
        Returns:
        The query object as set with setQuery.
      • isEmpty

        public boolean isEmpty()
        Set if the query input had no terms.
        Specified by:
        isEmpty in interface SearchRequest
        Returns:
        true if the query has no terms.
      • getWeightingModel

        @Deprecated
        public java.lang.String getWeightingModel()
        Deprecated.
        returns the name of the weighting model that should be used for retrieval
      • getMatchingModel

        @Deprecated
        public java.lang.String getMatchingModel()
        Deprecated.
        returns the name of the matching model that should be used for retrieval
      • setResultSet

        public void setResultSet​(ResultSet results)
        Set the result set returned by this object to be this results.
      • getControls

        public java.util.Map<java.lang.String,​java.lang.String> getControls()
        Get the entire hashtable used for storing controls for this query
        Specified by:
        getControls in interface SearchRequest
      • setEmpty

        public void setEmpty​(boolean in)
        force this query to be seen as containing (no) terms.
        Parameters:
        in - set to true for query to be seen empty.
      • setMatchingQueryTerms

        public void setMatchingQueryTerms​(MatchingQueryTerms mqts)
        Used by runPreProcessing after the query tree has been aggregated into a list of terms, each containing frequencies.
        Parameters:
        mqts - The matchingqueryterms to use for matching.
      • getMatchingQueryTerms

        public MatchingQueryTerms getMatchingQueryTerms()
        Return the MatchingQueryTerms object to use for matching
      • setControls

        public void setControls​(java.util.Map<java.lang.String,​java.lang.String> controls)
        Use this hashtable to store controls and their values in
      • setOriginalQuery

        public void setOriginalQuery​(java.lang.String _q)
        sets the string of the original query, before applying any pre-processing
        Specified by:
        setOriginalQuery in interface SearchRequest
      • getOriginalQuery

        public java.lang.String getOriginalQuery()
        gets the string of the original query, before applying any pre-processing.
        Specified by:
        getOriginalQuery in interface SearchRequest
      • setNumberOfDocumentsAfterFiltering

        public void setNumberOfDocumentsAfterFiltering​(int n)
        sets the number of documents in the result set, after applying post filters.
        Specified by:
        setNumberOfDocumentsAfterFiltering in interface SearchRequest
      • getNumberOfDocumentsAfterFiltering

        public int getNumberOfDocumentsAfterFiltering()
        returns the number of documents in the result set after applying post filters.
        Specified by:
        getNumberOfDocumentsAfterFiltering in interface SearchRequest
        Returns:
        the number of documents returned for a search request. integer.
      • getStartedProcessingTime

        public long getStartedProcessingTime()
        returns the time when the processing of the request started.
        Specified by:
        getStartedProcessingTime in interface SearchRequest
        Returns:
        time long
      • setStartedProcessingTime

        public void setStartedProcessingTime​(long _startedProcessingTime)
        sets the time when the processing of the request started
        Specified by:
        setStartedProcessingTime in interface SearchRequest
        Parameters:
        _startedProcessingTime - the time obtained from a call to System.currentTimeMillis()
      • setContextObject

        public void setContextObject​(java.lang.String key,
                                     java.lang.Object value)
        Set a value of a context object.
        Specified by:
        setContextObject in interface SearchRequest
        Parameters:
        key - the key of the context object
        value - the value of the context object
      • getContextObject

        public java.lang.Object getContextObject​(java.lang.String key)
        Returns the value of a context object.
        Specified by:
        getContextObject in interface SearchRequest
        Parameters:
        key - the key of the context object to get
        Returns:
        the value of the context object for the given key
      • clone

        public Request clone()
        Overrides:
        clone in class java.lang.Object