cbelasticsearch

Class Client

lucee.Component
    extended by cbelasticsearch.Client

Elasticsearch Client

Class Attributes:
  • threadsafe
  •  
  • singleton
  •  
  • license : Apache v2.0
  •  
  • package : cbElasticsearch.models.Elasticsearch
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Jon Clausen
  •  
    Property Summary
    type property default serializable required
    any nativeClient
          Properties created on init().

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


    • access = public
    • returntype = any
    • inject = wirebox
    true false
    Constructor Summary
    init()
          Constructor.
    Method Summary
    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 mappings to an index.
    any close()
         Pool close method.
    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)
         Delete documents from a query.
    struct deleteIndex(string indexName)
         Deletes an index.
    boolean deleteMapping(string indexName, string mapping, [boolean throwOnError='false'])
         Deletes a mapping.
    boolean deleteType(string indexName, string type)
         Deletes an index type.
    SearchResult executeSearch(SearchBuilder searchBuilder)
         Execute a client search request.
    any get(any id, [string index], [string type])
         Retrieves a document by ID.
    any getConfig()
         Provider for Config object.
    array getMultiple(array keys, [string index], [string type])
         Gets multiple items when provided an array of keys.
    string getNativeClient()
    any getSearchBuilder()
         Provider for search builder.
    string getWirebox()
    boolean indexExists(string indexName)
         Verifies whether an index exists.
    boolean indexMappingExists(string indexName, string mapping)
         Verifies whether an index mapping exists.
    any onDIComplete()
         After init the autowire properties.
    Document save(Document document)
    array saveAll(array documents)
         Persists multiple items to the index.
    any setNativeClient(any nativeClient)
    any setWirebox(any wirebox)
    boolean updateByQuery(SearchBuilder searchBuilder, struct script)
         updates documents from a query.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()

    Constructor


    Property Detail

    nativeClient

    property any nativeClient

    Properties created on init()

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

    wirebox

    property any wirebox

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

    Method Detail

    applyIndex

    public boolean applyIndex(IndexBuilder indexBuilder)

    Applies an index item ( create/update )

    Parameters:
    indexBuilder - IndexBuilder An instance of the IndexBuilder object
    Returns:
    boolean Boolean result as to whether the index was created

    applyMapping

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

    Applies a single mapping to an index

    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 mappings to an index

    Parameters:
    indexName - string the index containing the mappings
    mappings - struct the struct representation of the mappings

    close

    public any close()

    Pool close method


    delete

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

    Deletes a single document

    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

    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)

    Delete documents from a query

    Parameters:
    searchBuilder - SearchBuilder The assemble search builder to use for the query

    deleteIndex

    public struct deleteIndex(string indexName)

    Deletes an index

    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

    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

    deleteType

    public boolean deleteType(string indexName, string type)

    Deletes an index type

    Parameters:
    indexName - string the name of the index to be deleted
    type - type the index typing to be deleted

    executeSearch

    public SearchResult executeSearch(SearchBuilder searchBuilder)

    Execute a client search request

    Parameters:
    searchBuilder - SearchBuilder An instance of the SearchBuilder object
    Returns:
    iNativeClient An implementation of the iNativeClient

    get

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

    Retrieves a document by ID

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

    Provider for Config object


    getMultiple

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

    Gets multiple items when provided an array of keys

    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

    getNativeClient

    public string getNativeClient()


    getSearchBuilder

    public any getSearchBuilder()

    Provider for search builder


    getWirebox

    public string getWirebox()


    indexExists

    public boolean indexExists(string indexName)

    Verifies whether an index exists

    Parameters:
    indexName - string the name of the index

    indexMappingExists

    public boolean indexMappingExists(string indexName, string mapping)

    Verifies whether an index mapping exists

    Parameters:
    indexName - string the name of the index
    mapping - string the name of the mapping

    onDIComplete

    public any onDIComplete()

    After init the autowire properties


    save

    public Document save(Document document)

    Parameters:
    document - Document@cbElasticSearch An instance of the elasticsearch Document object
    Returns:
    Document@cbElasticsearch The saved document object

    saveAll

    public array saveAll(array documents)

    Persists multiple items to the index

    Parameters:
    documents - array An array of elasticsearch Document objects to persist
    Returns:
    array An array of results for the saved items

    setNativeClient

    public any setNativeClient(any nativeClient)

    Parameters:
    nativeClient

    setWirebox

    public any setWirebox(any wirebox)

    Parameters:
    wirebox

    updateByQuery

    public boolean updateByQuery(SearchBuilder searchBuilder, struct script)

    updates documents from a query

    Parameters:
    searchBuilder - SearchBuilder The assemble search builder to use for the query
    script - struct script to process on the query