Skip to content

feat(search): configurable facets size - #3738

Open
abulte wants to merge 2 commits into
opendatateam:mainfrom
ecolabdata:feat/search/facet-size
Open

feat(search): configurable facets size#3738
abulte wants to merge 2 commits into
opendatateam:mainfrom
ecolabdata:feat/search/facet-size

Conversation

@abulte

@abulte abulte commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Related datagouv/data.gouv.fr#1432
Related datagouv/cdata#1054

This lets the consumer use a query parameter ?facet_size__{facet_name}={value} to request more bucket values for a facet from ElasticSearch.

There's a configurable MAX_FACET_SIZE that defaults to 500. Increasing the facet size leads to more resource usage in ES, this a defensive value that needs to be discussed.

Not all facets can be configured, it's in a configurable_size_facets[] list on the adapter. Only organization_id_with_name is in there for now. Listing the facts was needed to generate a proper query arg parser, and I took the opportunity to limit the facets that can be configured. We could include more facets by default. We could also refactor to auto-list all the supported facets, but it's a bigger rework ⬇️.

⬆️ This rework is proposed in ecolabdata#10, I can merge that one into this one if it makes sense.

For ecologie.data.gouv.fr, this would let use facet_size__organization_id_with_name=200 for the filter from datagouv/cdata#1054 to have all the values from our universe. It would also need to be wired up in cdata's GlobalSearch.

Reference: https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-terms-aggregation#search-aggregations-bucket-terms-aggregation-size

@abulte
abulte marked this pull request as ready for review April 24, 2026 08:37
@abulte

abulte commented Apr 24, 2026

Copy link
Copy Markdown
Contributor Author

@ThibaudDauce can't assign you as reviewer from a fork... Can you have a look? 🙏

@maudetes
maudetes requested a review from ThibaudDauce April 24, 2026 10:13
@abulte

abulte commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Idea: use SOLR DSL for url queries https://solr.apache.org/guide/solr/latest/query-guide/faceting.html (thanks @streino)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant