2

I am using a decimal value type in cassandra to store money (corresponds to BigDecimal, a reasonably precise number type for this use case).

I seem to be unable to index this field. The SolR data types I tried to match this are "CurrencyField" and then float. The error message is nearly the same:

Solr type text and Cassandra type: decimal do not match for field

CurrencyField seems to expect a currency and value as a tuple. This makes it necessary to store currency values as a string in C* to be able to index this correctly? As a workaround, I could store the values twice, as a decimal and string although I do not like the redundancy which complicates updates and other handling. Thanks for your suggestions...

Community
  • 1
  • 1
John
  • 1,462
  • 10
  • 17

1 Answers1

0

Try using double or float. If you plan to do range scans use the trie Solr fields:

TrieDoubleField double

TrieFloatField float

Reference docs: http://www.datastax.com/documentation/datastax_enterprise/4.5/datastax_enterprise/srch/srchSolrType.html

phact
  • 7,305
  • 23
  • 27
  • I want to store a precise representation of the number, check out http://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency – John Oct 20 '14 at 15:38
  • It's not currently supported. You may want to have two fields for now. – phact Nov 05 '14 at 18:57
  • @phact Do you know if and when the support will be added? With float, double, tfloat and tdouble, I get similar error messages: '''Solr type float and Cassandra type: decimal do not match for field: amount''' – Rahul Singhai Apr 21 '15 at 13:56