Asonic
async python client for the sonic search backend
Install / Use
/learn @moshe/AsonicREADME
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
Usage
Search channel
import asyncio
from asonic import Client
from asonic.enums import Channel
async def main():
c = await Client.create(
host="127.0.0.1",
port=1491,
password="SecretPassword",
channel=Channel.SEARCH,
max_connections=100
)
assert (await c.query('collection', 'bucket', 'quick')) == [b'user_id']
assert (await c.suggest('collection', 'bucket', 'br', 1)) == [b'brown']
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Ingest channel
import asyncio
from asonic import Client
from asonic.enums import Channel
async def main():
c = await Client.create(
host="127.0.0.1",
port=1491,
password="SecretPassword",
channel=Channel.INGEST,
max_connections=100
)
await c.push('collection', 'bucket', 'user_id', 'The quick brown fox jumps over the lazy dog')
# Return b'OK'
await c.pop('collection', 'bucket', 'user_id', 'The')
# Return 1
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Control channel
import asyncio
from asonic import Client
from asonic.enums import Channel, Action
async def main():
c = await Client.create(
host="127.0.0.1",
port=1491,
password="SecretPassword",
channel=Channel.CONTROL,
)
await c.trigger(Action.CONSOLIDATE)
# Return b'OK'
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Related Skills
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
