public final class Parsable extends Object
This class encapsulates all the parameters required to call Parser.parse(Parsable)
. Because all set-
methods return a reference to self, you can write very compact calls to the parser:
parser.parse(new Parsable() .setQuery("foo") .setFilter("bar") .setDefaultIndexName("default") .setLanguage(Language.ENGLISH))
In case you are parsing the content of a Model
, you can use the fromQueryModel(Model)
factory for
convenience.
Constructor and Description |
---|
Parsable() |
Modifier and Type | Method and Description |
---|---|
Parsable |
addRestrict(String restrictName) |
Parsable |
addRestricts(Collection<String> restrictNames) |
Parsable |
addSource(String sourceName) |
Parsable |
addSources(Collection<String> sourceNames) |
static Parsable |
fromQueryModel(Model model) |
String |
getDefaultIndexName() |
Optional<com.yahoo.language.Language> |
getExplicitLanguage()
Returns the language explicitly set to be used when parsing, or empty if none is set.
|
String |
getFilter() |
com.yahoo.language.Language |
getLanguage()
Returns the language to use when parsing, or null to decide during parsing.
|
com.yahoo.language.Language |
getOrDetectLanguage(String languageDetectionText)
Returns the language to use when parsing, with a text to use for detection if necessary.
|
String |
getQuery() |
Set<String> |
getRestrict() |
Select |
getSelect() |
Set<String> |
getSources() |
Parsable |
setDefaultIndexName(String defaultIndexName) |
Parsable |
setExplicitLanguage(Optional<com.yahoo.language.Language> language) |
Parsable |
setFilter(String filter) |
Parsable |
setLanguage(com.yahoo.language.Language language) |
Parsable |
setModel(Model model) |
Parsable |
setQuery(String query) |
Parsable |
setSelect(Select select) |
public String getQuery()
public String getFilter()
public String getDefaultIndexName()
public com.yahoo.language.Language getLanguage()
public com.yahoo.language.Language getOrDetectLanguage(String languageDetectionText)
public Parsable setLanguage(com.yahoo.language.Language language)
public Optional<com.yahoo.language.Language> getExplicitLanguage()
public Parsable setExplicitLanguage(Optional<com.yahoo.language.Language> language)
public Parsable addSources(Collection<String> sourceNames)
public Parsable addRestricts(Collection<String> restrictNames)
public Select getSelect()
Copyright © 2018. All rights reserved.