You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Viktors Belovs <vi...@biologis.com> on 2019/08/16 08:29:54 UTC

using let() with other streaming expressions

Dear Solr Comunity,

Recently I've been working with the 'let()' expression.
And I got in a sort of trouble, when I was trying combining it with the different streaming expressions,
as well as trying to re-assign variables.

As an example:
let(
  a=search(techproducts, q="cat:electronics", fl="id, manu, price", sort="id asc"),
  b=search(techproducts, q="cat:electronics", fl="id, popularity, _version_", sort="id asc"),
  c=innerJoin(a, b, on=id)
)

In case with re-assigning the variables:
let(
  a=search(techproducts, q="cat:electronics", fl="id, manu, price", sort="id asc"),
  b=a,
  c=innerJoin(a, b, on=id)
)

According to documentation (Solr v8.1 the version I use) its possible to store any kind values with 'let()'
function but it seems the usage of such a function is strictly limited for specific mathematical operations.

I was wondering if there is possible way to reduce the verbosity and (potentially)
increase the efficiency of the streaming expression's performance, while dealing and constructing complex
combinations of different streaming expressions.

I assume the 'let()' doesn't suited for such purposes, but perhaps there is an alternative way to do such a thing.

Regards,
Viktors

Re: using let() with other streaming expressions

Posted by Joel Bernstein <jo...@gmail.com>.
Yes, the examples you show will fail because the "let" expression reads
streams into an in-memory List. All the Streaming Expressions expect a
TupleStream to be passed in rather that a List.

There is an undocumented function that turns a List of tuples back into a
Stream. The function is called "stream".

Here is the syntax:

let(
  a=search(techproducts, q="cat:electronics", fl="id, manu, price",
sort="id asc"),
  b=search(techproducts, q="cat:electronics", fl="id, popularity,
_version_", sort="id asc"),
  c=innerJoin(stream(a),stream(b), on=id)
)




Joel Bernstein
http://joelsolr.blogspot.com/


On Fri, Aug 16, 2019 at 4:30 AM Viktors Belovs <vi...@biologis.com>
wrote:

> Dear Solr Comunity,
>
> Recently I've been working with the 'let()' expression.
> And I got in a sort of trouble, when I was trying combining it with the
> different streaming expressions,
> as well as trying to re-assign variables.
>
> As an example:
> let(
>   a=search(techproducts, q="cat:electronics", fl="id, manu, price",
> sort="id asc"),
>   b=search(techproducts, q="cat:electronics", fl="id, popularity,
> _version_", sort="id asc"),
>   c=innerJoin(a, b, on=id)
> )
>
> In case with re-assigning the variables:
> let(
>   a=search(techproducts, q="cat:electronics", fl="id, manu, price",
> sort="id asc"),
>   b=a,
>   c=innerJoin(a, b, on=id)
> )
>
> According to documentation (Solr v8.1 the version I use) its possible to
> store any kind values with 'let()'
> function but it seems the usage of such a function is strictly limited for
> specific mathematical operations.
>
> I was wondering if there is possible way to reduce the verbosity and
> (potentially)
> increase the efficiency of the streaming expression's performance, while
> dealing and constructing complex
> combinations of different streaming expressions.
>
> I assume the 'let()' doesn't suited for such purposes, but perhaps there
> is an alternative way to do such a thing.
>
> Regards,
> Viktors