On 20 Feb 2013, at 14:35, Theo Bot <[email protected]> wrote:
> Hi
>
> It's not that I want to use the erlang client. It's just that I want to know
> to to create http queries to maintain the secondary indexes.
Ah, OK.
Sorry for the confusion. Updating the indexes is just like updating a value or
any other object meta-data in riak, you need to fetch the whole value, change
it, and send it back.
To delete all the indexes for a key just POST that keys value to riak's HTTP,
without the x-riak-index headers.
To remove particular index(es) just POST that keys value to riak's HTTP
interface minus the x-riak-index headers for the index you want to remove.
For example, say you created (as per the riak docs example[1])
curl -X POST \
-H 'x-riak-index-twitter_bin: jsmith123' \
-H 'x-riak-index-email_bin: [email protected]' \
-d'...user data...' \
http://localhost:8098/buckets/users/keys/john_smith
When you read the data back with `curl -v
localhost:8098/buckets/users/keys/john_smith` you get:
< HTTP/1.1 200 OK
< X-Riak-Vclock: a85hYGBgzGDKBVIcypz/fgbKiqhmMCUy57EyfImZeYovCwA=
< x-riak-index-twitter_bin: jsmith123
< x-riak-index-email_bin: [email protected]
< Vary: Accept-Encoding
< Server: MochiWeb/1.1 WebMachine/1.9.2 (someone had painted it blue)
< Link: </buckets/users>; rel="up"
< Last-Modified: Wed, 20 Feb 2013 14:43:00 GMT
< ETag: "7DdYGiY7JujKiCVTTXp51M"
< Date: Wed, 20 Feb 2013 14:43:10 GMT
< Content-Type: application/x-www-form-urlencoded
< Content-Length: 15
<
* Connection #0 to host localhost left intact
...user data...* Closing connection #0
Those x-riak-index headers are your indexes. To remove one just post back the
object, minus the index you want to remove. So to drop the 'twitter' index:
curl -X POST http://localhost:8098/buckets/users/keys/john_smith -d"...user
data..." \
-H"X-Riak-Vclock: a85hYGBgzGDKBVIcypz/fgbKiqhmMCUy57EyfImZeYovCwA=" \
-H 'x-riak-index-email_bin: [email protected]'
When you read the value again you'll see it now only has one index.
I guess your client will need to parse out those index headers into some useful
structure, and expose a way for the user to add / edit / remove indexes, and
your client then needs to generate headers to post back to riak.
Does that cover it?
Cheers
Russell
[1]
http://docs.basho.com/riak/latest/tutorials/querying/Secondary-Indexes/#Query-Interfaces-and-Examples
>
> Theo
>
>
> On Wed, Feb 20, 2013 at 3:30 PM, Christian Dahlqvist <[email protected]>
> wrote:
> Hi Theo,
>
> The Riak HTTP client for Erlang uses the 'riakc_obj' from the PB client to
> represent records. You can therefore use any utility functions available
> there to manipulate metadata. The HTTP client for Erlang does however
> currently not support secondary indexes [1], meaning that these will not be
> parsed nor sent when getting or putting an object.
>
> [1] http://docs.basho.com/riak/1.3.0rc4/references/Client-Libraries/#HTTP
>
> Best regards,
>
> Christian
>
>
> On 20 Feb 2013, at 08:41, Theo Bot <[email protected]> wrote:
>
>> Hi
>>
>> I found in the erlang client that there are methods
>> (clear_secondary_indexes, delete_secondary_index) in the pb api to maintain
>> the secondary index of objects. However in the http api I cannot find such
>> methods.
>>
>> --
>> Kind regards
>>
>> Theo Bot
>> Network Management Engineer
>> e-mail: [email protected]
>> Website: http://www.proxy.nl
>> LinkedIn: http://www.linkedin.com/in/theobot
>>
>> _______________________________________________
>> riak-users mailing list
>> [email protected]
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>
>
>
> --
> Met vriendelijke groet,
>
> Theo Bot
> Network Management Engineer
> Tel: +31653965698
> e-mail: [email protected]
> Website: http://www.proxy.nl
> LinkedIn: http://www.linkedin.com/in/theobot
>
> _______________________________________________
> 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