Repository navigation
feat: serve PostQuery - #25
Open
mattdjenkinson wants to merge 1 commit into
Open
mattdjenkinson wants to merge 1 commit into
mattdjenkinson wants to merge 1 commit into
Conversation
PostQuery searches, filters, sorts and facets posts without storing anything. - Filters on state, categories, orgs and delivery stage, plus votedByMe and followedByMe in the user context. Sorts top, newest, trending, recentlyChanged and relevance. Facets count over every match. Offset continue tokens are tied to the query that made them. - text runs a ResourceSearchQuery against the posts index when --search-kubeconfig is set, and Postgres keyword matching otherwise. - similarTo embeds the text through an OpenAI-compatible AI gateway and ranks posts by pgvector cosine distance, falling back to keyword matching with a Warning when embeddings aren't available. It is rate limited per user. - The apiserver embeds new and changed posts in the background, one replica at a time, keyed by model and a hash of the text. - Migration 00004 adds a weighted tsvector column on posts and a GIN index on categories. Part of datum-cloud/enhancements#943. Closes #5.
This was referenced Nov 12, 2026
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.
Serves
PostQuery: search, filter, sort and facet posts in one create call. Nothing is stored. Closes #5.Stacked on #23 (which is on #22 and #16). Review those first; GitHub retargets this to
mainas they merge.What it does
state,categories,orgs(case-insensitive) anddeliveryStage.votedByMeandfollowedByMework in the user context only; elsewhere the query is rejected as Invalid.top,newest,trending,recentlyChanged, andrelevance(the default whentextorsimilarTois set).limit(default 20, max 100) andcontinue. A continue token only works with the query that produced it.text: sends aResourceSearchQueryforPostto Milo's search service (--search-kubeconfig), applies filters in Postgres, and keeps search's ranking. If search fails the query returns 503; browsing andsimilarTokeep working, as in the design. Without the flag,textuses Postgres keyword matching: a new weightedtsvectorcolumn with title over summary over body, matching any of the words.similarTo: embeds the text through an OpenAI-compatible gateway (--ai-gateway-url,--embedding-model,--ai-gateway-token-file) and ranks the 100 nearest posts by pgvector cosine similarity. It falls back to keyword matching, with aWarningheader, when the gateway fails or nothing is embedded yet. Each user is rate limited (--similar-to-rate30/min,--similar-to-burst10, per replica), returning 429 withRetry-After.--embed-interval. Staleness is keyed on model plus an md5 of the text, so any change to title, summary or body is picked up, and changing the model re-embeds everything. A Postgres advisory lock keeps it to one replica at a time.Not in this PR
--ai-gateway-urlthe server runs withsimilarToon keyword matching. Choosing the model and dimension is the open question on PostQuery #5.ResourceIndexPolicyfor posts is Search integration #12. Until it exists the search service reports posts as denied, which this treats as unavailable.postqueriesgo with the other resources in Identity, contexts and authorization #10.Testing
votedByMeandfollowedByMeacross users and contexts;similarTowith a fake embedder: ranking, fallback before anything is embedded, fallback when the gateway is down, re-embedding on a summary change and on a model change;votedByMeworked from the user context and was refused from the platform context;similarToranked the ALB and billing posts first;Retry-After: 10s;