python sonic client
1.0.0
Sonic Search 백엔드용 Python 클라이언트입니다.
pip install sonic-client
from sonic import IngestClient
with IngestClient ( "127.0.0.1" , 1491 , "password" ) as ingestcl :
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" )
from sonic import SearchClient
with SearchClient ( "127.0.0.1" , 1491 , "password" ) as querycl :
print ( querycl . ping ())
print ( querycl . query ( "wiki" , "articles" , "for" ))
print ( querycl . query ( "wiki" , "articles" , "love" ))
print ( querycl . suggest ( "wiki" , "articles" , "hell" ))
from sonic import ControlClient
with ControlClient ( "127.0.0.1" , 1491 , "password" ) as controlcl :
print ( controlcl . ping ())
controlcl . trigger ( "consolidate" )
API 문서는 docs/api 및 Browsable에서 찾을 수 있습니다.
asonic은 asyncio를 사용하지만 이 클라이언트는 그렇지 않습니다. gevent 컨텍스트 내에서 Sonic을 사용해야 할 필요성에서 비롯되었습니다.