supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.
https://supabase.com
MIT License
965 stars 129 forks source link

textSearch() uses only English dictionary instead of 'simple' as a default #402

Open kvetoslavnovak opened 1 year ago

kvetoslavnovak commented 1 year ago

In my Supabase collection I have created to_tsvector using 'simple' parameter dictionary as I need multi languages searching. Testis in Supabase SQL editor using to_tsquery('simple', ...) work just fine.

But using client textSearch() method gives highly incorrect results.

I believe the problem and the reason is that Supabase uses only 'english' dictionary as a hidden to_tsvector parameter for textSearch() method. Is there any way how to specify in textSearch() the dictionary language parameter? I would guess 'simple' dictionary should be the default one instead. Why this "imperial English supremacy" ?

Anyway textSearch() should accept the parameter specifying the language for to_tsvector.

steve-chavez commented 1 year ago

Anyway textSearch() should accept the parameter specifying the language for to_tsvector.

See https://supabase.com/docs/reference/javascript/textsearch, you can set the dictionary in the config param.

const { data, error } = await supabase .from('quotes') .select('catchphrase') .textSearch('catchphrase', 'fat' & 'cat', { config: 'english' })

soedirgo commented 1 year ago

Thanks @kvetoslavnovak, in hindsight we should default to 'simple' instead - we'll make the change on the next major version of the library.

kvetoslavnovak commented 1 year ago

Thank you very much @soedirgo . And big thank to @steve-chavez for the tip.

siisee11 commented 8 months ago

default to 'simple' is merged or is still use 'english' as default?