Problem/Motivation

As a developer I would like to see the "Hard limit" setting for facets ported over to the facets exposed filters.

Steps to reproduce

Enable facets_exposed_filters
Create a Search API index based view
Create a Facet
View the settings for the facet
Fail to find the setting for "Hard limit"

Proposed resolution

Add field to the form and incorporate

Remaining tasks

X Create issue fork
X Review and test
_ Merge

User interface changes

New field on facets exposed filter widget for "Hard limit"

API changes

Hard limit will be passed to search api as value for field "limit" previous value was 0

Data model changes

None

Issue fork facets-3492078

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

scott_earnest created an issue. See original summary.

scott_earnest’s picture

Issue summary: View changes
scott_earnest’s picture

Something to note - in our case we are using search_api_opensearch - which will not set the limit (size) parameter if it is "0". We were seeing the default value for this api which was 10 records. Perhaps using other search api's "0" means "unlimited"?

scott_earnest’s picture

Issue summary: View changes

Testing Instructions
Create a Search API Index based view
Create a facet exposed filter
Find the new (old) field for "Hard limit"
Verify this will affect the total number of options in the facet dropdown (you should be able to see this in the preview)

scott_earnest’s picture

Assigned: scott_earnest » Unassigned
Status: Active » Needs review
griz’s picture

I'm also using OpenSearch and have experienced the same behaviour. This patch works for me.

sagesolutions’s picture

Status: Needs review » Reviewed & tested by the community

I'm using OpenSearch as the indexing backend, on Drupal 10 and Facets 3.0.0. The default is 10 items when no limit is set. Adding this patch allowed me to set the limit so I could show more.

Marking as RTBC

scott_earnest’s picture

Issue summary: View changes
johnny5th’s picture

Patch works for me

strykaizer’s picture

Thanks,
I do wonder, why hardcode the options? Wouldnt it make more sense to just use a numberfield, which allows the user to pick whatever they prefer?

chrisolof’s picture

Status: Reviewed & tested by the community » Needs work

Confirming MR 262 is working great in my tests.

+1 on the number field idea. It appears these hard-coded options are just carried over from the 2.x config form. Probably it makes for a nice clear "No limit" option chosen by default instead of an empty box. Maybe we'd need to modify this text:

*NOTE: setting to "No limit" sets the hard_limit value to "0", which depending on the search backend could lead to limited results. Try setting to the maximum value if you are experiencing this issue

To something like:

Leave empty for no limit.
Note: Some search backends will still apply a default limit when no hard limit is set. If this affects you, set this to an appropriately-high value or a value that indicates "no-limit" to your search backend.

It appears this new setting still needs to be added into the module's config schema (config/schema/facets.views.schema.yml).

Does this need test coverage?

aleix made their first commit to this issue’s fork.

aleix’s picture

Status: Needs work » Needs review

So, I changed the select to number field and use this text as description:

    $form['facet']['hard_limit'] = [
      '#type' => 'number',
      '#title' => $this->t('Hard limit'),
      '#default_value' => $facet->getHardLimit(),
      '#description' => $this->t('Display no more than this number of facet items.<br>*Note: Some search backends will use 0 as "no limit", and some still apply a default limit when hard limit is set to 0. If this affects you, set this to an appropriately-high value or a value that indicates "no limit" to your search backend'),
    ];

Also added hardlimit in config schema yml and I also did some minor labels changes.

oulalahakabu’s picture

Status: Needs review » Reviewed & tested by the community

Drupal 11, elastic 8, facets 3.0.1 patched, work as designed.

borisson_’s picture

This change looks good, RTBC++

strykaizer’s picture

Issue tags: +Vienna2025

strykaizer’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.