Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Prisma · Const

search

Prisma Client’s search filter performs database-native full-text search on String fields. It supports MySQL and PostgreSQL, with PostgreSQL requiring the fullTextSearchPostgres preview feature.

How it works

The search filter performs full-text search against a String field through the database’s native search support. In Prisma ORM v7, MySQL supports it directly, while PostgreSQL requires the fullTextSearchPostgres preview feature before the generated client exposes the filter.

Syntax

{ where: { <stringField>: { search: <query> } } }

Parameters

NameTypeDescription
searchstringA full-text search expression, such as cat, cat | dog, or cat & dog.

Returns

A Prisma Client query result containing records whose searched String field matches the full-text expression.

Key points

  • The search filter is available for MySQL and PostgreSQL, with PostgreSQL requiring its preview feature.
  • Regenerating Prisma Client adds the search filter to generated types for eligible String fields.
  • Prisma delegates full-text matching to the database rather than implementing text scanning in application code.

Common mistakes

  • MySQL searched columns need a full-text index in the Prisma schema.

Example: Search a string field

const result = await prisma.post.findMany({
  where: {
    title: {
      search: "cat | dog",
    },
  },
});

Searches post titles for either “cat” or “dog” with Prisma Client.

When to use it

Keyword search

A blog or knowledge base needs to locate records containing one or more terms in a text column.

Database-native filtering

A MySQL application needs native text matching rather than loading rows and filtering them in application code.

Preview PostgreSQL search

A PostgreSQL application wants Prisma-generated types for full-text search during preview adoption.

Interview questions

QHow do you perform full-text search with Prisma Client?

Use the search property inside a String field’s filter, for example title: { search: "cat | dog" }. Prisma translates the operation to the database’s native full-text search support.

Follow-up: How would PostgreSQL support be enabled? Add fullTextSearchPostgres to the schema’s preview features, then regenerate Prisma Client.

QHow can a search expression match either or both terms?

The search expression supports operators such as | for alternatives and & for terms that must both occur. The result is obtained through a normal Prisma Client query such as findMany().

Follow-up: What must be configured for MySQL? Add a @@fulltext index for each searched column.

QDoes full-text search work identically on PostgreSQL and MySQL?

PostgreSQL support is preview-only in the current documentation, so the fullTextSearchPostgres feature flag must be enabled before using the generated search field. MySQL support is documented without that PostgreSQL preview requirement.

Follow-up: Why does the database index matter? Native full-text search can use the declared index for efficient lookup.

  • Prisma Client
  • fullTextSearchPostgres
  • @@fulltext
  • findMany()
  • String

Source: Full-text search (Prisma ORM v7) | Prisma Documentation. Checked 2026-10-16.