* SQL predicate selecting only the locale's documents, so the row limit applies * to matching rows: non-English docs are prefixed with their locale segment; * English is everything not prefixed with another locale.
(locale: string)
| 188 | * English is everything not prefixed with another locale. |
| 189 | */ |
| 190 | function localeFilter(locale: string) { |
| 191 | const firstSegment = sql`split_part(${docsEmbeddings.sourceDocument}, '/', 1)` |
| 192 | if (locale === DEFAULT_LOCALE) { |
| 193 | const others = KNOWN_LOCALES.filter((l) => l !== DEFAULT_LOCALE) |
| 194 | return sql`${firstSegment} not in (${sql.join( |
| 195 | others.map((l) => sql`${l}`), |
| 196 | sql`, ` |
| 197 | )})` |
| 198 | } |
| 199 | return sql`${firstSegment} = ${locale}` |
| 200 | } |
| 201 | |
| 202 | type SearchRow = { |
| 203 | chunkId: string |