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:
     IndexRef indexref = IndexRef.of("/path/to/my/index/data.properties");
     IManager manager = ManagerFactor.from(indexref);
     SearchRequest srq = manager.newSearchRequest("my query");
     //run the query
     manager.runSearchRequest(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 Detail

      • addMatchingModel

        void addMatchingModel​(java.lang.String MatchingModelName,
                              java.lang.String WeightingModelName)
        Deprecated.
        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
      • setQueryID

        void setQueryID​(java.lang.String qid)
        Set a unique identifier for this query request.
        Parameters:
        qid - the unique string identifier
      • 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.
      • getControls

        java.util.Map<java.lang.String,​java.lang.String> getControls()
      • hasControl

        default boolean hasControl​(java.lang.String Name)
      • getControl

        java.lang.String getControl​(java.lang.String Name)
        Returns the value of the control.empty string if not set.
        Returns:
        the value.
      • getControl

        default java.lang.String getControl​(java.lang.String Name,
                                            java.lang.String Default)
        Returns the value of the control, or Default 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 -
      • setContextObject

        void setContextObject​(java.lang.String key,
                              java.lang.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

        java.lang.Object getContextObject​(java.lang.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