Skip to content

Repository files navigation

asonic - async python client for the sonic search backend

Asonic implements all Sonic APIs
Bugfixes and api changes are welcome

Install

pip install asonic

API Docs

here

Usage

Search channel

importasynciofromasonicimportClientfromasonic.enumsimportChannelasyncdefmain():
c=awaitClient.create(
host="127.0.0.1",
port=1491,
password="SecretPassword",
channel=Channel.SEARCH,
max_connections=100
)
assert (awaitc.query('collection', 'bucket', 'quick')) == [b'user_id']
assert (awaitc.suggest('collection', 'bucket', 'br', 1)) == [b'brown']
if__name__=='__main__':
loop=asyncio.get_event_loop()
loop.run_until_complete(main())

Ingest channel

importasynciofromasonicimportClientfromasonic.enumsimportChannelasyncdefmain():
c=awaitClient.create(
host="127.0.0.1",
port=1491,
password="SecretPassword",
channel=Channel.INGEST,
max_connections=100
)
awaitc.push('collection', 'bucket', 'user_id', 'The quick brown fox jumps over the lazy dog')
# Return b'OK'awaitc.pop('collection', 'bucket', 'user_id', 'The')
# Return 1if__name__=='__main__':
loop=asyncio.get_event_loop()
loop.run_until_complete(main())

Control channel

importasynciofromasonicimportClientfromasonic.enumsimportChannel, Actionasyncdefmain():
c=awaitClient.create(
host="127.0.0.1",
port=1491,
password="SecretPassword",
channel=Channel.CONTROL,
)
awaitc.trigger(Action.CONSOLIDATE)
# Return b'OK'if__name__=='__main__':
loop=asyncio.get_event_loop()
loop.run_until_complete(main())

About

async python client for the sonic search backend

Resources

Stars

139 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages