I was trying out the new `Order by relevance in fu...
# orm-help
g
I was trying out the new
Order by relevance in full text search (PostgreSQL)
, and maybe im misunderstanding it, but im having an issue:
Copy code
const cards = await prisma.card.findMany({
    include: {
        character: true,
        creator: true
    },
    where: {
        character: {
            name: {
                contains: value,
                mode: 'insensitive'
            }
        },
        user_id: member.user.id
    },
    take: 10,
    // Here <-------------
    orderBy: {
        _relevance: {
            fields: [{ character: ['name'] }],
            search: value,
            sort: 'desc'
        }
    }
});
this definitely fails, because i just made up/guessed the syntax for
fields
, but the only 2 fields i can input are the unique fields, which are just the IDs that arent useful at all for search/ordering/etc. it only lets me put
user_id
and
creator_id
as the fields, but i would expect i can sort by the
character.name
which is the important string that the user is searching for.
r
@Garrick Chippendale 👋 I don’t think you can add a relation’s field there. You can only use the fields of the model you’re querying for.
g
@Ryan true, and thats understandable. do you think as a feature request it would be considered? i just was wanting to try it out, im not sure if it would even give me better ordering, so i dont want to create extra for the prisma team by requesting something not very important like this 🙂 thanks
r
Sure, you can create a feature request here 🙂