Class Parsable

java.lang.Object
com.yahoo.search.query.parser.Parsable

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.

Author:
Simon Thoresen Hult
  • Constructor Details

    • Parsable

      public Parsable()
  • Method Details

    • getQuery

      public String getQuery()
    • setQuery

      public Parsable setQuery(String query)
    • getFilter

      public String getFilter()
    • setFilter

      public Parsable setFilter(String filter)
    • getDefaultIndexName

      public String getDefaultIndexName()
    • setDefaultIndexName

      public Parsable setDefaultIndexName(String defaultIndexName)
    • getLanguage

      public com.yahoo.language.Language getLanguage()
      Returns the language to use when parsing, or null to decide during parsing.
    • getOrDetectLanguage

      public com.yahoo.language.Language getOrDetectLanguage(String languageDetectionText)
      Returns the language to use when parsing, with a text to use for detection if necessary. if not decided by the item under parsing. This is never null or UNKNOWN
    • setLanguage

      public Parsable setLanguage(com.yahoo.language.Language language)
    • getExplicitLanguage

      public Optional<com.yahoo.language.Language> getExplicitLanguage()
      Returns the language explicitly set to be used when parsing, or empty if none is set.
    • setExplicitLanguage

      public Parsable setExplicitLanguage(Optional<com.yahoo.language.Language> language)
    • setModel

      public Parsable setModel(Model model)
    • getSources

      public Set<String> getSources()
    • addSource

      public Parsable addSource(String sourceName)
    • addSources

      public Parsable addSources(Collection<String> sourceNames)
    • getRestrict

      public Set<String> getRestrict()
    • addRestrict

      public Parsable addRestrict(String restrictName)
    • addRestricts

      public Parsable addRestricts(Collection<String> restrictNames)
    • setSelect

      public Parsable setSelect(Select select)
    • getSelect

      public Select getSelect()
    • fromQueryModel

      public static Parsable fromQueryModel(Model model)