feat: return objets counts in orgs suggest for search facets - #3838
feat: return objets counts in orgs suggest for search facets#3838ThibaudDauce wants to merge 5 commits into
Conversation
Samuelfaure
left a comment
There was a problem hiding this comment.
LGTM (not approving cause I dont feel confident enough in my skills on this repo)
|
@ThibaudDauce congrats on your creativity 🧠 As per being a replacement of #3738, from what I understand it suffers from the following limitations:
I think your solution could work well in a purely "query suggest" context, I guess that's what you have a mind for data.gouv.fr's search. But for our current requirement on ecologie.data.gouv.fr (replicate the organisation list filter here https://ecologie.data.gouv.fr/datasets), it would fall a bit short. |
|
@abulte I reworked the PR to cover your case. Two additions:
For your org list filter on a topic, e.g.: → organizations of the topic, ranked by followers, each with its dataset count in the This keeps facet sizes internal (so it also replaces the need from #3738). I'm not assuming |
|
@ThibaudDauce Thanks! It does seem to cover some important use cases: organisations lists for the current universe in datasets and dataservices. It would even cover things #3738 didn't:
What it would not cover and #3738 did: list the orgs for a list of Topics (organisations list here https://ecologie.data.gouv.fr/bouquets). Thinking ahead, it would also fail to cover precise results for a query like Overall, I fell this might be over-engineered for topic-specific needs compared to a If exposing ES internals really is a problem, maybe we could introduce |
|
On "over-engineered for topic-specific needs": the topic part is actually an add-on; So it's really two problems: the unbounded one (data.gouv), which only the suggest solves, On performance — I benchmarked the MongoDB derivation
Local test MongoDB, ~200 unique orgs; cost is driven by the number of datasets in the The cost is isolated to the topic path (data.gouv stays at ~2ms, no derivation) and only On the dedicated endpoint: I'd rather not nest it under On the multi-topic bouquets list: agreed, neither this nor a single-topic filter covers Does this address your concerns, or is there a case you still feel is missed? Maybe @maudetes have an opinion too? |
GET /organizations/suggest/can now annotate each suggested organization with thenumber of objects it owns that match a search, so a frontend can build an organization
filter with counts.
Parameters (all optional, on top of the existing
q/size):count_for(dataset|reuse|dataservice): annotate each suggestion with amatching_count. Without it the endpoint stays a plain name suggest.count_filter.*: the search the count is scoped to (e.g.count_filter.tag=transport).Namespaced so the dataset full-text query (
count_filter.q) never collides with theorganization name query (
q).topic: restrict candidate organizations to those owning acount_forobject in thistopic (the "universe").
count_facet_ids: organization ids from the caller's current search facet, kept ascandidates so organizations that actually have results show up even when they are not
the most followed. They go through the same name +
topicconstraints as the rest.How it works:
(restricted to
topicwhen given), merged with the matchingcount_facet_ids.size: 0aggregation (includeon thecandidate ids, scoped by
count_filter.*) — no result fetching.are never used as a sort key.
matching_countisnullwhencount_foris absent,0when counted with no match,>0otherwise.Replaces #3804. Covers #3738's organization-filter need through
topic+count_facet_idswithout exposing Elasticsearch facet sizes to API consumers.