cbelasticsearch

Class SearchBuilder

lucee.Component
    extended by cbelasticsearch.SearchBuilder

Elasticsearch Search Builder Object

Class Attributes:
  • license : Apache v2.0
  •  
  • package : cbElasticsearch.models
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Jon Clausen
  •  
    Property Summary
    type property default serializable required
    any aggregations
          Property containing the struct representation of any query aggregations.

    • access = public
    • returntype = any
    true false
    any configObject


    • access = public
    • returntype = any
    • inject = Config@cbElasticsearch
    true false
    any highlight
          Property containing the struct representation of highlight.

    • access = public
    • returntype = any
    true false
    any id
          Property containing a document `_id`.

    • access = public
    • returntype = any
    true false
    any index
          Property containing the index name of the active builder search.

    • access = public
    • returntype = any
    true false
    any matchType
          When performing matching searches, the type of match to specify.

    • access = public
    • returntype = any
    true false
    any maxRows


    • access = public
    • returntype = any
    true false
    any params
          URL parameters which will be passed to transform the execution output.

    • access = public
    • returntype = any
    true false
    boolean preflight
          Whether to preflight the query prior to execution( recommended ) - ensures consistent formatting to prevent errors.

    • access = public
    • returntype = any
    true false
    any query
          Property containing the struct representation of the query being built.

    • access = public
    • returntype = any
    true false
    any script
          Property containing an elasticsearch scripting dsl string.

    • access = public
    • returntype = any
    true false
    any sorting
          Property containing an array of sort commands.

    • access = public
    • returntype = any
    true false
    any source
          Property containing the struct representation of any _source properties.

    • access = public
    • returntype = any
    true false
    any startRow


    • access = public
    • returntype = any
    true false
    any suggest
          Property containing the struct representation of suggest.

    • access = public
    • returntype = any
    true false
    any type
          Property containing the object type within the index.

    • access = public
    • returntype = any
    true false
    Method Summary
    SearchBuilder aggregation(string name, struct options)
         Adds an aggregation directive to the search parameters.
    any count()
         Counts the results of the currently built search.
    SearchBuilder dateMatch(string name, [string start], [string end], [numeric boost])
         `range` match for dates.
    any deleteAll()
         Deletes all documents matching the currently build search query.
    SearchBuilder disjunction(struct matches, [numeric tieBreaker])
         Performs a disjunctive search ( https://www.
    any execute()
         Persists the document to Elasticsearch.
    SearchBuilder filterTerm(string name, any value)
    SearchBuilder filterTerms(string name, any value)
    string getAggregations()
    Client getClient()
         Client provider.
    string getConfigObject()
    any getDSL()
    string getHighlight()
    string getId()
    string getIndex()
    string getJSON()
    string getMatchType()
    string getMaxRows()
    string getParams()
    string getPreflight()
    string getQuery()
    string getScript()
    string getSorting()
    string getSource()
    string getStartRow()
    string getSuggest()
    string getType()
    SearchBuilder highlight(struct highlight)
         Adds highlighting to search.
    SearchBuilder match(any name, any value, [numeric boost], [struct options], [string matchType='any'], [string type='best_fields'], [string minimumShouldMatch])
         Applies a match requirement to the search builder query.
    SearchBuilder multiMatch(array names, any value, [numeric boost], [string type='best_fields'])
         'multi_match' query alias for match().
    SearchBuilder mustExist(string name)
         Assigns a key which must exists to the query.
    SearchBuilder mustMatch(string name, any value, [numeric boost])
         `must` query alias for match().
    SearchBuilder mustNotExist(string name)
         Assigns a key which must not exist to the query.
    SearchBuilder mustNotMatch(string name, any value, [numeric boost])
         `must_not` query alias for match().
    SearchBuilder new([string index], [string type], [struct properties])
         Populates a new SearchBuilder object.
    any onDIComplete()
    SearchBuilder param(string name, any value)
         Adds a URL parameter to the request ( transformation, throttling, etc.
    void preflightQuery()
         Performs a preflight on the search.
    any reset()
    any setAggregations(any aggregations)
    any setConfigObject(any configObject)
    any setHighlight(any highlight)
    any setId(any id)
    any setIndex(any index)
    any setMatchType(any matchType)
    any setMaxRows(any maxRows)
    any setParams(any params)
    any setPreflight(boolean preflight)
    any setQuery(any query)
    any setScript(any script)
    any setSorting(any sorting)
    any setSource([any source])
    any setSourceExcludes([array excludes='[runtime expression]'])
    any setSourceIncludes([array includes='[runtime expression]'])
    any setStartRow(any startRow)
    any setSuggest(any suggest)
    any setType(any type)
    SearchBuilder shouldMatch(string name, any value, [numeric boost])
         `must` query alias for match().
    SearchBuilder sort(any sort, [any sortConfig])
         Applies a custom sort to the search query.
    SearchBuilder suggestCompletion(string text, string name, [string field='[runtime expression]'], [struct options='[runtime expression]'])
         Adds a completion to a search query.
    SearchBuilder suggestPhrase(string text, string name, [string field='[runtime expression]'], [struct options='[runtime expression]'])
         Adds a term suggestion to a search query.
    SearchBuilder suggestTerm(string text, string name, [string field='[runtime expression]'], [struct options='[runtime expression]'])
         Adds a term suggestion to a search query.
    SearchBuilder term(string name, any value, [numeric boost])
         Adds an exact value restriction ( elasticsearch: term ) to the query.
    SearchBuilder terms(string name, any value, [numeric boost])
         Adds an exact value restriction ( elasticsearch: term ) to the query.
     
    Methods inherited from class lucee.Component
    None

    Property Detail

    aggregations

    property any aggregations

    Property containing the struct representation of any query aggregations

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    configObject

    property any configObject

    Attributes:
    access - public
    required - false
    returntype - any
    inject - Config@cbElasticsearch
    serializable - true

    highlight

    property any highlight

    Property containing the struct representation of highlight

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    id

    property any id

    Property containing a document `_id`

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    index

    property any index

    Property containing the index name of the active builder search

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    matchType

    property any matchType

    When performing matching searches, the type of match to specify

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    maxRows

    property any maxRows

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    params

    property any params

    URL parameters which will be passed to transform the execution output

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    preflight

    property boolean preflight

    Whether to preflight the query prior to execution( recommended ) - ensures consistent formatting to prevent errors

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    query

    property any query

    Property containing the struct representation of the query being built

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    script

    property any script

    Property containing an elasticsearch scripting dsl string

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    sorting

    property any sorting

    Property containing an array of sort commands

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    source

    property any source

    Property containing the struct representation of any _source properties

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    startRow

    property any startRow

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    suggest

    property any suggest

    Property containing the struct representation of suggest

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    type

    property any type

    Property containing the object type within the index

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    Method Detail

    aggregation

    public SearchBuilder aggregation(string name, struct options)

    Adds an aggregation directive to the search parameters https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html

    Parameters:
    name - string the key of the aggregation
    options - struct the elasticsearch aggregation DSL struct

    count

    public any count()

    Counts the results of the currently built search


    dateMatch

    public SearchBuilder dateMatch(string name, [string start], [string end], [numeric boost])

    `range` match for dates

    Parameters:
    name - string the key to match
    start - string the preformatted date string to start the range
    end - string the preformatted date string to end the range
    boost - numeric the boost value of the match

    deleteAll

    public any deleteAll()

    Deletes all documents matching the currently build search query


    disjunction

    public SearchBuilder disjunction(struct matches, [numeric tieBreaker])

    Performs a disjunctive search ( https://www.elastic.co/guide/en/elasticsearch/guide/current/_tuning_best_fields_queries.html )

    Parameters:
    matches - struct A struct containing the matches
    tieBreaker

    execute

    public any execute()

    Persists the document to Elasticsearch


    filterTerm

    public SearchBuilder filterTerm(string name, any value)

    Parameters:
    name
    value

    filterTerms

    public SearchBuilder filterTerms(string name, any value)

    Parameters:
    name
    value

    getAggregations

    public string getAggregations()


    getClient

    public Client getClient()

    Client provider


    getConfigObject

    public string getConfigObject()


    getDSL

    public any getDSL()


    getHighlight

    public string getHighlight()


    getId

    public string getId()


    getIndex

    public string getIndex()


    getJSON

    public string getJSON()


    getMatchType

    public string getMatchType()


    getMaxRows

    public string getMaxRows()


    getParams

    public string getParams()


    getPreflight

    public string getPreflight()


    getQuery

    public string getQuery()


    getScript

    public string getScript()


    getSorting

    public string getSorting()


    getSource

    public string getSource()


    getStartRow

    public string getStartRow()


    getSuggest

    public string getSuggest()


    getType

    public string getType()


    highlight

    public SearchBuilder highlight(struct highlight)

    Adds highlighting to search https://www.elastic.co/guide/en/elasticsearch/reference/6.7/search-request-highlighting.html

    Parameters:
    highlight - struct the elasticsearch highlight DSL struct

    match

    public SearchBuilder match(any name, any value, [numeric boost], [struct options], [string matchType='any'], [string type='best_fields'], [string minimumShouldMatch])

    Applies a match requirement to the search builder query https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html pass in to the match parameters ( e.g. - operator, zero_terms_query, etc ) Valid options: - "any" - "all" - "phrase" - requires an exact match of a given phrase - "must" | "must_not" - specifies that any document returned must or must not match - "should" - specifies that any documents returned should match the value(s) provided

    Parameters:
    name - string|array the name of the key to search
    value - string the value of the key
    boost - numeric A numeric boost option for any exact matches
    options - struct An additional struct map of Elasticsearch query options to
    matchType - string a match type ( default="any" )
    type
    minimumShouldMatch

    multiMatch

    public SearchBuilder multiMatch(array names, any value, [numeric boost], [string type='best_fields'])

    'multi_match' query alias for match()

    Parameters:
    names - array an array of keys to search
    value - string the value of the key
    boost - numeric an optional boost value
    type

    mustExist

    public SearchBuilder mustExist(string name)

    Assigns a key which must exists to the query

    Parameters:
    name - string the name of the key to search

    mustMatch

    public SearchBuilder mustMatch(string name, any value, [numeric boost])

    `must` query alias for match()

    Parameters:
    name - string the name of the key to search
    value - string the value of the key
    boost

    mustNotExist

    public SearchBuilder mustNotExist(string name)

    Assigns a key which must not exist to the query

    Parameters:
    name - string the name of the key to search

    mustNotMatch

    public SearchBuilder mustNotMatch(string name, any value, [numeric boost])

    `must_not` query alias for match()

    Parameters:
    name - string the name of the key to search
    value - string the value of the key
    boost

    new

    public SearchBuilder new([string index], [string type], [struct properties])

    Populates a new SearchBuilder object

    Parameters:
    index - string the name of the index to search
    type - string the index type identifier
    properties - struct a struct representation of the search

    onDIComplete

    public any onDIComplete()


    param

    public SearchBuilder param(string name, any value)

    Adds a URL parameter to the request ( transformation, throttling, etc. ) Example https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html#_url_parameters

    Parameters:
    name - the name of the URL param
    value - the value of the param

    preflightQuery

    public void preflightQuery()

    Performs a preflight on the search ensures that a dynamically assembled query is well formatted before being passed on to elasticsearch


    reset

    public any reset()


    setAggregations

    public any setAggregations(any aggregations)

    Parameters:
    aggregations

    setConfigObject

    public any setConfigObject(any configObject)

    Parameters:
    configObject

    setHighlight

    public any setHighlight(any highlight)

    Parameters:
    highlight

    setId

    public any setId(any id)

    Parameters:
    id

    setIndex

    public any setIndex(any index)

    Parameters:
    index

    setMatchType

    public any setMatchType(any matchType)

    Parameters:
    matchType

    setMaxRows

    public any setMaxRows(any maxRows)

    Parameters:
    maxRows

    setParams

    public any setParams(any params)

    Parameters:
    params

    setPreflight

    public any setPreflight(boolean preflight)

    Parameters:
    preflight

    setQuery

    public any setQuery(any query)

    Parameters:
    query

    setScript

    public any setScript(any script)

    Parameters:
    script

    setSorting

    public any setSorting(any sorting)

    Parameters:
    sorting

    setSource

    public any setSource([any source])

    Parameters:
    source

    setSourceExcludes

    public any setSourceExcludes([array excludes='[runtime expression]'])

    Parameters:
    excludes

    setSourceIncludes

    public any setSourceIncludes([array includes='[runtime expression]'])

    Parameters:
    includes

    setStartRow

    public any setStartRow(any startRow)

    Parameters:
    startRow

    setSuggest

    public any setSuggest(any suggest)

    Parameters:
    suggest

    setType

    public any setType(any type)

    Parameters:
    type

    shouldMatch

    public SearchBuilder shouldMatch(string name, any value, [numeric boost])

    `must` query alias for match()

    Parameters:
    name - string the name of the key to search
    value - string the value of the key
    boost

    sort

    public SearchBuilder sort(any sort, [any sortConfig])

    Applies a custom sort to the search query may also accept a full struct representation, which will be appended to the custom sort

    Parameters:
    sort - any If passed as a string, the sortConfig argument is required,
    sortConfig - string A configuration - either a string or a full es-compatible sort configuration struct

    suggestCompletion

    public SearchBuilder suggestCompletion(string text, string name, [string field='[runtime expression]'], [struct options='[runtime expression]'])

    Adds a completion to a search query. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html

    Parameters:
    text - string The prefix text to match to a completion.
    name - string The name for the completion parameter.
    field - string The field name to match against. Uses the `name` if not provided.
    options - struct Any additional options to specify for the completion.

    suggestPhrase

    public SearchBuilder suggestPhrase(string text, string name, [string field='[runtime expression]'], [struct options='[runtime expression]'])

    Adds a term suggestion to a search query. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html

    Parameters:
    text - string The text to match to a term suggestion.
    name - string The name for the term suggestion parameter.
    field - string The field name to match against. Uses the `name` if not provided.
    options - struct Any additional options to specify for the term suggestion.

    suggestTerm

    public SearchBuilder suggestTerm(string text, string name, [string field='[runtime expression]'], [struct options='[runtime expression]'])

    Adds a term suggestion to a search query. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html

    Parameters:
    text - string The text to match to a term suggestion.
    name - string The name for the term suggestion parameter.
    field - string The field name to match against. Uses the `name` if not provided.
    options - struct Any additional options to specify for the term suggestion.

    term

    public SearchBuilder term(string name, any value, [numeric boost])

    Adds an exact value restriction ( elasticsearch: term ) to the query

    Parameters:
    name - string the name of the parameter to match
    value - any the value of the parameter to match
    boost - numeric A numeric boost option for any exact matches

    terms

    public SearchBuilder terms(string name, any value, [numeric boost])

    Adds an exact value restriction ( elasticsearch: term ) to the query

    Parameters:
    name - string the name of the parameter to match
    value - any the value of the parameter to match
    boost - numeric A numeric boost option for any exact matches