Hello Vincenzo,

I'm not getting your point:

> if I add an fq parameter the scale function still continues to work only
on
the q param .

well, but the function actually refers to q param:
scale(sum(price,query($q)), 0, 1).

What's your expectation values of  query($q) with  "q":"popularity:(1 OR
7)"? I suggest to check it with fl=score


On Tue, May 31, 2022 at 2:05 PM Vincenzo D'Amore <v.dam...@gmail.com> wrote:

> Hi all,
>
> playing with the solr scale function I found a few corner cases where I
> need to scale only the results set.
>
> I found a workaround that works but it does not seem to be viable, because
> if I add an fq parameter the scale function still continues to work only on
> the q param .
>
> For example with q=popularity:(1 OR 7):
>
> http://localhost:8983/solr/techproducts/select?q=popularity:(1 OR
> 7)&rows=100&fl=price,scale(sum(price,query($q)), 0, 1)
>
> {
>   "responseHeader":{
>     "status":0,
>     "QTime":1,
>     "params":{
>       "q":"popularity:(1 OR 7)",
>       "fl":"price,scale(sum(price,query($q)), 0, 1)",
>       "rows":"100"}},
>   "response":{"numFound":6,"start":0,"numFoundExact":true,"docs":[
>       {
>         "price":74.99,
>         "scale(sum(price,query($q)), 0, 1)":0.099437736},
>       {
>         "price":19.95,
>         "scale(sum(price,query($q)), 0, 1)":0.013234352},
>       {
>         "price":11.5,
>         "scale(sum(price,query($q)), 0, 1)":0.0},
>       {
>         "price":329.95,
>         "scale(sum(price,query($q)), 0, 1)":0.49875492},
>       {
>         "price":479.95,
>         "scale(sum(price,query($q)), 0, 1)":0.7336842},
>       {
>         "price":649.99,
>         "scale(sum(price,query($q)), 0, 1)":1.0}]
>   }}
>
> but moving the filter in fq:
>
>
> http://localhost:8983/solr/techproducts/select?q=*:*&fq=popularity:(1%20OR%207)&rows=100&fl=price,scale(sum(price,query($q)),%200,%201)
>
> {
>   "responseHeader":{
>     "status":0,
>     "QTime":8,
>     "params":{
>       "q":"*:*",
>       "fl":"price,scale(sum(price,query($q)), 0, 1)",
>       "fq":"popularity:(1 OR 7)",
>       "rows":"100"}},
>   "response":{"numFound":6,"start":0,"numFoundExact":true,"docs":[
>       {
>         "price":74.99,
>         "scale(sum(price,query($q)), 0, 1)":0.034101862},
>       {
>         "price":19.95,
>         "scale(sum(price,query($q)), 0, 1)":0.009072306},
>       {
>         "price":11.5,
>         "scale(sum(price,query($q)), 0, 1)":0.0052296496},
>       {
>         "price":329.95,
>         "scale(sum(price,query($q)), 0, 1)":0.15004548},
>       {
>         "price":479.95,
>         "scale(sum(price,query($q)), 0, 1)":0.2182583},
>       {
>         "price":649.99,
>         "scale(sum(price,query($q)), 0, 1)":0.29558435}]
>   }}
>
>
> On the other hand, I was thinking of implementing a custom scale function
> that by default works only on the current result set and not on the entire
> collection.
>
> Any suggestions on how to solve this problem?
>
> Best regards,
> Vincenzo
>
>
> --
> Vincenzo D'Amore
>


-- 
Sincerely yours
Mikhail Khludnev

Reply via email to