Repository navigation
Conversation
📊 Coverage ReportTotal Coverage: 91% 📁 View detailed coverage by fileFull HTML report available in artifacts Coverage report generated by gcovr |
There was a problem hiding this comment.
Pull request overview
Adds CI coverage for pg_textsearch + meerkat hybrid-search query patterns (RRF and both “recall → rerank” directions), plus supporting CI build/install/caching plumbing and documentation updates.
Changes:
- Add a new SQL compatibility test suite that validates hybrid query correctness and asserts index usage for each recall step.
- Add CI scripts and a composite action to build/cache/install pg_textsearch and run the hybrid-search test on a temporary PostgreSQL 18 instance.
- Update
docs/architecture.mdhybrid-search examples and document a planner/LIMITgotcha for ordered index scans.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/pg/compat/hybridsearch.sql | New SQL test suite covering RRF and both hybrid filter-then-rerank directions. |
| scripts/ci/textsearch-hybrid.sh | CI/local runner that provisions a temp PG instance, installs pg_textsearch + meerkat, and runs the SQL suite. |
| scripts/ci/install-pg-textsearch.sh | Installs a DESTDIR-staged pg_textsearch build into the active PostgreSQL installation. |
| scripts/ci/build-pg-textsearch.sh | Builds pg_textsearch and stages its install tree for caching/reuse. |
| docs/architecture.md | Fix and expand hybrid-search examples; document ORDER BY-without-LIMIT gotchas. |
| .github/workflows/hybrid-search.yml | New workflow to run hybrid-search CI on PRs/pushes with pinned actions and log artifacts. |
| .github/actions/setup-pg-textsearch/action.yml | Composite action to checkout, cache, build, and install pg_textsearch at a pinned tag. |
Suppressed comments (1)
scripts/ci/textsearch-hybrid.sh:89
- PostgreSQL is started with trust auth and (by default) still listens on localhost TCP. Even with
--auth-host=reject, it's safer to explicitly disable TCP listeners for this ephemeral test instance by settinglisten_addresses=''.
"$PG_BINDIR/pg_ctl" -D "$PGDATA" -l "$PGLOG" \
-o "-p $PGPORT -k $TMPDIR_BASE -c shared_preload_libraries=pg_textsearch" \
start
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| PGLOG="$TMPDIR_BASE/postgres.log" | ||
|
|
||
| echo "==> Creating temporary PostgreSQL instance (port $PGPORT)" | ||
| "$PG_BINDIR/initdb" -D "$PGDATA" --no-locale -E UTF8 -A trust > /dev/null |
erimatnor
force-pushed
the
feature/hybrid-search-ci-tests
branch
from
September 1, 2026 21:42
614df56 to
ae8c8b3
Compare
erimatnor
force-pushed
the
feature/hybrid-search-ci-tests
branch
from
September 9, 2026 06:58
ae8c8b3 to
22fce19
Compare
The RRF example used an inner JOIN between the two ranked CTEs, which silently drops any document found by only one signal -- defeating the stated point of fusing independent rankings. Use a FULL JOIN between the two ranked lists instead. A LEFT JOIN from the base table with an IS NOT NULL OR filter also keeps every candidate, but the planner cannot push that OR into the joins and ends up scanning the whole base table to fuse two short lists; the FULL JOIN touches only the candidates. Each CTE also gets its own ORDER BY ... LIMIT, since a window function does not restrict which rows survive. Also documents how each index scan sizes its output, since the two work differently. A PRISM scan sizes its top-k from the query's LIMIT, including inside a CTE, and returns what work_mem affords when there is no usable LIMIT; prism.query_limit caps it by hand. A pg_textsearch scan learns the LIMIT through the planner, and without one scores a default_limit batch and re-runs with a doubled batch while the executor keeps pulling; it only ever emits documents with nonzero term overlap. The safe pattern is a direct LIMIT on each signal's own recall CTE.
… queries Adds CI coverage for the hybrid search patterns pg_textsearch and pg_vectorsearch are jointly designed to support: Reciprocal Rank Fusion via dual CTEs, and filter-then-rerank in both directions (BM25 recall with vector rerank, and vector recall with BM25 rerank). The test corpus is synthetic rather than a real dataset -- five topics with disjoint vocabulary and one-hot embeddings -- so the correct answer is known by construction instead of derived from whatever the query happens to return, and the suite stays fast and network-free. Building pg_textsearch is the expensive, cacheable part, so it is split out from running the tests: build-pg-textsearch.sh and install-pg-textsearch.sh are the single build/install path shared by local runs and CI, and the new setup-pg-textsearch composite action wraps them with a cache keyed on the pinned release tag, mirroring how setup-pg-debug caches PostgreSQL itself. textsearch-hybrid.sh then either reuses that staged build (CI) or builds from source directly (local dev, no cache involved).
build-pg-textsearch.sh passed STAGE_DIR straight through to `make -C "$SRC_DIR" ... install DESTDIR="$STAGE_DIR"`. -C changes make's working directory to $SRC_DIR before DESTDIR is evaluated, so a relative STAGE_DIR resolved against that new directory instead of the caller's -- landing the staged files a level deeper than expected (pg_textsearch/.stage became pg_textsearch/pg_textsearch/.stage) and leaving the real target empty. This is exactly what the CI workflow hits, since the composite action passes the relative "pg_textsearch/.stage"; local runs happened to dodge it because textsearch-hybrid.sh always hands the script an absolute path via mktemp. Canonicalize both paths up front so the ambiguity can't arise regardless of caller.
erimatnor
force-pushed
the
feature/hybrid-search-ci-tests
branch
2 times, most recently
from
September 28, 2026 22:43
8024277 to
23ff98f
Compare
erimatnor
marked this pull request as draft
November 10, 2026 10:17
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.
Adds CI coverage for the hybrid search patterns pg_textsearch and pg_vectorsearch are designed to support together: Reciprocal Rank Fusion over two ranked CTEs, and filter-then-rerank in both directions.
The corpus is synthetic, five topics with disjoint vocabulary and one-hot embeddings, so the correct answer is known by construction and the suite is fast and network-free. Each case checks that results are a duplicate-free subset of an independently computed recall set, which catches join-wiring mistakes a topic-only check would miss.
Building pg_textsearch is the expensive part, so it is split from running the tests.
build-pg-textsearch.shandinstall-pg-textsearch.share the single build path for local runs and CI, thesetup-pg-textsearchcomposite action caches the staged build keyed on the pinned release tag, andtextsearch-hybrid.sheither reuses that stage or builds from source.The architecture note's RRF example uses a
FULL JOINbetween the two ranked lists, since an inner join drops documents found by only one signal, and gives each CTE its ownORDER BY ... LIMIT. It also documents how each index scan sizes its output: PRISM from the query'sLIMIT, pg_textsearch from the planner-recorded limit with a batched fallback, and that only documents with term overlap appear at all.