# 21. Implement iOS search service (FTS)

meta:
  id: native-business-logic-migration-21
  feature: native-business-logic-migration
  priority: P1
  depends_on: [native-business-logic-migration-15]
  tags: [implementation, ios, search]

objective:
- Implement full-text search service using Core Data FTS or SQLite FTS

deliverables:
- SearchService.swift
- SearchQuery.swift
- SearchResultProvider.swift
- FTS index management
- Search history storage

tests:
- Unit: Test query parsing
- Unit: Test FTS queries
- Unit: Test result ranking
- Integration: Test search with real data

acceptance_criteria:
- Full-text search working
- Search history maintained
- Results ranked by relevance
- Performance: <200ms for search
- Fuzzy matching supported

validation:
- Run unit tests
- Test with large dataset

notes:
- Use Core Data FTS or GRDB FTS5
- Implement search suggestions
- Cache frequent queries
