Skip to content

Redisearch returning empty result #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shoang22 opened this issue Apr 15, 2025 · 1 comment
Closed

Redisearch returning empty result #179

shoang22 opened this issue Apr 15, 2025 · 1 comment

Comments

@shoang22
Copy link

Hello,

I'm trying to add documents to redis and query them with Redisearch:

async def test_redis(db: redis.Redis):
    source_name = "my_source"
    schema = (
        TextField("type"),
        TextField("page"),
        TextField("text"),
    )
    await db.ft(source_name).create_index(
        schema, 
        definition=IndexDefinition(prefix=[f"{source_name}:"], index_type=IndexType.HASH)
    )
    text = ["a" * 100] * 50
    async with db.pipeline(transaction=True) as pipe:
        for i, _text in enumerate(text):
            doc = {"type": "paragraph", "page": i, "text": _text}
            await pipe.hset(f"doc:{i}", mapping=doc)
        await pipe.execute()

    print(await db.ft(source_name).search(Query("@type: paragraph").dialect(2)))

this returns Result{0 total, docs: []}.

But when I use db.hgetall I get my document as expected.

@shoang22
Copy link
Author

Sorry, meant to post this in redis-py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant