Full-text search (Prisma ORM v7)
Learn how to search text fields with Prisma Client using your database's native full-text search support.
Prisma Client supports full-text search for MySQL and for PostgreSQL with the fullTextSearchPostgres preview feature.
Enabling full-text search for PostgreSQL
Section titled “Enabling full-text search for PostgreSQL”Add the preview flag to your generator and re-generate Prisma Client:
generator client {
provider = "prisma-client"
output = "./generated"
previewFeatures = ["fullTextSearchPostgres"]
}bunx prisma generatepnpm prisma generateyarn prisma generatenpx prisma generateSearch within a text field
Section titled “Search within a text field”const posts = await prisma.post.findMany({
where: {
body: {
search: "cat | dog",
},
},
});Sort by relevance
Section titled “Sort by relevance”Prisma Client also supports relevance-based ordering on supported databases:
const posts = await prisma.post.findMany({
orderBy: {
_relevance: {
fields: ["title"],
search: "database",
sort: "desc",
},
},
});Related pages
Section titled “Related pages”Related pages
Section titled “Related pages”Aggregation, grouping, and summarizing: Use Prisma Client to aggregate, group by, count, and select distinct.CRUD: Learn how to perform create, read, update, and delete operationsExcluding fields: Learn how to exclude fields from Prisma Client results with the omit option.Filtering and sorting: Learn how to filter Prisma Client queries with where and sort results with orderBy.Pagination: Learn how to paginate Prisma Client query results with offset pagination and cursor-based pagination.