The one trick that can be done with 3.x is something like this (try this URL on 
the example app with the example data indexed):

  
http://localhost:8983/solr/browse?v.template.doc=%23set%28$cents=$doc.getFieldValue%28%27price%27%29*100%29%20$cents%20cents

Un-urlencoded, this is saying to make the doc template (the one rendered for 
each hit) be this:

   #set($cents=$doc.getFieldValue('price')*100) $cents cents

You could change conf/velocity/doc.vm to be that too rather than doing it on 
the URL.

This trick doesn't help you with any response writer but the Velocity one, but 
you could cobble together a Velocity template that output CSV if that is your 
only need for this custom multiplication.

        Erik


On Dec 9, 2011, at 16:17 , Gabriel Cooper wrote:

> Is there a way to manipulate the results coming back from SOLR?
> 
> I have a SOLR 3.5 index that contains values in cents (e.g. "100" in the 
> index represents $1.00) and in certain contexts (e.g. CSV export) I'd like to 
> divide by 100 for that field to provide a user-friendly "in dollars" number. 
> To do this I played around with Function Queries for a while without 
> realizing they're limited to relevancy scores, and later found 
> "DocTransformers" in 4.0 whose description sounded right but don't exist in 
> 3.5.
> 
> Is there anything else I haven't considered?
> 
> Thanks for any help
> 
> Gabriel Cooper.

Reply via email to