cbelasticsearch

Interface iNativeClient

cbelasticsearch.iNativeClient
All Known Implementing Classes:
JestClient

Elasticsearch Native Client Interface

Class Attributes:
  • singleton : true
  •  
  • license : Apache v2.0
  •  
  • package : cbElasticsearch.models
  •  
  • author : Jon Clausen
  •  
    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.
    void close()
         Closes any connections to the pool and destroys the client singleton.
    numeric count([SearchBuilder searchBuilder])
         Retreives a count of documents matching the given query.
    boolean delete(any document, [boolean throwOnError])
         Deletes a single document.
    any deleteAll(array documents, [boolean throwOnError])
         Deletes documents from an array of documents or IDs.
    any deleteByQuery(SearchBuilder searchBuilder, [boolean waitForCompletion])
         Deletes items in the index by query.
    struct deleteIndex(string indexName)
         Deletes an index.
    boolean deleteMapping(string indexName, string mapping, [boolean throwOnError])
         Deletes a mapping.
    SearchResult executeSearch(SearchBuilder searchBuilder)
         Execute a client search request.
    any get(any id, [string index], [string type])
         Retrieves a document by ID.
    struct getAliases()
         Returns a struct containing the mappings of all aliases in the cluster.
    struct getIndices([any verbose])
         Returns a struct containing all indices in the system, with statistics.
    array getMultiple(array keys, [string index], [string type])
         Gets multiple items when provided an array of keys.
    any getTask(string taskId, [Task taskObj])
         Retreives a task and its status.
    any getTasks()
         Retreives all tasks running on the cluster.
    boolean indexExists(string indexName)
         Verifies whether an index exists.
    boolean indexMappingExists(string indexName, string mapping)
         Verifies whether an index mapping exists.
    array parseParams(any params)
         Parses a parameter argument.
    any reindex(any source, any destination, [boolean waitForCompletion], [any params])
         Applies a reindex action.
    Document save(Document document)
    array saveAll(array documents)
         Persists multiple items to the index.
    any updateByQuery(SearchBuilder searchBuilder, struct script, [boolean waitForCompletion])
         Updates items in the index by query.

    Method Detail

    applyAliases

    public boolean applyAliases(any aliases)

    Applies an alias (or array of aliases)

    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 )

    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

    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

    Parameters:
    indexName - string The name of the index
    mappings - struct a struct containing the mapping configuration

    close

    public void close()

    Closes any connections to the pool and destroys the client singleton


    count

    public numeric count([SearchBuilder searchBuilder])

    Retreives a count of documents matching the given query

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

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

    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 any deleteByQuery(SearchBuilder searchBuilder, [boolean waitForCompletion])

    Deletes items in the index by query

    Parameters:
    searchBuilder - SearchBuilder The search builder object to use for the query
    waitForCompletion - boolean Whether to block the request until completion or return a task which can be checked

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

    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

    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

    getAliases

    public struct getAliases()

    Returns a struct containing the mappings of all aliases in the cluster


    getIndices

    public struct getIndices([any verbose])

    Returns a struct containing all indices in the system, with statistics

    Parameters:
    verbose - boolean whether to return the full stats output for the index

    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

    getTask

    public any getTask(string taskId, [Task taskObj])

    Retreives a task and its status

    Parameters:
    taskId - string The identifier of the task to retreive
    taskObj

    getTasks

    public any getTasks()

    Retreives all tasks running on the cluster


    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

    parseParams

    public array parseParams(any params)

    Parses a parameter argument. upports multiple formats : `requests_per_second=50&slices=5`, `{ "requests_per_second" : 50, "slices" : 5 }`, or `[ { "name" : "requests_per_second", "value" : 50 } ]` )

    Parameters:
    params - any the parameters to filter and transform

    reindex

    public any reindex(any source, any destination, [boolean waitForCompletion], [any params])

    Applies a reindex action Supports multiple formats : `requests_per_second=50&slices=5`, `{ "requests_per_second" : 50, "slices" : 5 }`, or `[ { "name" : "requests_per_second", "value" : 50 } ]` )

    Parameters:
    source - string The source index name or struct of options
    destination - string The destination index name or struct of options
    waitForCompletion - boolean whether to return the result or an asynchronous task
    params - any Additional url params to add to the reindex action.
    Returns:
    any Struct result of the reindex action if waiting for completion or a Task object if dispatched asnyc

    save

    public Document save(Document document)

    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

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

    updateByQuery

    public any updateByQuery(SearchBuilder searchBuilder, struct script, [boolean waitForCompletion])

    Updates items in the index by query

    Parameters:
    searchBuilder - SearchBuilder The search builder object to use for the query
    script - struct script to process on the query
    waitForCompletion - boolean Whether to block the request until completion or return a task which can be checked