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 Peter Sturge <pe...@gmail.com> on 2011/03/09 23:06:33 UTC

Math-generated fields during query

Hi,

I was wondering if it is possible during a query to create a returned
field 'on the fly' (like function query, but for concrete values, not
score).

For example, if I input this query:
   q=_val_:"product(15,3)"&fl=*,score

For every returned document, I get score = 45.

If I change it slightly to add *:* like this:
   q=*:* _val_:"product(15,3)"&fl=*,score

I get score = 32.526913.

If I try my use case of _val_:"product(qty_ordered,unit_price)", I get
varying scores depending on...well depending on something.

I understand this is doing relevance scoring, but it doesn't seem to
tally with the FunctionQuery Wiki
[example at the bottom of the page]:

   q=boxname:findbox+_val_:"product(product(x,y),z)"&fl=*,score
...where score will contain the resultant volume.

Is there a trick to getting not a score, but the actual value of
quantity*price (e.g. product(5,2.21) == 11.05)?

Many thanks

Re: Math-generated fields during query

Posted by Markus Jelsma <ma...@openindex.io>.
There is a ticket:
https://issues.apache.org/jira/browse/SOLR-1298


On Thursday 10 March 2011 15:46:55 Peter Sturge wrote:
> Hi Markus,
> 
> Thanks for your input. Hmmm, so it sounds like all those nice math
> functions operate only on the Lucene tf/idf score.
> In the link you gave, there is mention of 'Returning distances (and
> any arbitrary function query value) is currently under development.'
> (the workaround mentioned doesn't work for product()).
> Do you know if there is a JIRA ticket for this (I couldn't ssee one in
> a search of JIRA)?
> 
> Thanks again!
> Peter
> 
> 
> On Thu, Mar 10, 2011 at 1:19 PM, Markus Jelsma
> 
> <ma...@openindex.io> wrote:
> > Not at the moment if i'm not mistaken. The same issue is with Solr 3.1
> > where relative distances are not being returned as field value when
> > doing spatial filtering. To retrieve the value one must use the score as
> > the some pseudo field.
> > 
> > http://wiki.apache.org/solr/SpatialSearch#Returning_the_distance
> > 
> > On Wednesday 09 March 2011 23:06:33 Peter Sturge wrote:
> >> Hi,
> >> 
> >> I was wondering if it is possible during a query to create a returned
> >> field 'on the fly' (like function query, but for concrete values, not
> >> score).
> >> 
> >> For example, if I input this query:
> >>    q=_val_:"product(15,3)"&fl=*,score
> >> 
> >> For every returned document, I get score = 45.
> >> 
> >> If I change it slightly to add *:* like this:
> >>    q=*:* _val_:"product(15,3)"&fl=*,score
> >> 
> >> I get score = 32.526913.
> >> 
> >> If I try my use case of _val_:"product(qty_ordered,unit_price)", I get
> >> varying scores depending on...well depending on something.
> >> 
> >> I understand this is doing relevance scoring, but it doesn't seem to
> >> tally with the FunctionQuery Wiki
> >> [example at the bottom of the page]:
> >> 
> >>    q=boxname:findbox+_val_:"product(product(x,y),z)"&fl=*,score
> >> ...where score will contain the resultant volume.
> >> 
> >> Is there a trick to getting not a score, but the actual value of
> >> quantity*price (e.g. product(5,2.21) == 11.05)?
> >> 
> >> Many thanks
> > 
> > --
> > Markus Jelsma - CTO - Openindex
> > http://www.linkedin.com/in/markus17
> > 050-8536620 / 06-50258350

-- 
Markus Jelsma - CTO - Openindex
http://www.linkedin.com/in/markus17
050-8536620 / 06-50258350

Re: Math-generated fields during query

Posted by Markus Jelsma <ma...@openindex.io>.
Not at the moment if i'm not mistaken. The same issue is with Solr 3.1 where 
relative distances are not being returned as field value when doing spatial 
filtering. To retrieve the value one must use the score as the some pseudo 
field.

http://wiki.apache.org/solr/SpatialSearch#Returning_the_distance

On Wednesday 09 March 2011 23:06:33 Peter Sturge wrote:
> Hi,
> 
> I was wondering if it is possible during a query to create a returned
> field 'on the fly' (like function query, but for concrete values, not
> score).
> 
> For example, if I input this query:
>    q=_val_:"product(15,3)"&fl=*,score
> 
> For every returned document, I get score = 45.
> 
> If I change it slightly to add *:* like this:
>    q=*:* _val_:"product(15,3)"&fl=*,score
> 
> I get score = 32.526913.
> 
> If I try my use case of _val_:"product(qty_ordered,unit_price)", I get
> varying scores depending on...well depending on something.
> 
> I understand this is doing relevance scoring, but it doesn't seem to
> tally with the FunctionQuery Wiki
> [example at the bottom of the page]:
> 
>    q=boxname:findbox+_val_:"product(product(x,y),z)"&fl=*,score
> ...where score will contain the resultant volume.
> 
> Is there a trick to getting not a score, but the actual value of
> quantity*price (e.g. product(5,2.21) == 11.05)?
> 
> Many thanks

-- 
Markus Jelsma - CTO - Openindex
http://www.linkedin.com/in/markus17
050-8536620 / 06-50258350

Re: Math-generated fields during query

Posted by Peter Sturge <pe...@gmail.com>.
Hi Dan,

Yes, you're right - in fact that was precisely what I was thinking of
doing! Also looking at SOLR-1298 & SOLR-1566 - which would be good for
applying functions generically rather than on a per-use-case basis.

Thanks!
Peter


On Thu, Mar 10, 2011 at 3:58 PM, dan sutton <da...@gmail.com> wrote:
> As a workaround can you not have a search component run after the
> querycomponent, and have the qty_ordered,unit_price as stored fields
> and returned with the fl parameter and have your custom component do
> the calc, unless you need to sort by this value too?
>
> Dan
>
> On Wed, Mar 9, 2011 at 10:06 PM, Peter Sturge <pe...@gmail.com> wrote:
>> Hi,
>>
>> I was wondering if it is possible during a query to create a returned
>> field 'on the fly' (like function query, but for concrete values, not
>> score).
>>
>> For example, if I input this query:
>>   q=_val_:"product(15,3)"&fl=*,score
>>
>> For every returned document, I get score = 45.
>>
>> If I change it slightly to add *:* like this:
>>   q=*:* _val_:"product(15,3)"&fl=*,score
>>
>> I get score = 32.526913.
>>
>> If I try my use case of _val_:"product(qty_ordered,unit_price)", I get
>> varying scores depending on...well depending on something.
>>
>> I understand this is doing relevance scoring, but it doesn't seem to
>> tally with the FunctionQuery Wiki
>> [example at the bottom of the page]:
>>
>>   q=boxname:findbox+_val_:"product(product(x,y),z)"&fl=*,score
>> ...where score will contain the resultant volume.
>>
>> Is there a trick to getting not a score, but the actual value of
>> quantity*price (e.g. product(5,2.21) == 11.05)?
>>
>> Many thanks
>>
>

Re: Math-generated fields during query

Posted by dan sutton <da...@gmail.com>.
As a workaround can you not have a search component run after the
querycomponent, and have the qty_ordered,unit_price as stored fields
and returned with the fl parameter and have your custom component do
the calc, unless you need to sort by this value too?

Dan

On Wed, Mar 9, 2011 at 10:06 PM, Peter Sturge <pe...@gmail.com> wrote:
> Hi,
>
> I was wondering if it is possible during a query to create a returned
> field 'on the fly' (like function query, but for concrete values, not
> score).
>
> For example, if I input this query:
>   q=_val_:"product(15,3)"&fl=*,score
>
> For every returned document, I get score = 45.
>
> If I change it slightly to add *:* like this:
>   q=*:* _val_:"product(15,3)"&fl=*,score
>
> I get score = 32.526913.
>
> If I try my use case of _val_:"product(qty_ordered,unit_price)", I get
> varying scores depending on...well depending on something.
>
> I understand this is doing relevance scoring, but it doesn't seem to
> tally with the FunctionQuery Wiki
> [example at the bottom of the page]:
>
>   q=boxname:findbox+_val_:"product(product(x,y),z)"&fl=*,score
> ...where score will contain the resultant volume.
>
> Is there a trick to getting not a score, but the actual value of
> quantity*price (e.g. product(5,2.21) == 11.05)?
>
> Many thanks
>