diff --git a/server/internal/store/api_people.go b/server/internal/store/api_people.go index 1e211e7..794c5de 100644 --- a/server/internal/store/api_people.go +++ b/server/internal/store/api_people.go @@ -59,7 +59,13 @@ func (s *Store) SearchVisitors(ctx context.Context, clientID, query string, limi OR v.label ILIKE $3 ESCAPE '\' OR p.full_name ILIKE $3 ESCAPE '\' OR p.phone ILIKE $3 ESCAPE '\' - OR p.email ILIKE $3 ESCAPE '\') + OR p.email ILIKE $3 ESCAPE '\' + -- Notes are searched for ONE reason: a merge records the + -- phone and name it had to discard there, and a customer + -- reached by their old number is exactly who somebody is + -- looking for when they type it. Retained-but-unfindable + -- answers the letter of "nothing is lost" and not the point. + OR p.notes ILIKE $3 ESCAPE '\') ORDER BY v.last_seen_at DESC NULLS LAST, v.first_seen_at DESC LIMIT $4`, clientID, strings.TrimSpace(query), likePattern(strings.TrimSpace(query)),