redis / redis-vl-python

Redis Vector Library (RedisVL) interfaces with Redis' vector database for realtime semantic search, RAG, and recommendation systems.
https://www.redisvl.com/
MIT License
173 stars 25 forks source link

Simplify the chaining of queries #167

Open pierrelambert opened 1 week ago

pierrelambert commented 1 week ago

In some cases we need to perform multiple queries to be able to extract the document we need.

First case: Query1 without return fields: returns the id of keys (with with vector_distance or other) => The SubsetA

=> If I need to perform a second query, Query2 taking SubsetA as input to perform a new VectorQuery limited to this subset: Search query language permits me to use INKEYS keyword to limit the scope of a query to a subset of keys

Second case: Query1 without return an indexed id field (with with vector_distance or other) => The SubsetB => If I need to perform a second query, Query2 taking SubsetB as input to perform a new VectorQuery limited to this subset: Search query language permits me to use a TAG filter on the id field to limit the scope of a query to a subset of id

in both case we may imagine N steps.

It would be nice to provide helper method , enrich query object to be able to chain the Queries.

tylerhutcherson commented 1 week ago

I imagine this as some kind of pipeline like operation. What would be the right kind of utility here? It seems like depending on the specific use case, the number of iterations and the steps required would have to be heavily customized. For example, how do you control an arbitrary stopping condition?

However, if we can extend to support some lower level functionality that may help build this, I'm open to that for sure. The ability to use TAG fields like this should be supported today through a VectorQuery --> use results to build a Tag filter expression --> another VectorQuery w/ filter.