RediSearch / redisearch-py

RediSearch python client
https://redisearch.io
BSD 2-Clause "Simplified" License
221 stars 62 forks source link

Can't create an index with a single field #147

Closed clmnin closed 2 years ago

clmnin commented 2 years ago
definition = redisearch.IndexDefinition(
    prefix=['user:'], index_type=redisearch.client.IndexType.JSON)

SCHEMA = (
    redisearch.TextField("$.phone", as_name="phone")
)
rc = redisearch.Client("idx:user")

try:
    rc.info()
except redis.ResponseError:
    # Index does not exist. We need to create it!
    rc.create_index(SCHEMA, definition=definition)

Give this error

TypeError: 'TextField' object is not iterable

AvitalFineRedis commented 2 years ago

@clmno Try to use with comma

SCHEMA = (
    redisearch.TextField("$.phone", as_name="phone"),
)
clmnin commented 2 years ago

Thank you