Skip to content

feat: Add fuzzy search, date display, and improved search result prioritization#550

Merged
stasadev merged 5 commits intoddev:mainfrom
stasadev:20260217_stasadev_search
Feb 18, 2026
Merged

feat: Add fuzzy search, date display, and improved search result prioritization#550
stasadev merged 5 commits intoddev:mainfrom
stasadev:20260217_stasadev_search

Conversation

@stasadev
Copy link
Member

@stasadev stasadev commented Feb 17, 2026

The Issue

The site search was too strict, requiring exact matches. Search results didn't show publication dates, making it difficult to assess content recency. Blog posts lacked article:published_time OpenGraph metadata for SEO. Category/author index pages were incorrectly labeled as "Blog Post" in results.

How This PR Solves The Issue

Search improvements:

  • Add fuzzy matching (0.2 tolerance) for typo forgiveness
  • Add prefix matching for partial term searches
  • Display publication dates for blog posts (format: "Month DD, YYYY")
  • Prioritize blog posts over other pages in search results
  • Sort by: blog posts first → relevance score → date (tiebreaker)
  • Boost title matches 2x for better relevance
  • Extract isBlogPost helper to eliminate duplicate logic
  • Fix category/author pages incorrectly labeled as "Blog Post"

Metadata enhancements:

  • Add article:published_time OpenGraph metadata to blog post pages
  • Store publication dates in search index via article:published_time extraction
  • Pass pubDate prop through Layout component

Code quality:

  • Simplify search result detection with reusable isBlogPost function
  • Clean three-tier sorting: content type → relevance → recency

Manual Testing

https://pr-550.ddev-com-fork-previews.pages.dev/search/

  1. Search with typos (e.g., "ddevv") - fuzzy matching finds "ddev"
  2. Search partial terms (e.g., "dock") - prefix matching finds "docker"
  3. Verify blog posts appear before pages in mixed results
  4. Check search results show dates for blog posts only
  5. Verify <meta property="article:published_time"> in blog post HTML
  6. Rebuild and verify search.json includes date field

@github-actions
Copy link

github-actions bot commented Feb 17, 2026

🌐 Fork Preview for PR #550

https://pr-550.ddev-com-fork-previews.pages.dev

This preview updates automatically when you push changes to your fork.

@rfay
Copy link
Member

rfay commented Feb 17, 2026

Could search results be in descending modified date?

@stasadev stasadev force-pushed the 20260217_stasadev_search branch from 72bac98 to 94509c3 Compare February 17, 2026 18:56
@stasadev
Copy link
Member Author

Could search results be in descending modified date?

I added support for modified date, but note that the search will still prefer blog titles (so it won't always be descending modified date).

@rfay
Copy link
Member

rfay commented Feb 17, 2026

Thanks. I'm not trying to send you down a rabbit-hole here, but it doesn't seem to be accomplishing what I hoped. No need to worry too much.

image

@stasadev
Copy link
Member Author

stasadev commented Feb 18, 2026

That's because the word "windows" appeared much more often in the first blog post.

I pushed another change, should be better now.

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Thanks! It definitely behaves the way I'd expect now.

When you get interested in it again, it would be useful to show both pubDate and modifiedDate in the search results.

stasadev and others added 5 commits February 18, 2026 20:07
…ritization

## The Issue

The site search was too strict, requiring exact matches. Search results didn't show publication dates, making it difficult to assess content recency. Blog posts lacked article:published_time OpenGraph metadata for SEO. Category/author index pages were incorrectly labeled as "Blog Post" in results.

## How This PR Solves The Issue

**Search improvements:**
- Add fuzzy matching (0.2 tolerance) for typo forgiveness
- Add prefix matching for partial term searches
- Display publication dates for blog posts (format: "Month DD, YYYY")
- Prioritize blog posts over other pages in search results
- Sort by: blog posts first → relevance score → date (tiebreaker)
- Boost title matches 2x for better relevance
- Extract isBlogPost helper to eliminate duplicate logic
- Fix category/author pages incorrectly labeled as "Blog Post"

**Metadata enhancements:**
- Add article:published_time OpenGraph metadata to blog post pages
- Store publication dates in search index via article:published_time extraction
- Pass pubDate prop through Layout component

**Code quality:**
- Simplify search result detection with reusable isBlogPost function
- Clean three-tier sorting: content type → relevance → recency

## Manual Testing

1. Search with typos (e.g., "ddevv") - fuzzy matching finds "ddev"
2. Search partial terms (e.g., "dock") - prefix matching finds "docker"
3. Verify blog posts appear before pages in mixed results
4. Check search results show dates for blog posts only
5. Verify `<meta property="article:published_time">` in blog post HTML
6. Rebuild and verify search.json includes date field

## Automated Tests

No automated tests added. Changes affect:
- Client-side search (src/pages/search.astro)
- Search index generation (src/lib/search-index.js)
- OpenGraph metadata (src/layouts/Layout.astro)

## Release Notes

**Minor version bump** - New features added (fuzzy search, date display, metadata)

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@stasadev stasadev force-pushed the 20260217_stasadev_search branch from a4f134a to 59be544 Compare February 18, 2026 18:07
@stasadev
Copy link
Member Author

it would be useful to show both pubDate and modifiedDate in the search results

Good idea, done.

@rfay
Copy link
Member

rfay commented Feb 18, 2026

So great!

@stasadev stasadev merged commit cae832d into ddev:main Feb 18, 2026
4 checks passed
@stasadev stasadev deleted the 20260217_stasadev_search branch February 18, 2026 18:24
@github-actions
Copy link

PR closed. The Cloudflare Pages preview is no longer updated.

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

Comments