Skip to content

Theme Directory: Frontend search misses themes with a misdetected index language, and business-model views#730

Closed
obenland wants to merge 1 commit into
WordPress:trunkfrom
obenland:fix/theme-directory-search-default-lang
Closed

Theme Directory: Frontend search misses themes with a misdetected index language, and business-model views#730
obenland wants to merge 1 commit into
WordPress:trunkfrom
obenland:fix/theme-directory-search-default-lang

Conversation

@obenland

@obenland obenland commented Jul 22, 2026

Copy link
Copy Markdown
Member

Fixes #8376.

Two query-side fixes for Theme Directory frontend search returning no results; no reindex needed for either.

1. Themes with a misdetected index language are unfindable

Themes like brandy, amsel, and shadcn are findable via the Themes API but return zero results on https://wordpress.org/themes/search/.... Directory search goes through Jetpack Classic Search, which builds its Elasticsearch query only against locale-specific analyzed subfields (title.en, content.en, etc.). WP.com's indexer detects each document's language at index time, and that detection is unreliable on short theme descriptions — roughly 1,300 published themes are currently indexed as non-English (spiking in 2026). Those documents have no .en analyzed fields at all, only .default, so they can never match.

Fix: Filter jetpack_search_query_languages to append default to the query languages. Jetpack's Query_Parser::norm_langs() maps any code not in its avail_langs list to default, so the query then also targets the .default analyzed fields, which exist on every document regardless of detected language.

The filter takes no WP_Query context, but the plugin only loads on the themes site, so no further scoping is needed.

2. Searching within the Commercial/Community views returns no results

https://wordpress.org/themes/browse/commercial/?s=shop returns zero results, while browse/commercial/ alone works. The theme_business_model taxonomy is absent from the site's Elasticsearch index (no documents carry taxonomy.theme_business_model.slug), so the term filter Jetpack builds from the tax query excludes every document.

Fix: Filter jetpack_search_should_handle_query to return false for searches carrying a theme_business_model tax query, so they fall back to the SQL search path, which already handles the tax filter correctly. This is a workaround until the taxonomy is indexed in ES; the Photo Directory already uses the same filter to opt out of Jetpack Search.

Verification

After sandboxing/deploy:

  • https://wordpress.org/themes/search/brandy/, /amsel/, and /shadcn/ each return the theme.
  • A control search like /photography/ still returns ~1,000 results via Jetpack (unchanged counts).
  • Raw ES equivalent for fix 1: a multi_match on title.en+title.default against public-api.wordpress.com/rest/v1/sites/88381900/search finds the affected themes, while title.en alone does not.
  • browse/commercial/?s=shop and browse/community/?s=news return results.

🤖 Generated with Claude Code

https://claude.ai/code/session_011pfhLmrkpmrMsMMwrZEKJV

…th a misdetected language remain findable

Jetpack Search queries only locale-specific analyzed fields (title.en,
content.en, etc.), selected by the language WP.com detected at index time.
That detection is unreliable on short theme descriptions, so themes indexed
as non-English have no .en fields and can never match a search on
wordpress.org/themes. The .default analyzed fields exist on every document,
so appending 'default' to the query languages makes those themes findable
again without a reindex.

Fixes #8376.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011pfhLmrkpmrMsMMwrZEKJV
Copilot AI review requested due to automatic review settings July 22, 2026 23:05

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props obenland.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@bazza bazza closed this in 51eb1a5 Jul 22, 2026
@obenland obenland changed the title Theme Directory: Frontend search misses themes with a misdetected index language Theme Directory: Frontend search misses themes with a misdetected index language, and business-model views Jul 23, 2026
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.

2 participants