-
Notifications
You must be signed in to change notification settings - Fork 61
Implement interface for unified hybrid search in Redis 8.4.0+ #447
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
base: main
Are you sure you want to change the base?
Conversation
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.
You may have forgotten to export HybridQuery from redisvl.query.hybrid in the redisvl.query __init__.py
from redisvl.query.hybrid import HybridQuery # this works
from redisvl.query import HybridQuery # this will fail
Basically because there are now two different HybridQuery classes
- redisvl.query.aggregate.HybridQuery (old wrapper around AggregateHybridQuery)
- redisvl.query.hybrid.HybridQuery (new one)
This might cause some confusion and we might have to either choose a different name or find a better solution and deprecate the older one. Might change the name of the older class
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 great overall!
Just need to verify how we need to handle the deprecated HybridQuery class
Don't forget to update the api/sphinx documentation and add a guide in ai-resources
This PR adds an interface for using the new
FT.HYBRIDsearch operation introduced in Redis Open Source 8.4.0.Changes
redisvl.query.hybridThis new module defines query constructors for working with the new hybrid search operation. Attempting to import this module without having
redis-py>=7.1.0will raise anImportError. It defines aHybridQueryobject which can be used to define a hybrid search operation in a format largely similar to whatAggregateHybridSearchprovides.Under the hood,
redis-pyexpects three separate configuration objects to run hybrid search - one for the text+vector searches, one for the score combination, and one for post-processing of the results (e.g. aggregations, loading, limiting, etc.). TheHybridSearchclass manages the definition of all three.SearchIndex method
For
redis-py>=7.1.0, theSearchIndexandAsyncSearchIndexclasses define ahybrid_searchmethod that takes aHybridQueryinstance as an argument. Forredis-py<7.1.0the method is not defined. The method returns a list of retrieved dictionaries.Additional Changes
AggregateHybridQueryredis-py 7.0.0introduced a change to the type ofQuery._fields, changing it from a tuple to a list - a test had to be updated to differentiate the expectation based on the redis-py version.