Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xmonader/python-sonic-client
sonic search backend client in python
https://github.com/xmonader/python-sonic-client
index python search sonic
Last synced: 3 months ago
JSON representation
sonic search backend client in python
- Host: GitHub
- URL: https://github.com/xmonader/python-sonic-client
- Owner: xmonader
- License: mit
- Created: 2019-04-09T11:37:44.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-27T14:26:10.000Z (over 3 years ago)
- Last Synced: 2024-07-09T12:18:17.078Z (4 months ago)
- Topics: index, python, search, sonic
- Language: Python
- Size: 44.9 KB
- Stars: 60
- Watchers: 4
- Forks: 7
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# python-sonic-client
Python client for [sonic](https://github.com/valeriansaliou/sonic) search backend.
## Install
```
pip install sonic-client
```## Examples
### Ingest
```python
from sonic import IngestClientwith 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")
```### Search
```python
from sonic import SearchClientwith 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"))
```### Control
```python
from sonic import ControlClientwith ControlClient("127.0.0.1", 1491, "password") as controlcl:
print(controlcl.ping())
controlcl.trigger("consolidate")
```## API reference
API documentation can be found at [docs/api](./docs/api) and also [Browsable](https://xmonader.github.io/python-sonic-client/api/sonic/)
## Difference from asonic
asonic uses asyncio and this client doesn't. It grew out of needing to use sonic within gevent context