RediSearch / redisearch-py

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

Unable to get all data from docs #154

Closed pnthai88 closed 2 years ago

pnthai88 commented 2 years ago
client.info()
query = Query("this is keyword").paging(0, 10)
q = client.search(query)

sample loop for each itm:

for itm in q.docs:
        print(itm)

result

Document {'owner': 'srva', 'add_time': '2021-10-18 20:27:10.344281', 'TTL': '$0.07'}
Document {'owner': 'srva', 'add_time': '2021-10-18 20:27:10.342266', 'TTL': '$0.08'}

if I use print(itm.add_time) I can get 2021-10-18 20:27:10.344281

How do I get all of information ?

gkorland commented 2 years ago

Which information is missing here?

Document {'owner': 'srva', 'add_time': '2021-10-18 20:27:10.344281', 'TTL': '$0.07'}
pnthai88 commented 2 years ago

Hello @gkorland , I'm trying to loop on each Document item to get its key and value. How can I do it ?

pnthai88 commented 2 years ago

I know the the column's name. But it's dynamic from excel

Cols = ['owner','add_time','TTL']

When i try:

for col in Cols:
  print ( itm.col )

(This type of loop will not work)

gkorland commented 2 years ago

try

getattr(itm, col)

see: https://stackoverflow.com/a/16060719/593425

pnthai88 commented 2 years ago

Beautiful, it's working. Thank you!