cbelasticsearch

Class JestClient

lucee.Component
    extended by cbelasticsearch.JestClient
All Implemented Interfaces:
iNativeClient

Elasticsearch JEST Native Client https://github.com/searchbox-io/Jest

Class Attributes:
  • threadsafe
  •  
  • singleton
  •  
  • license : Apache v2.0
  •  
  • package : cbElasticsearch.models
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Jon Clausen
  •  
    Property Summary
    type property default serializable required
    any HTTPClient
          The HTTP Jest Client.

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


    • access = public
    • returntype = any
    • inject = loader@cbjavaloader
    true false
    any log


    • access = public
    • returntype = any
    • inject = logbox:logger:{this}
    true false
    any versionTarget
          The Elasticsearch version target for this client.

    • access = public
    • returntype = any
    true false
    Method Summary
    boolean applyAliases(any aliases)
         Applies an alias (or array of aliases).
    boolean applyIndex(IndexBuilder indexBuilder)
         Applies an index item ( create/update ).
    struct applyMapping(string indexName, [string mappingName], struct mappingConfig)
         Applies a single mapping to an index.
    struct applyMappings(string indexName, struct mappings)
         Applies multiple mappings to an index.
    private any buildDeleteAction(Document document)
    private any buildUpdateAction(Document document)
    void close()
         Closes any connections to the pool and destroys the client singleton.
    void configure()
    numeric count([SearchBuilder searchBuilder])
         Retreives a count of documents matching the given query.
    boolean delete(any document, [boolean throwOnError='true'])
         Deletes a single document.
    any deleteAll(array documents, [boolean throwOnError='false'])
         Deletes documents from an array of documents or IDs.
    boolean deleteByQuery(SearchBuilder searchBuilder)
         Deletes items in the index by query.
    struct deleteIndex(string indexName)
         Deletes an index.
    boolean deleteMapping(string indexName, string mapping, [boolean throwOnError='false'])
         Deletes a mapping.
    any execute(any action, [any returnObject='false'])
         Executes an HTTP client transaction.
    SearchResult executeSearch(SearchBuilder searchBuilder)
         Execute a client search request.
    private any generateIndexMap(any index)
    any get(any id, [string index], [string type])
         Retrieves a document by ID.
    Config getConfig()
         Config provider.
    string getHTTPClient()
    string getJLoader()
    string getLog()
    array getMultiple(array keys, [string index], [string type])
         Gets multiple items when provided an array of keys.
    string getVersionTarget()
    boolean indexExists(string indexName)
         Verifies whether an index exists.
    boolean indexMappingExists(string indexName, string mapping)
         Verifies whether an index mapping exists.
    private boolean isMajorVersion(numeric versionNumber)
         Returns a boolean as to whether the target version matches a major version.
    SearchBuilder newBuilder()
         SearchBuilder provider.
    Document newDocument()
         Document provider.
    SearchResult newResult()
         SearchResult provider.
    any onDIComplete()
         Configure instance once DI is complete.
    struct reindex(any source, any destination, [boolean waitForCompletion='true'])
         Applies a reindex action.
    Document save(Document document)
    array saveAll(array documents)
         Persists multiple items to the index.
    any setHTTPClient(any HTTPClient)
    any setJLoader(any jLoader)
    any setLog(any log)
    any setVersionTarget(any versionTarget)
    boolean updateByQuery(SearchBuilder searchBuilder, struct script)
         Updates items in the index by query.
     
    Methods inherited from class lucee.Component
    None

    Property Detail

    HTTPClient

    property any HTTPClient

    The HTTP Jest Client

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

    jLoader

    property any jLoader

    Attributes:
    access - public
    required - false
    returntype - any
    inject - loader@cbjavaloader
    serializable - true

    log

    property any log

    Attributes:
    access - public
    required - false
    returntype - any
    inject - logbox:logger:{this}
    serializable - true

    versionTarget

    property any versionTarget

    The Elasticsearch version target for this client

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

    Method Detail

    applyAliases

    public boolean applyAliases(any aliases)

    Applies an alias (or array of aliases)

    Specified by:
    applyAliases in interface iNativeClient
    Parameters:
    aliases - AliasBuilder An AliasBuilder instance (or array of instances)
    Returns:
    boolean Boolean result as to whether the operations were successful

    applyIndex

    public boolean applyIndex(IndexBuilder indexBuilder)

    Applies an index item ( create/update )

    Specified by:
    applyIndex in interface iNativeClient
    Parameters:
    indexBuilder - IndexBuilder An instance of the IndexBuilder object
    Returns:
    struct A struct representation of the transaction result

    applyMapping

    public struct applyMapping(string indexName, [string mappingName], struct mappingConfig)

    Applies a single mapping to an index

    Specified by:
    applyMapping in interface iNativeClient
    Parameters:
    indexName - string the name of the index
    mappingName - string the name of the mapping
    mappingConfig - struct the mapping configuration struct

    applyMappings

    public struct applyMappings(string indexName, struct mappings)

    Applies multiple mappings to an index

    Specified by:
    applyMappings in interface iNativeClient
    Parameters:
    indexName - string The name of the index
    mappings - struct a struct containing the mapping configuration

    buildDeleteAction

    private any buildDeleteAction(Document document)

    Parameters:
    document

    buildUpdateAction

    private any buildUpdateAction(Document document)

    Parameters:
    document

    close

    public void close()

    Closes any connections to the pool and destroys the client singleton

    Specified by:
    close in interface iNativeClient

    configure

    public void configure()


    count

    public numeric count([SearchBuilder searchBuilder])

    Retreives a count of documents matching the given query

    Specified by:
    count in interface iNativeClient
    Parameters:
    searchBuilder - [SearchBuilder] An instance of the SearchBuilder object
    Returns:
    numeric The returned count matching the search parameters

    delete

    public boolean delete(any document, [boolean throwOnError='true'])

    Deletes a single document

    Specified by:
    delete in interface iNativeClient
    Parameters:
    document - Document the Document object for the document to be deleted
    throwOnError - boolean whether to throw an error if the document cannot be deleted ( default: false )

    deleteAll

    public any deleteAll(array documents, [boolean throwOnError='false'])

    Deletes documents from an array of documents or IDs

    Specified by:
    deleteAll in interface iNativeClient
    Parameters:
    documents - array Either an array of Document objects
    throwOnError - boolean whether to throw an error if the document cannot be deleted ( default: false )

    deleteByQuery

    public boolean deleteByQuery(SearchBuilder searchBuilder)

    Deletes items in the index by query

    Specified by:
    deleteByQuery in interface iNativeClient
    Parameters:
    searchBuilder - SearchBuilder The search builder object to use for the query

    deleteIndex

    public struct deleteIndex(string indexName)

    Deletes an index

    Specified by:
    deleteIndex in interface iNativeClient
    Parameters:
    indexName - string the name of the index to be deleted

    deleteMapping

    public boolean deleteMapping(string indexName, string mapping, [boolean throwOnError='false'])

    Deletes a mapping

    Specified by:
    deleteMapping in interface iNativeClient
    Parameters:
    indexName - string the name of the index which contains the mapping
    mapping - string the mapping ( e.g. type ) to delete
    throwOnError - boolean Whether to throw an error if the mapping could not be deleted ( default=false )
    Returns:
    struct the deletion transaction response

    execute

    public any execute(any action, [any returnObject='false'])

    Executes an HTTP client transaction

    Parameters:
    action - any A valid Jest client action
    returnObject - boolean Whether to return the JestResult, default to false, which returns a struct

    executeSearch

    public SearchResult executeSearch(SearchBuilder searchBuilder)

    Execute a client search request

    Specified by:
    executeSearch in interface iNativeClient
    Parameters:
    searchBuilder - SearchBuilder An instance of the SearchBuilder object
    Returns:
    iNativeClient An implementation of the iNativeClient

    generateIndexMap

    private any generateIndexMap(any index)

    Parameters:
    index

    get

    public any get(any id, [string index], [string type])

    Retrieves a document by ID

    Specified by:
    get in interface iNativeClient
    Parameters:
    id - any The document key
    index - string The name of the index
    type - type The name of the type
    Returns:
    any Returns a Document object if found, otherwise returns null

    getConfig

    public Config getConfig()

    Config provider


    getHTTPClient

    public string getHTTPClient()


    getJLoader

    public string getJLoader()


    getLog

    public string getLog()


    getMultiple

    public array getMultiple(array keys, [string index], [string type])

    Gets multiple items when provided an array of keys

    Specified by:
    getMultiple in interface iNativeClient
    Parameters:
    keys - array An array of keys to retrieve
    index - string The name of the index
    type - type The name of the type
    Returns:
    array An array of Document objects

    getVersionTarget

    public string getVersionTarget()


    indexExists

    public boolean indexExists(string indexName)

    Verifies whether an index exists

    Specified by:
    indexExists in interface iNativeClient
    Parameters:
    indexName - string the name of the index

    indexMappingExists

    public boolean indexMappingExists(string indexName, string mapping)

    Verifies whether an index mapping exists

    Specified by:
    indexMappingExists in interface iNativeClient
    Parameters:
    indexName - string the name of the index
    mapping - string the name of the mapping

    isMajorVersion

    private boolean isMajorVersion(numeric versionNumber)

    Returns a boolean as to whether the target version matches a major version

    Parameters:
    versionNumber - true

    newBuilder

    public SearchBuilder newBuilder()

    SearchBuilder provider


    newDocument

    public Document newDocument()

    Document provider


    newResult

    public SearchResult newResult()

    SearchResult provider


    onDIComplete

    public any onDIComplete()

    Configure instance once DI is complete


    reindex

    public struct reindex(any source, any destination, [boolean waitForCompletion='true'])

    Applies a reindex action

    Specified by:
    reindex in interface iNativeClient
    Parameters:
    source - string The source index name or struct of options
    destination - string The destination index name or struct of options
    waitForCompletion
    Returns:
    struct Struct result of the reindex action

    save

    public Document save(Document document)

    Specified by:
    save in interface iNativeClient
    Parameters:
    document - Document@cbElasticSearch An instance of the elasticsearch Document object
    Returns:
    iNativeClient An implementation of the iNativeClient

    saveAll

    public array saveAll(array documents)

    Persists multiple items to the index

    Specified by:
    saveAll in interface iNativeClient
    Parameters:
    documents - array An array of elasticsearch Document objects to persist
    Returns:
    array An array of results for the saved items

    setHTTPClient

    public any setHTTPClient(any HTTPClient)

    Parameters:
    HTTPClient

    setJLoader

    public any setJLoader(any jLoader)

    Parameters:
    jLoader

    setLog

    public any setLog(any log)

    Parameters:
    log

    setVersionTarget

    public any setVersionTarget(any versionTarget)

    Parameters:
    versionTarget

    updateByQuery

    public boolean updateByQuery(SearchBuilder searchBuilder, struct script)

    Updates items in the index by query

    Specified by:
    updateByQuery in interface iNativeClient
    Parameters:
    searchBuilder - SearchBuilder The search builder object to use for the query
    script - struct script to process on the query