Skip to main content

Hermes Client

Async Python client for Hermes search server.

Installation

pip install hermes-client-python

Quick Start

import asyncio
from hermes_client_python import HermesClient


async def main():
    async with HermesClient("localhost:50051") as client:
        # Create index with SDL schema
        await client.create_index(
            "articles",
            """
            index articles {
                field title: text [indexed, stored]
                field body: text [indexed, stored]
                field score: f64 [stored]
            }
        """,
        )

        # Index documents
        await client.index_documents(
            "articles",
            [
                {"title": "Hello World", "body": "First article", "score": 1.5},
                {"title": "Goodbye World", "body": "Last article", "score": 2.0},
            ],
        )

        # Commit changes
        await client.commit("articles")

        # Search
        results = await client.search("articles", term=("title", "hello"), limit=10)
        for hit in results.hits:
            print(f"Doc {hit.doc_id}: score={hit.score}, fields={hit.fields}")

        # Get document by ID
        doc = await client.get_document("articles", 0)
        print(doc.fields)

        # Delete index
        await client.delete_index("articles")


asyncio.run(main())

API Reference

HermesClient

client = HermesClient(address="localhost:50051")

Connection

# Using context manager (recommended)
async with HermesClient("localhost:50051") as client:
    ...

# Manual connection
client = HermesClient("localhost:50051")
await client.connect()
# ... use client ...
await client.close()

Index Management

# Create index with SDL schema
await client.create_index(
    "myindex",
    """
    index myindex {
        field title: text [indexed, stored]
        field body: text [indexed, stored]
    }
""",
)

# Create index with JSON schema
await client.create_index(
    "myindex",
    """
{
    "fields": [
        {"name": "title", "type": "text", "indexed": true, "stored": true},
        {"name": "body", "type": "text", "indexed": true, "stored": true}
    ]
}
""",
)

# Get index info
info = await client.get_index_info("myindex")
print(f"Documents: {info.num_docs}, Segments: {info.num_segments}")

# Delete index
await client.delete_index("myindex")

Document Indexing

# Index multiple documents (batch)
indexed, errors = await client.index_documents(
    "myindex",
    [
        {"title": "Doc 1", "body": "Content 1"},
        {"title": "Doc 2", "body": "Content 2"},
    ],
)

# Index single document
await client.index_document("myindex", {"title": "Doc", "body": "Content"})


# Stream documents (for large datasets)
async def doc_generator():
    for i in range(10000):
        yield {"title": f"Doc {i}", "body": f"Content {i}"}


count = await client.index_documents_stream("myindex", doc_generator())

# Commit changes (required to make documents searchable)
num_docs = await client.commit("myindex")

# Force merge segments (for optimization)
num_segments = await client.force_merge("myindex")

Searching

# Term query
results = await client.search("myindex", term=("title", "hello"), limit=10)

# Boolean query
results = await client.search(
    "myindex",
    boolean={
        "must": [("title", "hello")],
        "should": [("body", "world")],
        "must_not": [("title", "spam")],
    },
)

# With pagination
results = await client.search("myindex", term=("title", "hello"), limit=10, offset=20)

# With field loading
results = await client.search(
    "myindex", term=("title", "hello"), fields_to_load=["title", "body"]
)

# Access results
for hit in results.hits:
    print(f"Doc {hit.doc_id}: {hit.score}")
    print(f"  Title: {hit.fields.get('title')}")

print(f"Total hits: {results.total_hits}")
print(f"Took: {results.took_ms}ms")

Document Retrieval

# Get document by ID
doc = await client.get_document("myindex", doc_id=42)
if doc:
    print(doc.fields["title"])

Field Types

Type Python Type Description
text str Full-text searchable string
u64 int (>= 0) Unsigned 64-bit integer
i64 int Signed 64-bit integer
f64 float 64-bit floating point
bytes bytes Binary data
json dict / list JSON object (auto-serialized)
dense_vector list[float] Dense vector for semantic search
sparse_vector dict Sparse vector with indices and values

Error Handling

import grpc

try:
    await client.search("nonexistent", term=("field", "value"))
except grpc.RpcError as e:
    if e.code() == grpc.StatusCode.NOT_FOUND:
        print("Index not found")
    else:
        raise

Development

Generate protobuf stubs:

pip install grpcio-tools
python generate_proto.py

License

MIT

Timeouts / deadlines

Every RPC accepts an optional timeout (seconds) which sets a gRPC deadline; a client-wide default can be set in the constructor. On expiry the call raises grpc.aio.AioRpcError with DEADLINE_EXCEEDED.

client = HermesClient("localhost:50051", default_timeout=5.0)
results = await client.search("articles", query={...}, timeout=0.5)  # per-call override
await client.force_merge("articles", timeout=3600)  # long op, long deadline

Download files

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

Source Distribution

hermes_client_python-1.8.86.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hermes_client_python-1.8.86-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file hermes_client_python-1.8.86.tar.gz.

File metadata

  • Download URL: hermes_client_python-1.8.86.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for hermes_client_python-1.8.86.tar.gz
Algorithm Hash digest
SHA256 aade2f3480c131caaed97ac0c3eac8d081d2be92e9248517f72ba006b2f7a5d2
MD5 a4b968450725b68ff755a2e61bed4ff1
BLAKE2b-256 cc574da9f4158ced34c3ca863a94be8c55df0c9fc167c6b99ec6969c76dad2bc

See more details on using hashes here.

File details

Details for the file hermes_client_python-1.8.86-py3-none-any.whl.

File metadata

  • Download URL: hermes_client_python-1.8.86-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for hermes_client_python-1.8.86-py3-none-any.whl
Algorithm Hash digest
SHA256 2a813b6961e5f901ad6f8f7be7193d7bf83b6ba8d13f22a8c52d377ce393e230
MD5 6e1c906f50718cb3c40b1c5549a97661
BLAKE2b-256 1e72edac875171799989768e6135a07eff7fc30833bd988b6d91550fa22dd92b

See more details on using hashes here.

Release history Release notifications | RSS feed

1.8.127

2 files

1.8.124

2 files

1.8.123

2 files

1.8.122

2 files

1.8.121

2 files

1.8.120

2 files

1.8.119

2 files

1.8.118

2 files

1.8.117

2 files

1.8.116

2 files

1.8.115

2 files

1.8.114

2 files

1.8.113

2 files

1.8.112

2 files

1.8.111

2 files

1.8.110

2 files

1.8.109

2 files

1.8.108

2 files

1.8.107

2 files

1.8.105

2 files

1.8.104

2 files

1.8.103

2 files

1.8.102

2 files

1.8.101

2 files

1.8.100

2 files

1.8.99

2 files

1.8.98

2 files

1.8.97

2 files

1.8.96

2 files

1.8.95

2 files

1.8.94

2 files

1.8.93

2 files

1.8.92

2 files

1.8.91

2 files

1.8.90

2 files

1.8.89

2 files

1.8.88

2 files

1.8.87

2 files

This release

1.8.86 This release

2 files

1.8.85

2 files

1.8.84

2 files

1.8.83

2 files

1.8.82

2 files

1.8.81

2 files

1.8.80

2 files

1.8.79

2 files

1.8.78

2 files

1.8.77

2 files

1.8.76

2 files

1.8.75

2 files

1.8.74

2 files

1.8.73

2 files

1.8.72

2 files

1.8.71

2 files

1.8.70

2 files

1.8.69

2 files

1.8.68

2 files

1.8.67

2 files

1.8.66

2 files

1.8.65

2 files

1.8.64

2 files

1.8.63

2 files

1.8.62

2 files

1.8.61

2 files

1.8.60

2 files

1.8.59

2 files

1.8.58

2 files

1.8.57

2 files

1.8.56

2 files

1.8.55

2 files

1.8.54

2 files

1.8.53

2 files

1.8.52

2 files

1.8.51

2 files

1.8.50

2 files

1.8.49

2 files

1.8.48

2 files

1.8.47

2 files

1.8.45

2 files

1.8.44

2 files

1.8.43

2 files

1.8.41

2 files

1.8.40

2 files

1.8.39

2 files

1.8.38

2 files

1.8.37

2 files

1.8.36

2 files

1.8.35

2 files

1.8.34

2 files

1.8.33

2 files

1.8.32

2 files

1.8.31

2 files

1.8.30

2 files

1.8.29

2 files

1.8.28

2 files

1.8.27

2 files

1.8.26

2 files

1.8.25

2 files

1.8.24

2 files

1.8.23

2 files

1.8.22

2 files

1.8.21

2 files

1.8.20

2 files

1.8.19

2 files

1.8.18

2 files

1.8.17

2 files

1.8.16

2 files

1.8.15

2 files

1.8.14

2 files

1.8.13

2 files

1.8.12

2 files

1.8.11

2 files

1.8.10

2 files

1.8.9

2 files

1.8.8

2 files

1.8.7

2 files

1.8.6

2 files

1.8.5

2 files

1.8.4

2 files

1.8.3

2 files

1.8.2

2 files

1.8.1

2 files

1.8.0

2 files

1.7.98

2 files

1.7.97

2 files

1.7.59

2 files

1.7.56

2 files

1.7.55

2 files

1.7.54

2 files

1.7.52

2 files

1.7.51

2 files

1.7.50

2 files

1.7.49

2 files

1.7.48

2 files

1.7.47

2 files

1.7.46

2 files

1.7.45

2 files

1.7.44

2 files

1.7.43

2 files

1.7.42

2 files

1.7.41

2 files

1.7.40

2 files

1.7.39

2 files

1.7.38

2 files

1.7.37

2 files

1.7.36

2 files

1.7.35

2 files

1.7.34

2 files

1.7.33

2 files

1.7.32

2 files

1.7.31

2 files

1.7.30

2 files

1.7.29

2 files

1.7.28

2 files

1.7.27

2 files

1.7.26

2 files

1.7.25

2 files

1.7.24

2 files

1.7.23

2 files

1.7.22

2 files

1.7.21

2 files

1.7.20

2 files

1.7.19

2 files

1.7.18

2 files

1.7.17

2 files

1.7.16

2 files

1.7.15

2 files

1.7.14

2 files

1.7.13

2 files

1.7.12

2 files

1.7.11

2 files

1.7.10

2 files

1.7.9

2 files

1.7.8

2 files

1.7.7

2 files

1.7.6

2 files

1.7.5

2 files

1.7.4

2 files

1.7.3

2 files

1.7.2

2 files

1.7.1

2 files

1.7.0

2 files

1.6.16

2 files

1.6.15

2 files

1.6.14

2 files

1.6.13

2 files

1.6.12

2 files

1.6.11

2 files

1.6.10

2 files

1.6.9

2 files

1.6.8

2 files

1.6.7

2 files

1.6.6

2 files

1.6.5

2 files

1.6.4

2 files

1.6.3

2 files

1.6.2

2 files

1.6.1

2 files

1.5.2

2 files

1.5.1

2 files

1.5.0

2 files

1.4.80

2 files

1.4.79

2 files

1.4.78

2 files

1.4.77

2 files

1.4.76

2 files

1.4.75

2 files

1.4.74

2 files

1.4.73

2 files

1.4.72

2 files

1.4.71

2 files

1.4.70

2 files

1.4.69

2 files

1.4.68

2 files

1.4.67

2 files

1.4.66

2 files

1.4.65

2 files

1.4.64

2 files

1.4.63

2 files

1.4.62

2 files

1.4.61

2 files

1.4.60

2 files

1.4.59

2 files

1.4.57

2 files

1.4.56

2 files

1.4.55

2 files

1.4.54

2 files

1.4.53

2 files

1.4.52

2 files

1.4.51

2 files

1.4.50

2 files

1.4.49

2 files

1.4.48

2 files

1.4.47

2 files

1.4.46

2 files

1.4.45

2 files

1.4.44

2 files

1.4.43

2 files

1.4.42

2 files

1.4.40

2 files

1.4.39

2 files

1.4.38

2 files

1.4.37

2 files

1.4.36

2 files

1.4.35

2 files

1.4.34

2 files

1.4.33

2 files

1.4.32

2 files

1.4.31

2 files

1.4.30

2 files

1.4.29

2 files

1.4.28

2 files

1.4.27

2 files

1.4.26

2 files

1.4.25

2 files

1.4.24

2 files

1.4.23

2 files

1.4.22

2 files

1.4.21

2 files

1.4.20

2 files

1.4.18

2 files

1.4.17

2 files

1.4.16

2 files

1.4.15

2 files

1.4.14

2 files

1.4.13

2 files

1.4.12

2 files

1.4.11

2 files

1.4.10

2 files

1.4.9

2 files

1.4.8

2 files

1.4.7

2 files

1.4.6

2 files

1.4.5

2 files

1.4.4

2 files

1.4.3

2 files

1.4.1

2 files

1.4.0

2 files

1.3.4

2 files

1.3.3

2 files

1.3.2

2 files

1.3.1

2 files

1.2.7

2 files

1.2.6

2 files

1.2.5

2 files

1.2.4

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.0.4

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page