feat(search): add ranked post id pool API#3
Merged
Conversation
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a new consumer-facing API, WPVDB_Search\Search::post_ids(), to return an ordered, de-duplicated pool of ranked post IDs (for callers that want to hydrate results in their own WP_Query context) while keeping Search::run() behavior and payload unchanged.
Changes:
- Introduces
Search::post_ids()andSearch::MAX_POOL(200), reusing existing dense/sparse/hybrid ranking and collapsing chunk rows to uniquedoc_ids. - Adds a private helper
collapse_raw_post_ids()to de-duplicate merged chunk rows while preserving rank order. - Updates unit tests, test bootstrap stubs, and README documentation to cover and describe the new API.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| includes/class-search.php | Adds MAX_POOL, implements post_ids(), and adds collapse_raw_post_ids() to return ranked unique post IDs. |
| tests/Unit/SearchTest.php | Adds unit tests covering raw collapse behavior, post ID pools across modes, and pool clamping. |
| tests/bootstrap.php | Extends WP/WPVDB stubs to support fulltext checks, embeddings, and SQL/json helpers used by the new path. |
| README.md | Documents Search::post_ids() usage, arguments, max pool cap, and hydration/visibility responsibilities for callers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Adds
Search::post_ids()for consumers that need a ranked pool of unique post IDs and want to hydrate inside their ownWP_Querycontext.Search::MAX_POOL, capped at 200.doc_idbefore hydration.Search::run()unchanged, including the public 20 result cap and response shape.Manual test plan
Search::post_ids()from a small test plugin, a theme snippet, orwp evalwithmodevaluesdense,sparse, andhybrid.perm => readablehydration pass and preserve the returned ranking withorderby => post__in.Search::run()still returns the existing result payload.