Class Model

  • All Implemented Interfaces:
    Cloneable

    public class Model
    extends Object
    implements Cloneable
    The parameters defining the recall of a query.
    Author:
    Arne Bergene Fossaa, bratseth
    • Constructor Detail

      • Model

        public Model​(Query query)
    • Method Detail

      • getParsingLanguage

        public com.yahoo.language.Language getParsingLanguage()
      • getParsingLanguage

        public com.yahoo.language.Language getParsingLanguage​(String languageDetectionText)
        Gets the language to use for parsing. If this is explicitly set in the model, that language is returned. Otherwise, if a query tree is already produced and any node in it specifies a language the first such node encountered in a depth first left to right search is returned. Otherwise the language is guessed from the query string. If this does not yield an actual language, English is returned as the default.
        Returns:
        the language determined, never null
      • getLanguage

        public com.yahoo.language.Language getLanguage()
        Returns the explicitly set parsing language of this query model, or null if none
      • setLanguage

        public void setLanguage​(com.yahoo.language.Language language)
        Explicitly sets the language to be used during parsing
      • setLanguage

        public void setLanguage​(String language)
        Explicitly sets the language to be used during parsing. The argument is first normalized by replacing underscores with hyphens (to support locale strings being used as RFC 5646 language tags), and then forwarded to setLocale(String) so that the Locale information of the tag is preserved.
        Parameters:
        language - The language string to parse.
        See Also:
        getLanguage(), setLocale(String)
      • getLocale

        public Locale getLocale()
        Returns the explicitly set parsing locale of this query model, or null if none.
        Returns:
        the locale of this
        See Also:
        setLocale(Locale)
      • setLocale

        public void setLocale​(String languageTag)
        Explicitly sets the locale to be used during parsing. This creates a Locale instance from the given language tag, and passes that to setLocale(Locale).
        Parameters:
        languageTag - the language tag to parse
        See Also:
        setLocale(Locale)
      • getEncoding

        public String getEncoding()
        Returns the encoding used in the query as a lowercase string
      • setEncoding

        public void setEncoding​(String encoding)
        Sets the encoding which was used in the received query string
      • setSearchPath

        public void setSearchPath​(String searchPath)
        Set the path for which backend nodes to forward the search too.
      • getSearchPath

        public String getSearchPath()
      • setQueryString

        public void setQueryString​(String queryString)
        Set the query from a string. This will not be parsed into a query tree until that tree is attempted accessed. Note that setting this will clear the current query tree. Usually, this should not be modified - changes to the query should be implemented as modifications on the query tree structure.

        Passing null causes this to be set to an empty string.

      • getQueryString

        public String getQueryString()
        Returns the query string which caused the original query tree of this model to come about. Note that changes to the query tree are not reflected in this query string. Note that changes to the query tree are not reflected in this query string.
        Returns:
        the original (or reassigned) query string - never null
      • getQueryTree

        public QueryTree getQueryTree()
        Returns the query as an object structure. Remember to have the correct Query.Type set. This causes parsing of the query string if it has changed since this was last called (i.e query parsing is lazy)
      • clearQueryTree

        public void clearQueryTree()
        Clears the parsed query such that it will be created anew from the textual representation (a query string or select.where expression) on the next access.
      • getFilter

        public String getFilter()
        Returns the filter string set for this query. The filter is included in the query tree at the time the query tree is parsed
      • setFilter

        public void setFilter​(String filter)
        Sets the filter string set for this query. The filter is included in the query tree at the time the query tree is parsed. Setting this does not cause the query to be reparsed.
      • getDefaultIndex

        public String getDefaultIndex()
        Returns the default index for this query. The default index is taken into account at the time the query tree is parsed.
      • setDefaultIndex

        public void setDefaultIndex​(String defaultIndex)
        Sets the default index for this query. The default index is taken into account at the time the query tree is parsed. Setting this does not cause the query to be reparsed.
      • getType

        public Query.Type getType()
        Sets the query type of for this query. The type is taken into account at the time the query tree is parsed.
      • setType

        public void setType​(Query.Type type)
        Sets the query type of for this query. The type is taken into account at the time the query tree is parsed. Setting this does not cause the query to be reparsed.
      • setType

        public void setType​(String typeString)
        Sets the query type of for this query. The type is taken into account at the time the query tree is parsed. Setting this does not cause the query to be reparsed.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getParent

        public Query getParent()
        returns the query owning this, never null
      • setParent

        public void setParent​(Query parent)
        Assigns the query owning this
      • setSources

        public void setSources​(String sourceString)
        Sets the set of sources this query will search from a comma-separated string of source names
      • getSources

        public Set<String> getSources()
        Returns the set of sources this query will search. This set can be modified to change the set of sources. If all sources are to be searched, this returns an empty set
        Returns:
        the set of sources to search, never null
      • setRestrict

        public void setRestrict​(String restrictString)
        Sets the set of types (document type or search definition names) this query will search from a comma-separated string of type names. This is useful to narrow a search to just a subset of the types available from a sources
      • getRestrict

        public Set<String> getRestrict()
        Returns the set of types this query will search. This set can be modified to change the set of types. If all types are to be searched, this returns an empty set.
        Returns:
        the set of types to search, never null
      • setExecution

        public void setExecution​(Execution execution)
        Sets the execution working on this. For internal use.
      • setDocumentDb

        public void setDocumentDb​(String documentDbName)
        Sets the document database this will search - a document type
      • getDocumentDb

        public String getDocumentDb()
        Returns the name of the document db this should search, or null if not set.
      • getExecution

        public Execution getExecution()
        Returns the Execution working on this, or a null execution if none. For internal use.
      • getFrom

        public static Model getFrom​(Query q)
      • prepare

        public void prepare​(Ranking ranking)
        Prepares this for binary serialization. For internal use.