Skip to content
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

[5.x]: Limit in search query doesn't work as expected #16183

Open
jakobhaerter opened this issue Nov 21, 2024 · 1 comment
Open

[5.x]: Limit in search query doesn't work as expected #16183

jakobhaerter opened this issue Nov 21, 2024 · 1 comment
Labels

Comments

@jakobhaerter
Copy link

What happened?

Description

When working with site('*') and unique() in a search query, the output contains more or less entries compared to the limit I set – with more than enough entries to limit.

  • I get 10 entries without site('*') and unique().
  • I get 6 entries without site('*') and with unique().
  • I get 12 entries with site('*') and without unique().
{% set searchTerm = q ?? null %}
{% set searchQuery = craft.entries()
    .section([
        'home',
        'locations',
        'news',
        'pages',
        'persons',
    ])
    .orderBy('score, title ASC')
    .limit(10)
    .search(searchTerm)
    .site('*')
    .unique()
%}

Steps to reproduce

  1. Create a couple of entries
  2. Create a search query similar to the example above, using a reasonable limit value
  3. Output the length of the search results with and without site('*') and unique()

Expected behavior

The limit parameter should always limit the query to the exact limit value.

Actual behavior

The query output is not being limited based on the limit value.

Craft CMS version

5.5.2

PHP version

8.3

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@i-just
Copy link
Contributor

i-just commented Nov 22, 2024

Hi, thanks for reaching out! I can’t replicate the query results going over the limit. Any chance you could send your composer.json, composer.lock and database export to [email protected] along with the searchTerm value you were testing this on?

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

No branches or pull requests

2 participants