You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
search-typesense: a reference facet query counts 50 arbitrary matches, missing the values that occur most #1102
A query on a reference facet counts only the first 50 referents that match the text, picked without knowing which of them the current documents use. When more than 50 referents match, the buckets are an arbitrary slice: values used by many documents go missing, and values used by one document show up.
withCandidates in @lde/search-typesense searches the target collection with limit: maxFacetQueryCandidates (default 50, at most 250), ranked by text relevance. countCandidates then counts the facet restricted to those IRIs.
Example
Linked Open Limburg, @lde/search-api-graphql 0.53.1 (search-api-server 0.55.1), local full index. The about facet holds 10022 values. Without a query, the values with “Petrus Regout” in their label start with:
count
label
69
Timor (Petrus Regout/Sphinx)
62
Flora (Petrus Regout/Sphinx)
56
Tancrede (Petrus Regout/Sphinx)
53
Cedra (Petrus Regout/Sphinx)
terms(query: "petrus") finds 5056 terms. So about(limit: 100, query: "petrus") returns 48 buckets with counts from 9 down to 1, none of the four above among them, and totalValues: null. The top hits of the term search (“Petrus” and the De Sphinx company itself) aren’t about values on any work, which is why there are 48 buckets rather than 50.
On another instance with a smaller index (limburg/lol#359) the same query returns 3 buckets: which values a user gets depends on the index build.
Typing more doesn’t help: nearly all 5056 labels end in “(Petrus Regout/Sphinx)”, so “petrus regout” still matches thousands.
Raising maxFacetQueryCandidates doesn’t fix it either: 250 is Typesense’s per-page maximum, far below 5056.
What a fix needs
The buckets for a facet query should be the matching values with the highest counts over the current documents, as without a query. That means the selection step has to know which referents occur, or the matching has to happen on the facet field itself.
lde#1100 built the second of the two options in lde#533, searching the referenced collection, and that issue already noted that the first step “doesn’t know which referents occur in the result set”. This is that weakness showing up in practice. The other option, a label stored beside the IRI in a facetable field, overlaps with lde#1058, which puts referent labels on the root document for search.
Activity