redis-om-python icon indicating copy to clipboard operation
redis-om-python copied to clipboard

Person.find(person.pk == id).first() returns empty even if there is an object

Open Sreesanth46 opened this issue 2 years ago • 4 comments

I got this issue when updating a Model and then finding the same model that I updated.

this is my code def get_campaign_by_id_and_client_id(id, client_id): try: return InterviewRedisModel.find( InterviewRedisModel.pk == id, InterviewRedisModel.created_by == client_id ).first() except NotFoundError: raise CampaignNotFoundException("Campaign not found")

First time it returns the object as expected. Next time it raises the exception. But when I do a get() query instead InterviewRedisModel.get(pk = id) This returns even if the find returns empty/NotFoundError

Sreesanth46 avatar Oct 30 '23 13:10 Sreesanth46

check types, for me it was the problem @Sreesanth46 . If you do update or anything like that and alter types (so that they no longer match your model types) your item becomes unsearchable

dearkafka avatar Nov 01 '23 16:11 dearkafka

@dearkafka issue was with the number of indexed fields. Solved the issue by reducing the number of indexed fields.

There is still no document specifying the maximum number of indexed fields that we can use in a document.

Sreesanth46 avatar Nov 01 '23 17:11 Sreesanth46

Mamma Mia!

dearkafka avatar Nov 01 '23 17:11 dearkafka

The limit is 1024. If you are using lots of text fields, that changes things somewhat (I think the limit is lower -like 128 or something)

slorello89 avatar Apr 05 '24 15:04 slorello89

Going to close this as it's resolved.

slorello89 avatar May 03 '24 19:05 slorello89