Package com.yahoo.search.query
Class Model
- java.lang.Object
-
- com.yahoo.search.query.Model
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_INDEX
static String
ENCODING
static com.yahoo.processing.request.CompoundName
ESTIMATE
The name of the query property used for generating hit count estimate queries.static String
FILTER
static String
LANGUAGE
static String
LOCALE
static String
MODEL
static String
PROGRAM
static String
QUERY_STRING
static String
RESTRICT
static String
SEARCH_PATH
static String
SOURCES
static String
TYPE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.Object
clone()
Model
cloneFor(Query q)
boolean
equals(Object o)
static QueryProfileType
getArgumentType()
String
getDefaultIndex()
Returns the default index for this query.String
getDocumentDb()
Returns the name of the document db this should search, or null if not set.String
getEncoding()
Returns the encoding used in the query as a lowercase stringExecution
getExecution()
Returns the Execution working on this, or a null execution if none.String
getFilter()
Returns the filter string set for this query.static Model
getFrom(Query q)
com.yahoo.language.Language
getLanguage()
Returns the explicitly set parsing language of this query model, or null if noneLocale
getLocale()
Returns the explicitly set parsing locale of this query model, or null if none.Query
getParent()
returns the query owning this, never nullcom.yahoo.language.Language
getParsingLanguage()
com.yahoo.language.Language
getParsingLanguage(String languageDetectionText)
Gets the language to use for parsing.String
getQueryString()
Returns the query string which caused the original query tree of this model to come about.QueryTree
getQueryTree()
Returns the query as an object structure.Set<String>
getRestrict()
Returns the set of types this query will search.String
getSearchPath()
Set<String>
getSources()
Returns the set of sources this query will search.Query.Type
getType()
Sets the query type of for this query.int
hashCode()
void
prepare(Ranking ranking)
Prepares this for binary serialization.void
setDefaultIndex(String defaultIndex)
Sets the default index for this query.void
setDocumentDb(String documentDbName)
Sets the document database this will search - a document typevoid
setEncoding(String encoding)
Sets the encoding which was used in the received query stringvoid
setExecution(Execution execution)
Sets the execution working on this.void
setFilter(String filter)
Sets the filter string set for this query.void
setLanguage(com.yahoo.language.Language language)
Explicitly sets the language to be used during parsingvoid
setLanguage(String language)
Explicitly sets the language to be used during parsing.void
setLocale(String languageTag)
Explicitly sets the locale to be used during parsing.void
setLocale(Locale locale)
Explicitly sets the locale to be used during parsing.void
setParent(Query parent)
Assigns the query owning thisvoid
setQueryString(String queryString)
Set the query from a string.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.void
setSearchPath(String searchPath)
Set the path for which backend nodes to forward the search too.void
setSources(String sourceString)
Sets the set of sources this query will search from a comma-separated string of source namesvoid
setType(Query.Type type)
Sets the query type of for this query.void
setType(String typeString)
Sets the query type of for this query.String
toString()
-
-
-
Field Detail
-
MODEL
public static final String MODEL
- See Also:
- Constant Field Values
-
PROGRAM
public static final String PROGRAM
- See Also:
- Constant Field Values
-
QUERY_STRING
public static final String QUERY_STRING
- See Also:
- Constant Field Values
-
TYPE
public static final String TYPE
- See Also:
- Constant Field Values
-
FILTER
public static final String FILTER
- See Also:
- Constant Field Values
-
DEFAULT_INDEX
public static final String DEFAULT_INDEX
- See Also:
- Constant Field Values
-
LANGUAGE
public static final String LANGUAGE
- See Also:
- Constant Field Values
-
LOCALE
public static final String LOCALE
- See Also:
- Constant Field Values
-
ENCODING
public static final String ENCODING
- See Also:
- Constant Field Values
-
SOURCES
public static final String SOURCES
- See Also:
- Constant Field Values
-
SEARCH_PATH
public static final String SEARCH_PATH
- See Also:
- Constant Field Values
-
RESTRICT
public static final String RESTRICT
- See Also:
- Constant Field Values
-
ESTIMATE
public static final com.yahoo.processing.request.CompoundName ESTIMATE
The name of the query property used for generating hit count estimate queries.
-
-
Constructor Detail
-
Model
public Model(Query query)
-
-
Method Detail
-
getArgumentType
public static QueryProfileType getArgumentType()
-
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 tosetLocale(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(Locale locale)
Explicitly sets the locale to be used during parsing. This method also callssetLanguage(Language)
with the correspondingLanguage
instance.- Parameters:
locale
- the locale to set- See Also:
getLocale()
,setLanguage(Language)
-
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 tosetLocale(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.
-
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.
-
prepare
public void prepare(Ranking ranking)
Prepares this for binary serialization. For internal use.
-
-