feat(beachcomber): search highlights and field projection (quick-261108-pe4)

- Additive: Query.IncludeFields, ExcludeFields and Highlight; left empty,
  the Typesense request is the same as before.
- SearchResult.Hits holds one Hit per id, in step with IDs; SearchPage
  always fills it.
- Snippets are plain-text Segment runs split at private-use highlight tags,
  never HTML; MaxSnippetsPerArray is applied client-side.
- Optional HighlightSearcher capability, checked with SupportsHighlights
  (true for Typesense, false for null and third-party engines).
- README and docs: Highlights sections with the rule that a caller drops
  the hit of every id failing the SQL re-check before showing a snippet.

Targets framework v0.6.4 (additive, no breaking change).
This commit is contained in:
Jakub Zych
2026-11-08 18:31:27 +01:00
parent 6f9b77033f
commit 7819c6746c
9 changed files with 756 additions and 27 deletions

View File

@@ -62,7 +62,8 @@ func init() {
}
// nullEngine is never configured, so sync is skipped before it is called.
// Every method is a no-op; SearchIDs and SearchPage return no ids.
// Every method is a no-op; SearchIDs and SearchPage return no ids. It does
// not implement HighlightSearcher.
type nullEngine struct{}
func (nullEngine) Name() string { return NullEngine }
@@ -76,5 +77,5 @@ func (nullEngine) SearchIDs(context.Context, string, Query) ([]string, error) {
return []string{}, nil
}
func (nullEngine) SearchPage(context.Context, string, Query) (SearchResult, error) {
return SearchResult{IDs: []string{}}, nil
return SearchResult{IDs: []string{}, Hits: []Hit{}}, nil
}