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 SandroZbinden <zb...@imagic.ch> on 2013/10/04 16:21:38 UTC

Use function return value for range queries

Is there a way to use the function return value for a range query

For example: I have two price fields pricea and priceb and now i want to get
the values where the sum of the pricea and priceb is between  [0 TO 5]

Something like *select?q={!func}sum(pricea,priceb):[0 TO 5]*

I can't calculate this at index time.

Bests Sandro





--
View this message in context: http://lucene.472066.n3.nabble.com/Use-function-return-value-for-range-queries-tp4093499.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: AW: Use function return value for range queries

Posted by SandroZbinden <zb...@imagic.ch>.
Thank you very much Jack.

I will take a look at this.

Bests Sandro



--
View this message in context: http://lucene.472066.n3.nabble.com/Use-function-return-value-for-range-queries-tp4093499p4093579.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: AW: Use function return value for range queries

Posted by Jack Krupansky <ja...@basetechnology.com>.
No plan that I know of, but there is a new Lucene "expression module", so 
maybe it is not so farfetched. Its performance might not be so great, but if 
you need the flexibility it might be worth it.

-- Jack Krupansky

-----Original Message----- 
From: Sandro Zbinden
Sent: Friday, October 04, 2013 10:53 AM
To: solr-user@lucene.apache.org
Subject: AW: Use function return value for range queries

Thanks for the quick answer.  I thought that :-)

Is there any plan add such a functionality in the future. Or is it 
completely against the concept.

Bests Sandro


-----Ursprüngliche Nachricht-----
Von: Jack Krupansky [mailto:jack@basetechnology.com]
Gesendet: Freitag, 4. Oktober 2013 16:41
An: solr-user@lucene.apache.org
Betreff: Re: Use function return value for range queries

I think the best you can do is compute sum(pricea,priceb) at index time as a 
third field, say priceSum, and then you can do a range query on that 
priceSum field.

It would be nice to be able to have a query that evaluates arbitrary 
expressions combining field values, but there is no such feature in Lucene 
at this time. FunctionQuery modifies the document score, but doesn't affect 
which documents are selected.

Function queries can be used to modify document scores and to return values, 
but not in the query itself to select documents.

-- Jack Krupansky

-----Original Message-----
From: SandroZbinden
Sent: Friday, October 04, 2013 10:21 AM
To: solr-user@lucene.apache.org
Subject: Use function return value for range queries

Is there a way to use the function return value for a range query

For example: I have two price fields pricea and priceb and now i want to get 
the values where the sum of the pricea and priceb is between  [0 TO 5]

Something like *select?q={!func}sum(pricea,priceb):[0 TO 5]*

I can't calculate this at index time.

Bests Sandro





--
View this message in context:
http://lucene.472066.n3.nabble.com/Use-function-return-value-for-range-queries-tp4093499.html
Sent from the Solr - User mailing list archive at Nabble.com. 


AW: Use function return value for range queries

Posted by Sandro Zbinden <zb...@imagic.ch>.
Thanks for the quick answer.  I thought that :-)

Is there any plan add such a functionality in the future. Or is it completely against the concept.

Bests Sandro


-----Ursprüngliche Nachricht-----
Von: Jack Krupansky [mailto:jack@basetechnology.com] 
Gesendet: Freitag, 4. Oktober 2013 16:41
An: solr-user@lucene.apache.org
Betreff: Re: Use function return value for range queries

I think the best you can do is compute sum(pricea,priceb) at index time as a third field, say priceSum, and then you can do a range query on that priceSum field.

It would be nice to be able to have a query that evaluates arbitrary expressions combining field values, but there is no such feature in Lucene at this time. FunctionQuery modifies the document score, but doesn't affect which documents are selected.

Function queries can be used to modify document scores and to return values, but not in the query itself to select documents.

-- Jack Krupansky

-----Original Message-----
From: SandroZbinden
Sent: Friday, October 04, 2013 10:21 AM
To: solr-user@lucene.apache.org
Subject: Use function return value for range queries

Is there a way to use the function return value for a range query

For example: I have two price fields pricea and priceb and now i want to get the values where the sum of the pricea and priceb is between  [0 TO 5]

Something like *select?q={!func}sum(pricea,priceb):[0 TO 5]*

I can't calculate this at index time.

Bests Sandro





--
View this message in context: 
http://lucene.472066.n3.nabble.com/Use-function-return-value-for-range-queries-tp4093499.html
Sent from the Solr - User mailing list archive at Nabble.com. 


Re: Use function return value for range queries

Posted by Jack Krupansky <ja...@basetechnology.com>.
I think the best you can do is compute sum(pricea,priceb) at index time as a 
third field, say priceSum, and then you can do a range query on that 
priceSum field.

It would be nice to be able to have a query that evaluates arbitrary 
expressions combining field values, but there is no such feature in Lucene 
at this time. FunctionQuery modifies the document score, but doesn't affect 
which documents are selected.

Function queries can be used to modify document scores and to return values, 
but not in the query itself to select documents.

-- Jack Krupansky

-----Original Message----- 
From: SandroZbinden
Sent: Friday, October 04, 2013 10:21 AM
To: solr-user@lucene.apache.org
Subject: Use function return value for range queries

Is there a way to use the function return value for a range query

For example: I have two price fields pricea and priceb and now i want to get
the values where the sum of the pricea and priceb is between  [0 TO 5]

Something like *select?q={!func}sum(pricea,priceb):[0 TO 5]*

I can't calculate this at index time.

Bests Sandro





--
View this message in context: 
http://lucene.472066.n3.nabble.com/Use-function-return-value-for-range-queries-tp4093499.html
Sent from the Solr - User mailing list archive at Nabble.com. 


Re: Use function return value for range queries

Posted by Yonik Seeley <yo...@lucidworks.com>.
"frange" (function range) is what you are looking for.

http://yonik.com/posts/ranges-over-functions-in-solr-1-4/

-Yonik
http://lucidworks.com


On Fri, Oct 4, 2013 at 10:21 AM, SandroZbinden <zb...@imagic.ch> wrote:
> Is there a way to use the function return value for a range query
>
> For example: I have two price fields pricea and priceb and now i want to get
> the values where the sum of the pricea and priceb is between  [0 TO 5]
>
> Something like *select?q={!func}sum(pricea,priceb):[0 TO 5]*
>
> I can't calculate this at index time.
>
> Bests Sandro
>
>
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Use-function-return-value-for-range-queries-tp4093499.html
> Sent from the Solr - User mailing list archive at Nabble.com.