asonic package¶
Submodules¶
asonic.client module¶
-
class
asonic.client.
Client
(host: str = 'localhost', port: int = 1491, password: str = 'SecretPassword', max_connections: int = 100)¶ Bases:
object
-
channel
(channel: asonic.enums.Channel) → None¶
-
count
(collection: str, bucket: str = None, obj: str = None) → int¶ Count indexed search data time complexity: O(1) :param collection: index collection (ie. what you search in, eg. messages, products, etc.) :param bucket: index bucket name (ie. user-specific search classifier in the collection if you have any :param obj: 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)
-
flushb
(collection: str, bucket: str) → int¶ Flush all indexed data from a bucket in a collection time complexity: O(1) :param collection: index collection (ie. what you search in, eg. messages, products, etc.) :param bucket: index bucket name (ie. user-specific search classifier in the collection if you have any
-
flushc
(collection: str) → int¶ Flush all indexed data from a collection time complexity: O(1) :param collection: index collection (ie. what you search in, eg. messages, products, etc.)
-
flusho
(collection: str, bucket: str, obj: str) → int¶ Flush all indexed data from an object in a bucket in collection time complexity: O(1) :param collection: index collection (ie. what you search in, eg. messages, products, etc.) :param bucket: index bucket name (ie. user-specific search classifier in the collection if you have any :param obj: 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)
-
help
(manual: str) → bytes¶ show help time complexity: O(1) :param manual: help manual to be shown (available manuals: commands)
-
info
() → Dict[KT, VT]¶ Get server information time complexity: O(1)
-
ping
() → bytes¶ ping server time complexity: O(1)
-
pop
(collection: str, bucket: str, obj: str, text: str) → int¶ Pop search data from the index time complexity: O(1) :param collection: index collection (ie. what you search in, eg. messages, products, etc.) :param bucket: index bucket name (ie. user-specific search classifier in the collection if you have any :param obj: 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) :param text: search text to be indexed (can be a single word, or a longer text; within maximum length safety limits)
-
push
(collection: str, bucket: str, obj: str, text: str, locale: str = None) → bytes¶ Push search data in the index time complexity: O(1) :param collection: index collection (ie. what you search in, eg. messages, products, etc.) :param bucket: index bucket name (ie. user-specific search classifier in the collection if you have any :param obj: 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) :param text: search text to be indexed (can be a single word, or a longer text; within maximum length safety limits) :param locale: 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)
-
query
(collection: str, bucket: str, terms: str, limit: int = None, offset: int = None, locale: str = None) → List[bytes]¶ query database time complexity: O(1) if enough exact word matches or O(N) if not enough exact matches where N is the number of alternate words tried, in practice it approaches O(1) :param collection: index collection (ie. what you search in, eg. messages, products, etc.) :param bucket: index bucket name (ie. user-specific search classifier in the collection if you have any :param terms: text for search terms :param limit: a positive integer number; set within allowed maximum & minimum limits :param offset: a positive integer number; set within allowed maximum & minimum limits :param locale: 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)
-
quit
() → bytes¶ stop connection time complexity: O(1)
-
suggest
(collection: str, bucket: str, word: str, limit: int = None) → List[bytes]¶ auto-completes word time complexity: O(1) :param collection: index collection (ie. what you search in, eg. messages, products, etc.) :param bucket: index bucket name (ie. user-specific search classifier in the collection if you have any :param word: text for search term :param limit: a positive integer number; set within allowed maximum & minimum limits
-
trigger
(action: asonic.enums.Action = None) → bytes¶ Trigger an action time complexity: O(1) :param action: action to be triggered (available actions: consolidate)
-
-
asonic.client.
escape
(t)¶
asonic.connection module¶
-
class
asonic.connection.
Connection
(host: str, port: int, channel: asonic.enums.Channel, password: str)¶ Bases:
object
-
connect
() → None¶
-
read
() → bytes¶
-
write
(msg: str) → None¶
-
-
class
asonic.connection.
ConnectionPool
(host: str, port: int, channel: asonic.enums.Channel, password: str, max_connections: int = 100)¶ Bases:
object
-
destroy
()¶
-
get_connection
() → asonic.connection.Connection¶
-
make_connection
() → asonic.connection.Connection¶
-
release
(connection: asonic.connection.Connection) → None¶
-
asonic.enums module¶
-
class
asonic.enums.
Action
¶ Bases:
enum.Enum
An enumeration.
-
BACKUP
= 'backup'¶
-
CONSOLIDATE
= 'consolidate'¶
-
RESTORE
= 'restore'¶
-
asonic.exceptions module¶
-
exception
asonic.exceptions.
BaseSonicException
¶ Bases:
Exception
-
exception
asonic.exceptions.
ClientError
¶
-
exception
asonic.exceptions.
ConnectionClosed
¶
-
exception
asonic.exceptions.
ServerError
¶