[ 
https://issues.apache.org/jira/browse/SOLR-6539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17736266#comment-17736266
 ] 

Yuntong Qu commented on SOLR-6539:
----------------------------------

Curious to if this issue is still active. It seems that to index high precision 
number, the workaround would be to create a custom schema, or index as string. 

[https://solr-user.lucene.apache.narkive.com/vKksUECS/bigdecimal-data-type]
[https://solr-user.lucene.apache.narkive.com/UelbUx2V/bigdecimal-solr-field-in-schema]

 

> SolrJ document object binding / BigDecimal
> ------------------------------------------
>
>                 Key: SOLR-6539
>                 URL: https://issues.apache.org/jira/browse/SOLR-6539
>             Project: Solr
>          Issue Type: Improvement
>          Components: SolrJ
>    Affects Versions: 4.9, 4.10, 4.10.1
>            Reporter: Bert Brecht
>            Priority: Major
>              Labels: patch
>             Fix For: 6.0
>
>         Attachments: SOLR-6539.diff
>
>
> We are using BigDecimals in our application quite often for calculating. We 
> store our values typically as java primitives (int, long/double, float) and 
> using the DocumentObjectBinder (annotations based document object binding). 
> Unfortunately, we must have exactly the type given in solr schema for type 
> used as field/accessor. We found out, that the following patch would allow us 
> to define BigDecimal as type as we just use BigDecimal as a type in our 
> mapped POJO. This would help to make the mapping more powerful without 
> loosing anything.
> ----------
> $ svn diff 
> Downloads/solr/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
> Index: 
> Downloads/solr/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
> ===================================================================
> --- 
> Downloads/solr/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
>      (revision 1626087)
> +++ 
> Downloads/solr/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
>      (working copy)
> @@ -359,6 +359,9 @@
>        if (v != null && type == ByteBuffer.class && v.getClass() == 
> byte[].class) {
>          v = ByteBuffer.wrap((byte[]) v);
>        }
> +      if (type == java.math.BigDecimal.class){
> +        v = BigDecimal.valueOf(v):
> +      }
>        try {
>          if (field != null) {
>            field.set(obj, v);



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to