I'm planning to retrieve some vectors according to some queries, combine
them by doing some vector math, then use the resulting vector as input for
a KNN query. Considering the films dataset as an example, imagine that I
could have a collection of users, storing the IDs of the movies that were
watched. Then I could retrieve the list of IDs a specific user watched,
make a query to retrieve the vectors of these movies, calculate an "average
vector", then use this resulting vector to make a KNN query to retrieve the
most similar movies. Essentially this would be a recommendation of movies
using a single Streaming Expression instead of doing several external
queries and vector math externally to Solr.

I do have other questions regarding other parts of this use case, but I
thought it would be better to separate them in different emails pinpointing
specific questions of the process (I'm planning to write a second e-mail
soon).

For this e-mail and question specifically I was wondering whether it would
be possible to use an array variable as input for a KNN query, regardless
of how the vector was created/calculated. Because if not even this is
possible, the rest of the process becomes impossible.

Best,

--
Gabriel Magno


Em qua., 18 de jan. de 2023 às 10:18, Alessandro Benedetti <
benedetti.ale...@gmail.com> escreveu:

> Hi, during the implementation work so far, streaming expressions were not
> taken into account at all.
> If it works, it has not been tested.
>
> Can you elaborate a little more your requirements and idea?
>
> Cheers
>
> On Wed, 18 Jan 2023, 13:51 Gabriel Magno, <gabrielmag...@gmail.com> wrote:
>
> > Hi
> >
> > I'm trying to use streaming expressions to make some queries using the
> > Dense Vectors and KNN queries introduced in Solr 9.
> >
> > For instance, as per Dense Vector Search documentation, I could do a
> query
> > like this:
> >
> > &q={!knn f=film_vector topK=10}[1.0, 2.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0,
> > 10.0]
> >
> > I was wondering rather it is possible to do exactly this same query, but
> > using Streaming Expressions, and the array/vector coming from a variable.
> > Imagine that the target vector variable would come from a more complex
> > calculation, but to simplify my example I define it as hard-coded in the
> > expression. Something like this:
> >
> > let(
> >     target_vector=array(1.0, 2.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0)
> >     resulting_documents=search(films, q="{!knn f=film_vector topK=10}$
> > target_vector")
> > )
> >
> > The above expression does not work. I also tried inputting the
> > "target_vector" variable without the ampersand (&), but it does not work
> > either.
> >
> > In summary: is it possible to use streaming variables inside query
> strings.
> > More specifically, is it possible to use streaming arrays as target Dense
> > Vectors in KNN queries?
> >
> > Best,
> >
> > --
> > Gabriel Magno
> >
>

Reply via email to