Skip to main content
Prisma Documentation Docs
current

Search documentation

Type to search this documentation.

On this pageOverview

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.

Add the preview flag to your generator and re-generate Prisma Client:

schema.prisma
generator client {
  provider        = "prisma-client"
  output          = "./generated"
  previewFeatures = ["fullTextSearchPostgres"]
}
bun
bunx prisma generate
pnpm
pnpm prisma generate
yarn
yarn prisma generate
npm
npx prisma generate
TypeScript
const posts = await prisma.post.findMany({
  where: {
    body: {
      search: "cat | dog",
    },
  },
});

Prisma Client also supports relevance-based ordering on supported databases:

TypeScript
const posts = await prisma.post.findMany({
  orderBy: {
    _relevance: {
      fields: ["title"],
      search: "database",
      sort: "desc",
    },
  },
});
  • 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 operations
  • Excluding 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.
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu