Full-text search on jsonb column

Hey, I was experimenting with full-text search and drizzle. I saw in the docs an example for full-text search https://orm.drizzle.team/docs/sql, but this seems to only work with text columns. How would I convert the where statement to make it work with jsonb? @Angelelz
7 Replies
Angelelz
Angelelz13mo ago
What dialect are you using? I'm honesly not super familiar with jsonb tbh
MAST
MAST13mo ago
Database Administrators Stack Exchange
How can I use a full-text search on a jsonb column with Postgres?
So i have a jsonb column that has entries like this: https://pastebin.com/LxJ8rKk4 Is there any way to implement a full-text search on the entire jsonb column?
itsyoboieltr
itsyoboieltrOP13mo ago
Postgresql @Angelelz thanks, will see if I can get this to work
MAST
MAST13mo ago
In the Postgresql docs https://www.postgresql.org/docs/11/functions-textsearch.html if you search for json(b) you can see a couple of ways of doing it.
PostgreSQL Documentation
9.13. Text Search Functions and Operators
9.13. Text Search Functions and Operators Table 9.40, Table 9.41 and Table 9.42 summarize the functions and operators that are provided for full text …
MAST
MAST13mo ago
Or this link (newest docs version 16) https://www.postgresql.org/docs/current/functions-textsearch.html search for jsonb
PostgreSQL Documentation
9.13. Text Search Functions and Operators
9.13. Text Search Functions and Operators # Table 9.42, Table 9.43 and Table 9.44 summarize the functions and operators that are provided for full …
itsyoboieltr
itsyoboieltrOP13mo ago
This is for future dwellers: I ended up doing the simplest thing ever (which was enough for my use-case of just searching for any substring in a nested json tree)
where(
sql`${table.column}::text ILIKE ${`%${search}%`}`
)
where(
sql`${table.column}::text ILIKE ${`%${search}%`}`
)
DCsan
DCsan7mo ago
thanks! did you find any way to query arrays in JSONb columns?
Want results from more Discord servers?
Add your server