I am using cassandra-driver-core version 3.5.1
I have a table in cassandra. All fields in table are camel cased and created with double quotes. These fields needs to be in camel case as my solr schema has camel casing and we have around 80-120 field.
But when I insert my json documents in this table, using below code:
//jsonData is json document in String
Insert insertQuery = QueryBuilder.insertInto(keySpace, table).json(jsonData);
ResultSet resultSet = session.execute(insertQuery.toString());
Generated insert query:
INSERT INTO asda_search.GROCERIES JSON '{"catalogName":"some data", .....);
cassandra driver converts the field in insert statement to lower case, leading to below exception:
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: JSON values map contains unrecognized column: catalogname
In my table field name is catalogName
What I should do, so that driver does not lower case my fields?
Update:
I know I can create Query as below:
QueryBuilder.insertInto(keySpace, table).values(fieldNameList, fieldValueList)
while creating fieldNameList
I can add quotes to the field names.
Any other solution?
While creating JSON added escaped double quotes to such fields.
Example:"\"catalogName\""
.
If using jackson: @JsonProperty("\"catalogName\"")
This worked for me.