Aviroop Jana
Aviroop Jana

Reputation: 41

How can I implement Full text search by using Prisma + PostgreSQL ? (I'm using Supabase as the database)

This is my schema file:

generator client {
  provider = "prisma-client-js"
  previewFeatures = ["fullTextSearch","fullTextIndex"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Category {
  id            String @id @db.Uuid @default(dbgenerated("gen_random_uuid()"))
  name          String
  companions    Companion[]
}


model Companion {
  id            String @id @db.Uuid @default(dbgenerated("gen_random_uuid()"))
  userId        String
  userName      String
  src           String
  name          String @db.Text 
  description   String
  instruction   String @db.Text
  seed          String @db.Text

  createdAt     DateTime @default(dbgenerated("now()"))
  updatedAt     DateTime @updatedAt

  category      Category @relation(fields: [categoryId], references: [id])
  categoryId    String

  @@index([categoryId])
  @@fulltext([name])
}

Here I am unable to implement @@fulltext feature, showing:

Error parsing attribute "@@fulltext": Defining fulltext indexes is not supported with the current connector.

Please do let me know how I can do this as @@fulltext can be used with mySQL.

Upvotes: 4

Views: 6287

Answers (6)

Ay, using @@index() instead of @@fulltext.

Upvotes: 0

A-Makeyev
A-Makeyev

Reputation: 419

My solution was switching to https://tidbcloud.com/

Then change provider to mysql

datasource db {
  provider     = "mysql"
  url          = env("DATABASE_URL")
  relationMode = "prisma"
}

and inside .env add ?sslaccept=strict at the end of your DATABASE_URL

Upvotes: 0

Akash
Akash

Reputation: 1

https://www.prisma.io/docs/orm/prisma-client/queries/full-text-search#postgresql-1

Prisma Client does not currently support using indexes to speed up full text search in PostgreSQL.

There is an existing GitHub Issue for this.

So if you are migrating from MySql to PostgreSQL consider removing that line.

Upvotes: -1

Avi Cohen
Avi Cohen

Reputation: 3414

...Prisma Client supports full-text search for PostgreSQL databases in versions 2.30.0 and later, and MySQL databases in versions 3.8.0 and late...

https://www.prisma.io/docs/orm/prisma-client/queries/full-text-search

Upvotes: 1

Mustafa Özyurt
Mustafa Özyurt

Reputation: 39

Prisma Client does not currently support using indexes to speed up full text search on postgresSQL. You can install MySQL Community Edition and change your provider to MySQL easily.

There is a link I think it might be helpful to you: https://www.prisma.io/docs/concepts/components/prisma-client/full-text-search

Upvotes: 3

Anthony Fink
Anthony Fink

Reputation: 1

It's happening only with postgresSQL, if you change provider to mysql error gone.

Upvotes: -4

Related Questions