Skip to content

[Autocomplete] filter_query & max_results conflict #769

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

Closed
ytilotti opened this issue Apr 4, 2023 · 7 comments · Fixed by #2440
Closed

[Autocomplete] filter_query & max_results conflict #769

ytilotti opened this issue Apr 4, 2023 · 7 comments · Fixed by #2440
Labels

Comments

@ytilotti
Copy link
Contributor

ytilotti commented Apr 4, 2023

There is a conflict on ux-autocomplete between filter_query and max_results.

With this code, we have 50 results:

'max_results' => 50

But with this code, we have 10 results:

'filter_query' => function(QueryBuilder $qb, string $query, EntityRepository $repository) {
    if (!$query) {
        return;
    }

    $qb->andWhere('entity.name LIKE :filter OR entity.description LIKE :filter')
        ->setParameter('filter', '%'.$query.'%');
},
 'max_results' => 50
@ytilotti ytilotti changed the title [Aucomplete] filter_query & max_results conflict [Autocomplete] filter_query & max_results conflict Apr 4, 2023
@norkunas
Copy link
Contributor

norkunas commented Apr 4, 2023

filter_query is used when you manually build the query so you also must call the $queryBuilder->setMaxResults(50) not sure if that is a good DX :)

@ytilotti
Copy link
Contributor Author

ytilotti commented Apr 4, 2023

I think a PR is necessary on the doc when I see:

filter_query (default: null)
If you want to completely control the query made for the "search results", use this option.
This is incompatible with searchable_fields and max_results

@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

@carsonbot
Copy link

Friendly reminder that this issue exists. If I don't hear anything I'll close this.

@carsonbot
Copy link

Hey,

I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!

@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

@carsonbot
Copy link

Just a quick reminder to make a comment on this. If I don't hear anything I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants