Skip to content

feat(api): add query-wide post-type facets - #4

Merged
fgirolami29 merged 9 commits into
mainfrom
feat/search-facets-v0.2.1
Sep 19, 2026
Merged

fgirolami29 merged 9 commits into
mainfrom
feat/search-facets-v0.2.1

Conversation

@fgirolami29

Copy link
Copy Markdown
Contributor

0.2.1

Adds opt-in query-wide facet counts to the public SearchEngine API.

Contract

SearchEngine::resolve() accepts:

[
    'include_facets' => true,
]

and SearchResultSet now exposes:

public readonly array $facets;

Each SearchFacet contains:

  • post type
  • semantic context key / label / badge
  • accent color
  • exact count for the full search query

Facet counts reuse the same isolated resolver contract as the main result query and never mutate the global $wp_query.

The extra facet queries are opt-in, so existing consumers keep the 0.2.0 query cost unless they request facets.

Bump: 0.2.1.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7735f3c408

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

$facets = ! empty( $options['include_facets'] )
? $this->facets( $resolver, $collection, $options, $post_types )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize post types before building facets

When a caller uses the comma-separated post_types form already accepted by SearchQueryResolver::sanitizePostTypes(), enabling include_facets passes that string directly to facets(), whose $post_types parameter requires an array, causing a TypeError instead of returning results. The same raw pass-through lets invalid array entries be queried as any and reported under the invalid type; normalize the value once before both the main query and facet construction.

Useful? React with 👍 / 👎.

Comment thread package.json
{
"name": "cc-divi5-search-results",
"version": "0.2.0",
"version": "0.2.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the npm lockfile with the version bump

This changes the package version to 0.2.1 while package-lock.json still records 0.2.0 both at its root and in packages[""]. That leaves the committed manifest and lock metadata inconsistent and violates the lockfile synchronization contract documented in README.md:271; regenerate and commit the lockfile with the bump.

Useful? React with 👍 / 👎.

@fgirolami29
fgirolami29 merged commit 872749a into main Sep 19, 2026
1 check passed
@fgirolami29
fgirolami29 deleted the feat/search-facets-v0.2.1 branch September 19, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant