Hi Izhar,

I've included a command-line example below that uses the special $key
field.

Note that on the command line, the dollar sign ($) must be escaped with a
backslash, otherwise the shell thinks you are referencing a variable. You
won't need to escape the dollar sign using the client libraries.

Best,
Rusty

## Load some data...

curl -v -X PUT -d 'data1' -H "x-riak-index-field1_bin: val1" \
http://127.0.0.1:8098/riak/bucket1/key1

curl -v -X PUT -d 'data2' -H "x-riak-index-field1_bin: val2" \
http://127.0.0.1:8098/riak/bucket1/key2

curl -v -X PUT -d 'data3' -H "x-riak-index-field1_bin: val3" \
http://127.0.0.1:8098/riak/bucket1/key3

curl -v -X PUT -d 'data4' -H "x-riak-index-field1_bin: val4" \
http://127.0.0.1:8098/riak/bucket1/key4

curl -v -X PUT -d 'data5' -H "x-riak-index-field1_bin: val5" \
http://127.0.0.1:8098/riak/bucket1/key5

## Run a REST-based query. In a web browser, you can just open
http://localhost:8098/buckets/bucket1/index/$key/key2/key4

curl http://localhost:8098/buckets/bucket1/index/\$key/key2/key4

## Run a M/R-based query...

curl -X POST \
-H "content-type: application/json" \
-d @- \
http://localhost:8098/mapred \
<<EOF
{
   "inputs":{
       "bucket":"bucket1",
       "index":"\$key",
       "start":"key2",
       "end":"key4"
   },
   "query":[
      {
         "reduce":{
            "language":"erlang",
            "module":"riak_kv_mapreduce",
            "function":"reduce_identity",
            "keep":true
         }
      }
   ]
}
EOF


On Thu, Dec 15, 2011 at 11:06 AM, Izhar Ravid <iz...@conduit.com> wrote:

> HI All,
>
> The Basho wiki states that:
> The $key index field is a special field that is implicitly indexed on all
> objects when Secondary Indexes is enabled. The value of this field is the
> object's key, so this field allows an application to perform range queries
> across the keys in a bucket.
>
> What is the REST API to use this special field? And what would be the the
> corresponding read URI?
>
> Thanks,
> Izhar.
> _______________________________________________
> riak-users mailing list
> riak-users@lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>



-- 
Rusty Klophaus (@rustyio)
*Basho Technologies, Inc.*
www.basho.com
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to