sonic

Sonicclient Copyright Ahmed T. Youssef nim Sonic client TODO: check help.

Types

SonicChannel {...}{.pure.} = enum
  Ingest, Search, Control
Sonic = ref object of SonicBase[Socket]
AsyncSonic = ref object of SonicBase[AsyncSocket]

Procs

proc startSession(this: AsyncSonic): Future[void] {...}{.raises: [FutureError],
    tags: [RootEffect].}
proc startSession(this: Sonic): void {...}{.raises: [TimeoutError, OSError, SslError], tags: [
    ReadIOEffect, TimeEffect, WriteIOEffect].}
## started. FIXME extract protocol bufsize
proc open(host = "localhost"; port = 1491; password = ""; channel: SonicChannel;
         ssl = false; timeout = 0): Sonic {...}{.raises: [OSError, SslError, TimeoutError], tags: [
    ReadIOEffect, TimeEffect, WriteIOEffect].}
proc openAsync(host = "localhost"; port = 1491; password = ""; channel: SonicChannel;
              ssl = false; timeout = 0): Future[AsyncSonic] {...}{.raises: [FutureError],
    tags: [RootEffect].}
Open an asynchronous connection to a Sonic server.
proc receiveManaged(this: AsyncSonic; size = 1): Future[string] {...}{.
    raises: [FutureError], tags: [RootEffect].}
proc receiveManaged(this: Sonic; size = 1): string {...}{.
    raises: [TimeoutError, OSError, SslError, SonicServerError],
    tags: [ReadIOEffect, TimeEffect].}
proc execCommand(this: AsyncSonic; command: string; args: seq[string]): Future[string] {...}{.
    raises: [FutureError], tags: [RootEffect].}
proc execCommand(this: Sonic; command: string; args: seq[string]): string {...}{.
    raises: [SslError, OSError, TimeoutError, SonicServerError],
    tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
proc execCommand(this: AsyncSonic; command: string): Future[string] {...}{.
    raises: [FutureError], tags: [RootEffect].}
proc execCommand(this: Sonic; command: string): string {...}{.
    raises: [SslError, OSError, TimeoutError, SonicServerError],
    tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
proc ping(this: AsyncSonic): Future[bool] {...}{.raises: [FutureError], tags: [RootEffect].}
Send ping command to the server Returns: bool True if successfully reaching the server.
proc ping(this: Sonic): bool {...}{.raises: [SslError, OSError, TimeoutError,
                                   SonicServerError],
                           tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
Send ping command to the server Returns: bool True if successfully reaching the server.
proc quit(this: AsyncSonic): Future[string] {...}{.raises: [FutureError],
    tags: [RootEffect].}
Quit the channel and closes the connection.
proc quit(this: Sonic): string {...}{.raises: [SslError, OSError, TimeoutError,
                                     SonicServerError],
                             tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
Quit the channel and closes the connection.
proc help(this: AsyncSonic; arg: string): Future[string] {...}{.raises: [FutureError],
    tags: [RootEffect].}
Sends Help query.
proc help(this: Sonic; arg: string): string {...}{.raises: [SslError, OSError, TimeoutError,
    SonicServerError], tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
Sends Help query.
proc push(this: AsyncSonic; collection, bucket, objectName, text: string; lang = ""): Future[
    bool] {...}{.raises: [FutureError], tags: [RootEffect].}
Push search data in the index
  • collection: index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact)
  • text: search text to be indexed can be a single word, or a longer text; within maximum length safety limits
  • lang: ISO language code
Returns:
bool True if search data are pushed in the index.
proc push(this: Sonic; collection, bucket, objectName, text: string; lang = ""): bool {...}{.
    raises: [SslError, OSError, TimeoutError, SonicServerError],
    tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
Push search data in the index
  • collection: index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact)
  • text: search text to be indexed can be a single word, or a longer text; within maximum length safety limits
  • lang: ISO language code
Returns:
bool True if search data are pushed in the index.
proc pop(this: AsyncSonic; collection, bucket, objectName, text: string): Future[int] {...}{.
    raises: [FutureError], tags: [RootEffect].}
Pop search data from the index
  • collection: index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact)
  • text: search text to be indexed can be a single word, or a longer text; within maximum length safety limits
Returns:
int
proc pop(this: Sonic; collection, bucket, objectName, text: string): int {...}{.raises: [
    SslError, OSError, TimeoutError, SonicServerError, OverflowError, ValueError],
    tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
Pop search data from the index
  • collection: index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact)
  • text: search text to be indexed can be a single word, or a longer text; within maximum length safety limits
Returns:
int
proc count(this: AsyncSonic; collection, bucket, objectName: string): Future[int] {...}{.
    raises: [FutureError], tags: [RootEffect].}
Count indexed search data
  • collection: index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact)

Returns: int count of index search data.

proc count(this: Sonic; collection, bucket, objectName: string): int {...}{.raises: [
    OverflowError, ValueError, SslError, OSError, TimeoutError, SonicServerError],
    tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
Count indexed search data
  • collection: index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact)

Returns: int count of index search data.

proc flushCollection(this: AsyncSonic; collection: string): Future[int] {...}{.
    raises: [FutureError], tags: [RootEffect].}
Flush all indexed data from a collection
  • collection index collection (ie. what you search in, eg. messages, products, etc.)

Returns:
int number of flushed data

proc flushCollection(this: Sonic; collection: string): int {...}{.raises: [OverflowError,
    ValueError, SslError, OSError, TimeoutError, SonicServerError],
    tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
Flush all indexed data from a collection
  • collection index collection (ie. what you search in, eg. messages, products, etc.)

Returns:
int number of flushed data

proc flushBucket(this: AsyncSonic; collection, bucket: string): Future[int] {...}{.
    raises: [FutureError], tags: [RootEffect].}
Flush all indexed data from a bucket in a collection
  • collection: index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
Returns:
int number of flushed data
proc flushBucket(this: Sonic; collection, bucket: string): int {...}{.raises: [OverflowError,
    ValueError, SslError, OSError, TimeoutError, SonicServerError],
    tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
Flush all indexed data from a bucket in a collection
  • collection: index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
Returns:
int number of flushed data
proc flushObject(this: AsyncSonic; collection, bucket, objectName: string): Future[int] {...}{.
    raises: [FutureError], tags: [RootEffect].}
Flush all indexed data from an object in a bucket in collection
  • collection: index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact)
Returns:
int number of flushed data
proc flushObject(this: Sonic; collection, bucket, objectName: string): int {...}{.raises: [
    OverflowError, ValueError, SslError, OSError, TimeoutError, SonicServerError],
    tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
Flush all indexed data from an object in a bucket in collection
  • collection: index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact)
Returns:
int number of flushed data
proc flush(this: AsyncSonic; collection: string; bucket = ""; objectName = ""): Future[int] {...}{.
    raises: [FutureError], tags: [RootEffect].}
Flush indexed data in a collection, bucket, or in an object.
  • collection: index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact)
Returns:
int number of flushed data
proc flush(this: Sonic; collection: string; bucket = ""; objectName = ""): int {...}{.raises: [
    OverflowError, ValueError, SslError, OSError, TimeoutError, SonicServerError],
    tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
Flush indexed data in a collection, bucket, or in an object.
  • collection: index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact)
Returns:
int number of flushed data
proc query(this: AsyncSonic; collection, bucket, terms: string; limit = 10;
          offset: int = 0; lang = ""): Future[seq[string]] {...}{.raises: [FutureError],
    tags: [RootEffect].}
Query the database
  • collection index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • terms text for search terms
  • limit a positive integer number; set within allowed maximum & minimum limits
  • offset a positive integer number; set within allowed maximum & minimum limits
  • lang an ISO 639-3 locale code eg. eng for English (if set, the locale must be a valid ISO 639-3 code; if not set, the locale will be guessed from text).
Returns:
list list of objects ids.
proc query(this: Sonic; collection, bucket, terms: string; limit = 10; offset: int = 0;
          lang = ""): seq[string] {...}{.raises: [SslError, OSError, TimeoutError,
                                        SonicServerError],
                                tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
Query the database
  • collection index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • terms text for search terms
  • limit a positive integer number; set within allowed maximum & minimum limits
  • offset a positive integer number; set within allowed maximum & minimum limits
  • lang an ISO 639-3 locale code eg. eng for English (if set, the locale must be a valid ISO 639-3 code; if not set, the locale will be guessed from text).
Returns:
list list of objects ids.
proc suggest(this: AsyncSonic; collection, bucket, word: string; limit = 10): Future[
    seq[string]] {...}{.raises: [FutureError], tags: [RootEffect].}
auto-completes word.
  • collection index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • word word to autocomplete
  • limit a positive integer number; set within allowed maximum & minimum limits (procault: {None})
Returns:
list list of suggested words.
proc suggest(this: Sonic; collection, bucket, word: string; limit = 10): seq[string] {...}{.
    raises: [SslError, OSError, TimeoutError, SonicServerError],
    tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
auto-completes word.
  • collection index collection (ie. what you search in, eg. messages, products, etc.)
  • bucket index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..)
  • word word to autocomplete
  • limit a positive integer number; set within allowed maximum & minimum limits (procault: {None})
Returns:
list list of suggested words.
proc trigger(this: AsyncSonic; action = ""): Future[string] {...}{.raises: [FutureError],
    tags: [RootEffect].}
Trigger an action
action text for action
proc trigger(this: Sonic; action = ""): string {...}{.
    raises: [SslError, OSError, TimeoutError, SonicServerError],
    tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
Trigger an action
action text for action