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
    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 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.
    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.
    any filterTerm(string name, any value)
    any filterTerms(string name, any value)
    string getAggregations()
    Client getClient()
         Client provider.
    string getConfigObject()
    struct getDSL()
    string getHighlight()
    string getId()
    string getIndex()
    string getJSON()
    string getMatchType()
    string getMaxRows()
    string getPreflight()
    string getQuery()
    string getScript()
    string getSorting()
    string getSource()
    string getStartRow()
    string getType()
    SearchBuilder highLight(any 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 mustMatch(string name, any value, [numeric boost])
         `must` query alias for match().
    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()
    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 setPreflight(boolean preflight)
    any setQuery(any query)
    any setScript(any script)
    any setSorting(any sorting)
    any setSource([struct source='[runtime expression]'])
    any setSourceExcludes([array excludes='[runtime expression]'])
    any setSourceIncludes([array includes='[runtime expression]'])
    any setStartRow(any startRow)
    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 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

    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

    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

    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 any filterTerm(string name, any value)

    Parameters:
    name
    value

    filterTerms

    public any filterTerms(string name, any value)

    Parameters:
    name
    value

    getAggregations

    public string getAggregations()


    getClient

    public Client getClient()

    Client provider


    getConfigObject

    public string getConfigObject()


    getDSL

    public struct 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()


    getPreflight

    public string getPreflight()


    getQuery

    public string getQuery()


    getScript

    public string getScript()


    getSorting

    public string getSorting()


    getSource

    public string getSource()


    getStartRow

    public string getStartRow()


    getType

    public string getType()


    highLight

    public SearchBuilder highLight(any 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

    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

    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()


    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

    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([struct source='[runtime expression]'])

    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

    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

    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