Re: manipulate the results coming back from SOLR? (was: possible to do arithmetic on returned values?)
Erik hatcher wrote you a comment assuming you were using Velocity. The more generic form of that comment is that this is an app-level issue by and large. Solr is in charge of searching and returning data, the app is a better place to change that into something pretty... Best Erick On Mon, Dec 12, 2011 at 9:37 AM, Gabriel Cooper wrote: > I'm hoping I just got lost in the shuffle due to posting on a Friday night. > Is there a way to change a field's data via some function, e.g. add, > subtract, product, etc.? > > > On 12/9/11 4:17 PM, 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. > >
manipulate the results coming back from SOLR? (was: possible to do arithmetic on returned values?)
I'm hoping I just got lost in the shuffle due to posting on a Friday night. Is there a way to change a field's data via some function, e.g. add, subtract, product, etc.? On 12/9/11 4:17 PM, 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.
Re: possible to do arithmetic on returned values?
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.
possible to do arithmetic on returned values?
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.