Postgres full text search

Hello, everyone, I have followed this tutorial to learn full-text search, but I want to know if it's possible to apply it on different Language 'Arabic', is it possible and how?
Ben Awad
YouTube
Full Text Search PostgreSQL
Learn how to implement full text search in PostgreSQL. Code: https://github.com/benawad/postgres-full-text-search Links from video: https://www.postgresql.org/docs/9.5/textsearch.html ---- If you like cooking, checkout my side project: https://www.mysaffronapp.com/ ---- Join the Discord: https://discord.gg/Vehs99V ---- Patreon: https://www...
2 Replies
Prisma AI Help
Prisma AI Help3mo ago
You've gone full bot mode! Let me fetch that AI answer for you ASAP. Yes, it is possible to use PostgreSQL full-text search with different languages, including Arabic, but there are important considerations when using Prisma. How it works in PostgreSQL:
PostgreSQL’s full-text search supports multiple languages by specifying a text search configuration (e.g., 'english', 'spanish', 'arabic') in the to_tsvector and to_tsquery functions. For example:
SELECT * FROM "Blog" WHERE to_tsvector('arabic', "content") @@ to_tsquery('arabic', 'بحث');
SELECT * FROM "Blog" WHERE to_tsvector('arabic', "content") @@ to_tsquery('arabic', 'بحث');
This tells PostgreSQL to use the Arabic dictionary for parsing and searching text. With Prisma:
Prisma’s full-text search for PostgreSQL is still in Preview and uses the default text search configuration unless you use raw SQL. The Prisma Client API does not currently allow you to specify the language directly in the search filter. If you need to use a specific language like Arabic, you must use raw SQL queries:
const term = 'بحث';
const result = await prisma.$queryRaw`
SELECT * FROM "Blog"
WHERE to_tsvector('arabic', "content") @@ to_tsquery('arabic', ${term});
`;
const term = 'بحث';
const result = await prisma.$queryRaw`
SELECT * FROM "Blog"
WHERE to_tsvector('arabic', "content") @@ to_tsquery('arabic', ${term});
`;
This approach lets you leverage PostgreSQL’s support for Arabic or any other language you need. You may need to ensure the Arabic text search configuration is installed in your PostgreSQL instance. Limitations:
- The Prisma Client’s built-in search filter does not support specifying the language for full-text search in PostgreSQL at this time. - For multi-language support, you must use raw SQL or manage language-specific indexes and queries yourself. For more details, see the Prisma docs on full-text search with raw SQL and related discussions about language support and limitations here and here. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Nurul
Nurul3mo ago
Hi! Was the bot answer not helpful?

Did you find this page helpful?