Skip to content

Redisearch returning empty result #179

Closed
@shoang22

Description

@shoang22

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions