Thanks for this inquiry; as a result I have added a "round" JavaScript script for the StatelessScriptUpdate processor to Early Access Release #5 of my Solr 4.x Deep Dive book in the chapter on update processors.

The script takes a field name, a number of decimal digits to round to (default is 0), and an output field (defaults to replacing the input field), and an option to convert the type of the rounded number to integer.

One thing I just noticed - your message indicates that 0.5 should round to 0.0, but that is not the standard definition of rounding. What is your true intention there?

The script can replace the original value with the rounded value, or preserve the original value and place a rounded copy in another field. What is your preference? (Well, the script supports both, anyway.)

And I did give the script the "integer" option to convert the type, so that 1.0 would become 1 Solr "int" fields.

-- Jack Krupansky

-----Original Message----- From: Thyagaraj
Sent: Thursday, August 01, 2013 2:37 AM
To: solr-user@lucene.apache.org
Subject: Solr round ratings to nearest integer value

I'm using solr 4.0 with DIH jdbc connector and I use Solr Admin web interface
for testing. I have a field called *ratings* which varies like 0, 0.3, 0.5,
0.75, 1, 1.5, 1.6... and so on as per user input.


I found the link
http://lucene.472066.n3.nabble.com/How-to-round-solr-score-td495198.html
<http://lucene.472066.n3.nabble.com/How-to-round-solr-score-td495198.html>
which is beyond of my understanding and I unable to make use of in my case.


I just want to round this rating values to nearest integer value through
solr like,
0.3 & 0.5 to 0
0.75 & 1.5 to 1
1.6 to 2


Anybody help me guiding please?

Thank you!



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-round-ratings-to-nearest-integer-value-tp4081833.html Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to