Without knowing exactly what you're doing, it's hard to tell. When you're using an IRiakObject with StoreObject.store() without specifying a Converter<T>, there's not any JSON serialization/deserialization occurring. It's simply storing whatever you pass to withValue() in Riak.
If you can provide a short compilable example that exhibits the behavior you're describing, I'll be happy to look into it. Thanks! Brian Roach On Tue, Oct 23, 2012 at 3:08 PM, Hrishikesh More <[email protected]> wrote: > Index preparation works but storing the JSON is not working. It complains > about 'sku1' (which is a 'object' type). > > > On Wed, Oct 24, 2012 at 2:33 AM, Hrishikesh More > <[email protected]> wrote: >> >> I have config with list of attributes and their types (e.g. string, >> integer, boolean). Based on attribute I appropriately put it in RiakIndexes >> object. It works if I do it with simple (non nested) JSON. >> >> e.g. >> if (attrType.equals("String")) { >> riakIndexes.add(fieldName, parser.getText()); ==> >> parser is JsonParser >> } >> >> >> >> On Wed, Oct 24, 2012 at 2:27 AM, Brian Roach <[email protected]> wrote: >>> >>> How, exactly, are you creating 'indexes' ? >>> >>> A secondary index in Riak has to be an integer or a string. >>> >>> Thanks, >>> Brian Roach >>> >>> On Tue, Oct 23, 2012 at 2:42 PM, Hrishikesh More >>> <[email protected]> wrote: >>> > Hi, >>> > >>> > Using following JSON I am trying to create secondary indexes in >>> > Riak. >>> > >>> > { >>> > “Id” : “xxxx”, >>> > “login” : “xxx”, >>> > “context” : “xxx”, >>> > “creationDate” : “xxxx”, >>> > ........... >>> > ........... >>> > “sku1” : { >>> > quantity : 1, >>> > }, >>> > “sku2” : { >>> > quantity : 2, >>> > }, >>> > } >>> > >>> > I prepare RiakIndexes by using above JSON and looping over it. When >>> > I try >>> > to store (the same json string) it in following way I get 'Unknown >>> > field >>> > type for field: 'sku1' error. >>> > >>> > IRiakObject riakObj = RiakObjectBuilder.newBuilder(bucketName, id) >>> > .withIndexes(indexes) >>> > .withValue(json) >>> > .withContentType('application/json') >>> > .build(); >>> > >>> > IRiakObject returnObject = bucket.store(riakObj); >>> > >>> > Error: >>> > com.basho.riak.client.http.response.RiakResponseRuntimeException: >>> > Unknown field type for field: 'sku1'. >>> > Unknown field type for field: 'sku2'. >>> > >>> > 1. If I don't define nested JSON it works, however it I put 'skuid' >>> > using >>> > objectMapper.createObjectNode() and add to parent object node (while >>> > preparing JSON for testing), it gives above error. >>> > Do I have to write custom serializer here? >>> > 2. Is there a way to ignore this error through config in Riak? >>> > >>> > thanx. >>> > >>> > _______________________________________________ >>> > riak-users mailing list >>> > [email protected] >>> > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com >>> > >> >> > _______________________________________________ riak-users mailing list [email protected] http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
