: Expected identifier at pos 29 str='{!frange l=sum(size1, product(size1,
: .10))}size1
: 
: pos 29 is the open parenthesis of product(). can i not use a function
: within a function? or is there something else i'm missing in the way i'm
: constructing this?

1) you're confusing the parser by trying to put whitespace inside of a 
local param (specifically the 'l' param) w/o quoting the param value .. it 
things that you want "sum(size1" to be the value of the "l" param, and 
then it doesn't know what to make of "product(size1" as a another local 
param that it can't make sense of.

2) if you remove the whitespace, or quote the param, that will solve that 
parsing error -- but it will lead to a new error from 
ValueSourceRangeFilter (ie: "frange") because the "l" param doesn't 
support arbitrary functions -- it needs to be a concrete number.

3) even if you could pass a function for the "l" param, conceptually what 
you are asking for doesn't really make much sense ... you are asking solr 
to only return documents where the value of the "size1" field is in a 
range between X and infinity, where X is defined as the sum of the value 
of the "size1" field plus 10% of the value of the "size1" field.

In other words: "give me all docs where S * 1.1 <= S"

Basically you are asking it to return all documents with a negative value 
in the "size1" field.


4) your original question was about filtering docs where the value of a 
field was inside a range of +/- X% of a specified value.  a range query 
where you computed the lower/upper bounds bsed on that percentage in the 
client is really the most straight forward way to do that.

the main reason to consider using frange for something like this is if you 
wnat to filter documents based on the reuslts of a function over multiple 
fields. (ie: "docs where the price field divided by the quantity_included 
field was within a client specified range")

adimitedly, you could do something like this...

fq={!frange u=0.10}div(abs(sub($target,size1)),$target)&target=345

...which would tell solr to find you all documents where the "size1" field 
was within 10% of the target value (345 in this case) -- ie: "310.5 <= 
size1 <= 379.5)

however it's important to realize that doing something like this is going 
to be less inefficient then just computing the lower/upper range 
bounds in the client -- because solr will be evaluating that function for 
every document in order to make the comparison.  (meanwhile you can 
compute the upper and lower bounds exactly once and just let solr do the 
comparisons)


-Hoss
http://www.lucidworks.com/

Reply via email to