What would be the best way to implement a searchba...
# orm-help
h
What would be the best way to implement a searchbar where I want users to be able to search by any field in all objects that are associated with them in a db?
👀 2
✅ 1
r
Hi @Harris Rothaermel 👋 You might want to take a look at Full-text search documentation in order to add search functionality to your application.
h
@Raphael Etim I took a look at it, but it seems to only apply to a specific field. Is it possible to apply it to all fields within an object, or group of objects?
My usecase is I want to create a searchbar where users can enter a name, email, or other information for a contact, and be able to put it up directly.
r
At the moment, we support full text search for text within a database column. However, we are making improvements to full text search and you could help us by filling this survey and adding your specific usecase.
h
@Raphael Etim went ahead and filled it out!
In the meantime I’ll use multiple full text search queries on individual columns to achieve the same effect
r
Thank you for your time in filling out the survey and i'm glad you could find a workaround for your use case.
h
@Raphael Etim are you familiar with the full text search feature? I’ve followed the guide and have a support db (postgres) but can’t seem to get it to work
Copy code
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["fullTextSearch"]
}

const leadsByName = await prisma.lead.findMany({
    where: {
      userId: user.id,
      name: {
        search: query,
      },
    },
  });
Oh wait, I’ve figured out the issue. It only seems to work on full words
🙌 1
Is that the case? If so, I’m not sure I’ll be able to use it for my autocompleting searchbar functionality
oh wait, github copilot saved me
this seems to work
v
Thank you for sharing how you solved this issue! 🙌
This is super helpful!