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 maurizio1976 <ma...@gmail.com> on 2012/07/13 11:21:12 UTC
Computed fields - can I put a function in fl?
Hi,
I have 2 fields, one containing a string (product) and another containing a
boolean (show_product).
Is there a way of returning the product field with a value of null when the
show_product field is false?
I can make another field (product_computed) and index that with null where I
need but I would like to understand if there is a better approach like
putting a function query in the fl and make a computed field.
something like:
q=*:*&fq=&start=0&rows=10&fl=&qt=&wt=&explainOther=&hl.fl=/*product:(if(show_product:true,
product, "")*/
that obviously doesn't work.
thanks for any help
Maurizio
--
View this message in context: http://lucene.472066.n3.nabble.com/Computed-fields-can-I-put-a-function-in-fl-tp3994799.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Computed fields - can I put a function in fl?
Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Mon, Jul 16, 2012 at 4:43 AM, maurizio1976
<ma...@gmail.com> wrote:
> Yes,
> sorry Just a typo.
> I meant q=*:*&fq=&start=0&rows=10&qt=&wt=&explainOther=&fl=product:(if(show_product:true,
> product, "")
> thanks
Functions normally derive their values from the fieldCache... there
isn't currently a function to load stored fields (e.g. your "product"
field"), but it's not a bad idea (given this usecase).
Here's an example with the exampledocs that shows IN_STOCK_PRICE only
if the item is in stock, and otherwise shows 0.
This works because price is a single-valued indexed field that the
fieldCache works on.
http://localhost:8983/solr/query?
q=*:*
&fl=id, inStock, IN_STOCK_PRICE:if(inStock,price,0)
-Yonik
http://lucidimagination.com
Re: Computed fields - can I put a function in fl?
Posted by maurizio1976 <ma...@gmail.com>.
Yes,
sorry Just a typo.
I meant q=*:*&fq=&start=0&rows=10&qt=&wt=&explainOther=&fl=product:(if(show_product:true,
product, "")
thanks
On Sat, Jul 14, 2012 at 11:27 PM, Erick Erickson [via Lucene]
<ml...@n3.nabble.com> wrote:
> I think in 4.0 you can, but not 3.x as I remember. Your example has
> the fl as part
> of the highlight though, is that a typo?
>
> Best
> Erick
>
> On Fri, Jul 13, 2012 at 5:21 AM, maurizio1976
> <[hidden email]> wrote:
>
>> Hi,
>> I have 2 fields, one containing a string (product) and another containing
>> a
>> boolean (show_product).
>>
>> Is there a way of returning the product field with a value of null when
>> the
>> show_product field is false?
>>
>> I can make another field (product_computed) and index that with null where
>> I
>> need but I would like to understand if there is a better approach like
>> putting a function query in the fl and make a computed field.
>>
>> something like:
>>
>> q=*:*&fq=&start=0&rows=10&fl=&qt=&wt=&explainOther=&hl.fl=/*product:(if(show_product:true,
>> product, "")*/
>>
>> that obviously doesn't work.
>>
>> thanks for any help
>>
>> Maurizio
>>
>> --
>> View this message in context:
>> http://lucene.472066.n3.nabble.com/Computed-fields-can-I-put-a-function-in-fl-tp3994799.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://lucene.472066.n3.nabble.com/Computed-fields-can-I-put-a-function-in-fl-tp3994799p3995045.html
> To unsubscribe from Computed fields - can I put a function in fl?, click
> here.
> NAML
--
View this message in context: http://lucene.472066.n3.nabble.com/Computed-fields-can-I-put-a-function-in-fl-tp3994799p3995218.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Computed fields - can I put a function in fl?
Posted by Erick Erickson <er...@gmail.com>.
I think in 4.0 you can, but not 3.x as I remember. Your example has
the fl as part
of the highlight though, is that a typo?
Best
Erick
On Fri, Jul 13, 2012 at 5:21 AM, maurizio1976
<ma...@gmail.com> wrote:
> Hi,
> I have 2 fields, one containing a string (product) and another containing a
> boolean (show_product).
>
> Is there a way of returning the product field with a value of null when the
> show_product field is false?
>
> I can make another field (product_computed) and index that with null where I
> need but I would like to understand if there is a better approach like
> putting a function query in the fl and make a computed field.
>
> something like:
> q=*:*&fq=&start=0&rows=10&fl=&qt=&wt=&explainOther=&hl.fl=/*product:(if(show_product:true,
> product, "")*/
>
> that obviously doesn't work.
>
> thanks for any help
>
> Maurizio
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Computed-fields-can-I-put-a-function-in-fl-tp3994799.html
> Sent from the Solr - User mailing list archive at Nabble.com.