Riak special characters in keys

I want to store a key with a special char (slash in my case) until Riak via REST.

HowTo http://wiki.basho.com/Riak-Search---Querying.html#Fields says:

If your field contains special characters, for example ('+,' -, '/,' [, '],' (, '),': or space), then either surround the phrase in single quotes, or avoid each special character with using backslash.

But fields, not keys. I tried to hide it, but it did not work.

I could not find any information on this issue. Does anyone know how to mask special characters in keys ?

Example (does not work):

PUT https://riak:8069/buckets/key/keys/11111\/2 

where is the key 11111/2

+4
source share
1 answer

This has nothing to do with Riak, but rather how you need to avoid URLs, so the server (including Riak) does not interpret the slash as a path separator:

 PUT https://riak:8069/buckets/key/keys/11111%2F2 

Then you can get it the same way:

 GET https://riak:8069/riak/key/11111%2F2 

%2F is the value / when using URL Encoding - if your keys contain characters that are considered special characters in URLs, you need to do this with your keys.

You can make sure that this worked correctly in Riak by specifying the keys in your key bucket (on the test server - do not do this on the production server, as it is very expensive):

 GET https://riak:8069/riak/key?keys=true 

At the end of the JSON output, you will find:

 ... "keys":[...,"11111/2",...]} 
+6
source

Source: https://habr.com/ru/post/1402473/


All Articles