Full-text search retrieves by words and linguistic forms, making it strong for exact names, error codes, product identifiers, and rare terms that dense embeddings may blur. PostgreSQL converts documents to weighted tsvector values, queries to tsquery, uses GIN indexes for matching, and ranks results. Combine lexical and semantic retrieval rather than forcing one to solve both.
This fixed English configuration is only an example. For multilingual content, use per-language columns/partitions or an update trigger that selects an allowlisted configuration. Configuration names are identifiers and should not come directly from a request.
websearch_to_tsquery accepts familiar web-search syntax and avoids raw to_tsquery syntax errors for ordinary user text. Still limit query length and complexity.
Keep normalized identifier columns with B-tree or trigram indexes where needed. Full-text tokenization can split punctuation in SKUs, versions, stack traces, or paths. Hybrid retrieval may include an exact-identifier branch with a strong business rule.
Test stemming, stop words, phrases, negation, exact IDs, misspellings, and every supported language. Inspect to_tsvector output so you see lexemes and positions. Confirm GIN usage with EXPLAIN, and compare lexical recall with dense retrieval on identifier-heavy queries.
Design PostgreSQL lexical search for these languages, identifiers, fields, and query styles [details]. Propose tsvector construction, weights, safe query parser, GIN indexes, exact-ID branches, fixtures, and metrics. Explain multilingual limitations.
Verification contract: Evaluate lexical search alone before hybrid fusion and include rare identifiers plus no-result cases.