redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.13k stars 114 forks source link

Query returns all results after hitting limit #623

Closed mmiazzo closed 5 months ago

mmiazzo commented 6 months ago

Running a page query returns all results: Redis config: FT.CONFIG SET MAXSEARCHRESULTS -1

class TemplateGray(JSONModel):
    idd: str = Field(primary_key=True)
    version: str
    obj_id: str
    gray: pickled

@classmethod
def get_gray_page(cls):
    return TemplateGray.find().page(limit=1000)

print(len(TemplateGray.get_gray_page()))
> 157995

I would expect the length of this to be 1000, not every single record under the schema

slorello89 commented 6 months ago

Hi @mmiazzo - what version of RediSearch and redis om python are you using? Are you able to see the FT.SEARCH command that Redis OM is sending to your Redis instance using the Monitor? I am unable to reproduce this issue.

slorello89 commented 6 months ago

Nevermind @mmiazzo - I see it, for some reason it's automatically paginating over the entire result set even when just page is called, need to dig a bit.

mmiazzo commented 6 months ago

Hi @slorello89

I am using redis-om 0.3.0 with redis-stack:latest docker image. from INFO STATS:

redis_version:7.2.4
# Modules
module:name=search,ver=20813,api=1,filters=0,usedby=[],using=[ReJSON],options=[handle-io-errors]
module:name=RedisCompat,ver=1,api=1,filters=0,usedby=[],using=[],options=[]
module:name=ReJSON,ver=20610,api=1,filters=0,usedby=[search],using=[],options=[handle-io-errors]
module:name=timeseries,ver=11012,api=1,filters=0,usedby=[],using=[],options=[]
module:name=redisgears_2,ver=20020,api=1,filters=0,usedby=[],using=[],options=[]
module:name=bf,ver=20612,api=1,filters=0,usedby=[],using=[],options=[]

As you said I was seeing the empty query but paginating over the entire result set.