-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix max results for for all data #85
Conversation
ft.search return 10 results by default
Either we do that or we make a constant that gives 10000 max results which avoids doing the count as you want @clementtalleu ? |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #85 +/- ##
============================================
+ Coverage 70.65% 70.77% +0.12%
- Complexity 540 546 +6
============================================
Files 42 42
Lines 1213 1232 +19
============================================
+ Hits 857 872 +15
- Misses 356 360 +4 ☔ View full report in Codecov by Sentry. |
{ | ||
if ($limit === null) { | ||
$limit = $this->count([]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add new line after the condition block
private function defineLimit(?int $limit = null) | ||
{ | ||
if ($limit === null) { | ||
$limit = $this->count([]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to know the total number of results if no limit is indicated?
it adds a call to redis in addition to FT.SEARCH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's what I'm telling you, what we can do is make a constant since FT.SEARCH seems to return 10 results by default, so we can set a constant to 10000 so there are no more count calls, do you prefer that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, I prefer to avoid useless redis call and put an hardcoded value.
Maybe we could add it directly in the attribute #[Entity] ? 10000 by default and configurable for users, what do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from my point of view, I'm not sure it's the Entity attribute that should carry this, I'd say it's a value linked to the ft.search functional, I'd say that either we remove the nullable from the limit argument and set it to 10000 by default, or we define a constant that would be the value to avoid calls to the count method in the AbstractObjectRepository. Knowing that if you have more than 10000 results, which could happen in my case, you'll have to iterate on them automatically when you do a findAll or this kind of method, since you want to have everything.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but I think users should be able to change the default number.
I still have no idea of the best way to do it, if you have an idea I'd love to hear it, otherwise let's keep it constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use FT.AGGREGATE and then a FT.CURSOR cursor, but I'm not sure that's a good idea.
dacdc97
to
83a8c16
Compare
83a8c16
to
af83571
Compare
@@ -17,7 +17,7 @@ abstract class AbstractObjectRepository implements RepositoryInterface | |||
public ?string $className = null; | |||
protected ?RedisClientInterface $redisClient = null; | |||
protected ?ConverterInterface $converter = null; | |||
|
|||
private const DEFAULT_SEARCH_LIMIT = 10000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, add new line
thanks a lot @flug ! |
ft.search return 10 results by default