0

Please i can't get FULLTEXT search to work on planetscale via prisma. Vercel always returns this error: "Cannot find a fulltext index to use for the search, try adding a @@fulltext([Fields...]) to your schema". I have already added and enabled The previewFeatures included in the application's Prisma file.

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

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

model Coast {
  proid          Int       @id @default(autoincrement())
  serialid       String
  displayid      String    @unique @default(uuid())
  zootype        String  
  zoate          String   
  zoty           String
  zoea           String
  zoal           String
  bone           String
  zoice          Decimal   @default(0)
  postdate       DateTime  @default(now())
  authorId       String?
  author         Buser?     @relation(fields: [authorId], references: [userID], onDelete: Cascade)
  postsimage     Postimg[]

  @@index([authorId])
  
  @@fulltext([zoate])
  @@fulltext([zoty])
  @@fulltext([bone])
  @@fulltext([zoea])
  @@fulltext([zootype])
  @@fulltext([zoal])
}

It looks to me like the problem is my Prisma application isn't creating the necessary FULLTEXT indexes when I run my migrations or db push, which is why tried a workaround of creating them manually on planetscale. Why this isn't happening I don't know, but based on the other reports in the discussion at https://github.com/prisma/prisma/discussions/11249 it looks like a Prisma bug. can anyone help?

Mc-adams
  • 29
  • 7
  • Do you get this error when you deploy your app? Is it working locally? – Nurul Sundarani Mar 20 '23 at 19:00
  • Yes, it is working locally and I have also fixed it in production and it is working fine now. i figured it out by adding @@fulltext([zootype,zoal,zoate,zoty]) because I was searching multiple fields and it worked. Credits to this helpful article at https://www.prisma.io/docs/concepts/components/prisma-client/full-text-search – Mc-adams Mar 21 '23 at 22:42

0 Answers0