-
Notifications
You must be signed in to change notification settings - Fork 1.9k
KNN example #2352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KNN example #2352
Conversation
examples/search-knn.js
Outdated
// Add some sample data... | ||
// https://redis.io/commands/hset/ | ||
await Promise.all([ | ||
client.hSet('noderedis:vectors:1', { vector: [0.4, -0.325, 4.3] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to encode these vectors with Buffer
? How should that be done exactly?
Got it to work! Open to suggestions for cleaning it up. |
@curran thanks for contributing! I'll update it to use |
@curran review my changes? 🙏 |
Codecov ReportBase: 95.85% // Head: 95.85% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #2352 +/- ##
=======================================
Coverage 95.85% 95.85%
=======================================
Files 449 449
Lines 4224 4224
Branches 471 471
=======================================
Hits 4049 4049
Misses 107 107
Partials 68 68 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing! Thank you @leibale for the clean up, this looks fantastic.
]); | ||
await client.ft.create('idx:knn-example', { | ||
v: { | ||
type: SchemaFieldTypes.VECTOR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nice!!! This is exactly what I wanted to do but couldn't figure out the API for. Thank you.
"2", | ||
]); | ||
|
||
const results = await client.ft.search('idx:knn-example', '*=>[KNN 4 @v $BLOB AS dist]', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AMAZING! I could not for the life of me figure out how to formulate this with the ft.search
API. This is perfect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you
Hooray! |
Closes #2351