I have an app using Langchain.js in Express, Prisma ORM, Postgres and PGVector. I have the below function that performs a similarity search on the DB based on an array of answers that comes through:
const retriever = pgvectorStore.asRetriever({
verbose: true,
k: 25,
searchType: "similarity",
filter: {
iron_catergory: answers[4],
varient_price: { $lt: answers[1] },
dexterity: answers[0],
shaft_flex: answers[3],
length: answers[5],
},
});
Below is the Prisma schema:
model golfClubs4Cash_irons_online {
id String @id
varient_sku String
title String
varient_price Int
price_range String
url String
image String
brand String
club_model String
set_makeup String
iron_catergory String
dexterity String
condition String
shaft_flex String
shaft_material String
number_of_clubs String
shaft_model String
location String
length_to_standard String
length_inches String
length String
store_id Int
}
The issue is with the varient_price filter. yes, I know it’s spelling of varient is wrong but it is consistently wrong across the code. I am trying to filter all varient_price less than answers[1]. For some reason I cannot figure out is this filter is not working. I think I’m using the right syntax and when I run the program the data comes through as below but returns an empty array:
filter: {
iron_catergory: 'Midsize Players',
varient_price: { '$lt': 750 },
dexterity: 'Right-Handed',
shaft_flex: 'Stiff',
length: 'Standard'
}
If I remove the varient_price filter I get values returned. What am I doing wrong?