Skip to content

feat(search): index and filter by created_by, updated_by, created_at, updated_at#53

Merged
rgonek merged 9 commits intomainfrom
feat/frontmatter-author-date-search
Mar 3, 2026
Merged

feat(search): index and filter by created_by, updated_by, created_at, updated_at#53
rgonek merged 9 commits intomainfrom
feat/frontmatter-author-date-search

Conversation

@rgonek
Copy link
Owner

@rgonek rgonek commented Mar 3, 2026

Summary

  • Adds created_by, created_at, updated_by, updated_at from YAML frontmatter to the search index (denormalized into every page/section/code document).
  • Both SQLite and Bleve backends gain four new columns/fields and filter clauses for all four fields.
  • CLI gains six new conf search flags: --created-by, --updated-by, --created-after, --created-before, --updated-after, --updated-before.

Changes

internal/search/document.go

  • Added CreatedBy, CreatedAt, UpdatedBy, UpdatedAt to Document struct.
  • Added CreatedBy, UpdatedBy, CreatedAfter, CreatedBefore, UpdatedAfter, UpdatedBefore to SearchOptions.

internal/search/indexer.go

  • Populate the four new fields from frontmatter in indexFile() for page, section, and code documents.
  • Added normalizeDate helper.

SQLite backend (internal/search/sqlitestore/)

  • schema.go: Four new columns + two indexes.
  • store.go: Updated INSERT, SELECT, Scan, and WHERE clauses; added addColumnsIfMissing() migration helper.
  • New tests: TestStore_FilterByCreatedBy, TestStore_FilterByUpdatedBy, TestStore_FilterByCreatedAfterAndBefore, TestStore_FilterByUpdatedAfter, TestStore_AuthorFieldsRoundTrip.

Bleve backend (internal/search/blevestore/)

  • mapping.go: Four new field mappings.
  • store.go: Updated docToMap, mapToDoc, buildQuery; added buildDateRangeQuery helper using MinRFC3339CompatibleTime/MaxRFC3339CompatibleTime sentinels.
  • New tests: TestBleve_FilterByCreatedBy, TestBleve_FilterByUpdatedBy, TestBleve_FilterByCreatedAfterAndBefore, TestBleve_FilterByUpdatedAfter, TestBleve_AuthorFieldsRoundTrip.

CLI (cmd/search.go, cmd/search_test.go)

  • Six new flags registered and wired through searchRunOptionsstore.Search.
  • normalizeDateBound helper: expands YYYY-MM-DD to RFC3339; passes through existing RFC3339 strings unchanged.
  • shortDate helper: trims RFC3339 to YYYY-MM-DD for text output.
  • Text output byline shows Created by, Created, Updated by, Updated when fields are present.
  • projectResult standard case now preserves the four new fields.
  • QUERY guard relaxed to allow filter-only queries (no text query required when any filter flag is set).
  • New tests: TestSearch_CreatedByFlag, TestSearch_UpdatedByFlag, TestNormalizeDateBound_*, TestShortDate_*.

Test Results

All tests pass: go test ./... and go build ./... succeed.

Robert Gonek and others added 9 commits March 3, 2026 19:40
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add buildDateRangeQuery helper using MinRFC3339CompatibleTime/MaxRFC3339CompatibleTime
as sentinels for unbounded ranges. Wire CreatedBy, UpdatedBy, CreatedAfter,
CreatedBefore, UpdatedAfter, UpdatedBefore filters in buildQuery.
Add five tests covering all new filter paths and field round-trip.
…ore, --updated-after/before flags

Add six new filter flags wired through searchRunOptions and store.Search.
Add normalizeDateBound helper to expand YYYY-MM-DD to RFC3339.
Add shortDate helper for text output byline.
Show author/date byline in text output when fields are present.
Preserve new fields in standard result projection.
Relax QUERY requirement when any filter flag is provided.
Add CLI integration tests and unit tests for both helpers.
…t field mappings

These were part of Task 4 but not staged in the earlier commit.
@rgonek rgonek merged commit 2e0a515 into main Mar 3, 2026
2 checks passed
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