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 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 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 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.
    string getAggregations()
    Client getClient()
         Client provider.
    string getConfigObject()
    struct getDSL()
    string getId()
    string getIndex()
    string getJSON()
    string getMatchType()
    string getMaxRows()
    string getQuery()
    string getScript()
    string getSorting()
    string getStartRow()
    string getType()
    SearchBuilder match(any name, any value, [numeric boost], [struct options], [string matchType='any'])
         Applies a match requirement to the search builder query.
    SearchBuilder multiMatch(array names, any value, [numeric boost])
         '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()
    any reset()
    any setAggregations(any aggregations)
    any setConfigObject(any configObject)
    any setId(any id)
    any setIndex(any index)
    any setMatchType(any matchType)
    any setMaxRows(any maxRows)
    any setQuery(any query)
    any setScript(any script)
    any setSorting(any sorting)
    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.
     
    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

    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

    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

    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


    getAggregations

    public string getAggregations()


    getClient

    public Client getClient()

    Client provider


    getConfigObject

    public string getConfigObject()


    getDSL

    public struct getDSL()


    getId

    public string getId()


    getIndex

    public string getIndex()


    getJSON

    public string getJSON()


    getMatchType

    public string getMatchType()


    getMaxRows

    public string getMaxRows()


    getQuery

    public string getQuery()


    getScript

    public string getScript()


    getSorting

    public string getSorting()


    getStartRow

    public string getStartRow()


    getType

    public string getType()


    match

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

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

    multiMatch

    public SearchBuilder multiMatch(array names, any value, [numeric boost])

    '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

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


    reset

    public any reset()


    setAggregations

    public any setAggregations(any aggregations)

    Parameters:
    aggregations

    setConfigObject

    public any setConfigObject(any configObject)

    Parameters:
    configObject

    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

    setQuery

    public any setQuery(any query)

    Parameters:
    query

    setScript

    public any setScript(any script)

    Parameters:
    script

    setSorting

    public any setSorting(any sorting)

    Parameters:
    sorting

    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