Repository navigation
feat(search-api-graphql): search within a facet’s values - #1100
Merged
Merged
Conversation
- Add SearchQuery.facetQueries; facetSearches gives each facet with a query a search of its own, and validateQuery rejects a query on a facet that takes none - Treat text shorter than three characters, once trimmed, as no query (facetQueryText) - Compile a literal facet's query to Typesense facet_query, separating words at a colon - Answer a reference facet's query in two steps: search each target collection for candidates, then count each candidate on the field the facet buckets (maxFacetQueryCandidates, default 50) - Offer a query argument on each GraphQL facet that takes one, charged 1 more per target type on a reference facet
ddeboer
force-pushed
the
feat/facet-query
branch
from
November 17, 2026 11:37
43bbc6b to
f8127ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #533. A client can search a facet’s values:
creator(query: "rem", limit: 10)returns the creators matching “rem”, counted over the current results. Linked Open Limburg needs it forcreator,materialandabout(limburg/lol#221).How it works
@lde/search:SearchQuery.facetQueriesbesidefacetLimits.facetSearchesgives each facet with a query a search of its own, andvalidateQueryrejects a query on a facet that takes none (not-queryable: unlabelled references, booleans, ranges, presence). Text shorter than three characters once trimmed (MIN_FACET_QUERY_LENGTH,facetQueryText) is no query: locally “r” matched 76 terms, “re” 5095 and “rem” 2, so below three the match is noise.@lde/search-typesense:facet_query, whosestats.total_valuescounts only the matching values (checked on 30.2).maxFacetQueryCandidates(default 50) referents per type. Step 2 counts each candidate with a search of its own, on the field the facet buckets, so a facet policy’s exclusions hold.abouthas 10022 values in 19694 works), against ADR 12. Locally, 50 counts took 13 ms against 10 ms for one facet search.totalValuesis the number of candidates that occur, or absent when step 1 left referents out.@lde/search-api-graphql: aqueryargument on each facet that takes one, besidelimit: on a plain value facet and on a field’s facet object (‹Type›‹Field›Facet). Under a query a facet returns only matching values, selected or not: the one documented exception to reporting every selected value. A query on a reference facet costs 1 more per target type.Left open
searchFacetsbatch, the other facets wait for the two candidate round-trips. The listing’s own hits search is unaffected, because GraphQL sends it separately.::areaches Typesense as a one-letter prefix after passing the length check.