Function: toSearchTerms()
toSearchTerms(
query):string[]
Split a search-box string into the terms a tsquery is built from, using the
shared @dbx-tools/shared-core tokenizer so the splitting rules stay
consistent with the rest of the toolkit.
Splitting on punctuation is what makes store-intelligence behave like
store intelligence. Postgres indexes a hyphenated word as the compound
lexeme PLUS each of its parts, but compiles a hyphenated QUERY to the
compound alone - so store-intelligence demands a store-intellig lexeme
that a document titled racetrac-store-intelligence does not have, and the
search silently returns nothing while store intelligence returns
everything. Same for . and _ in a table reference.
camelCase: false is load-bearing rather than a default: the camelCase
splitter also breaks digit runs, turning gpt4 into gpt + 4 and s3
into s + 3. Postgres indexes each of those as ONE lexeme, so no lexeme
ever starts with the trailing digits and the precise pass could not match
them. Keeping punctuation as the only boundary mirrors how the index was
built.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string[]