Skip to main content

python client for sonic search backend

Project description

python-sonic-client

Python client for sonic search backend.

Install

pip install sonic-client

Examples

Ingest

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")

Search

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"))

Control

from sonic import ControlClient

with 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 and also Browsable

Difference from asonic

asonic uses asyncio and this client doesn't. It grew out of needing to use sonic within gevent context

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sonic-client-0.0.5.tar.gz (7.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page