Sonic Search后端的Python客户端
sonic-client的Python项目详细描述
python sonic客户端
用于sonic搜索后端的python客户端。
安装
pip install sonic-client
示例
摄入
fromsonicimportIngestClientwithIngestClient("127.0.0.1",1491,"password")asingestcl:print(ingestcl.ping())print(ingestcl.protocol)print(ingestcl.bufsize)ingestcl.push("wiki","articles","article-1","for the love of god hell")ingestcl.push("wiki","articles","article-2","for the love of satan heaven")ingestcl.push("wiki","articles","article-3","for the love of lorde hello")ingestcl.push("wiki","articles","article-4","for the god of loaf helmet")
搜索
fromsonicimportSearchClientwithSearchClient("127.0.0.1",1491,"password")asquerycl:print(querycl.ping())print(querycl.query("wiki","articles","for"))print(querycl.query("wiki","articles","love"))print(querycl.suggest("wiki","articles","hell"))
对照组
fromsonicimportControlClientwithControlClient("127.0.0.1",1491,"password")ascontrolcl:print(controlcl.ping())controlcl.trigger("consolidate")
API参考
与asonic的区别
asonic使用asyncio,而这个客户机不使用asyncio。它不再需要在gevent上下文中使用sonic