Reputation: 6394
Can I query an array of secondary indexes in a Map Reduce job in Riak, instead of just the one key? I want to do something like this:
"inputs": {
"bucket": myBycket,
"index": "myIndex",
"key": key + " OR " + key + " OR " + key
},
"query": [{
"map": {
"language":"javascript",
"name":"Riak.mapValuesJson"
}
}]
}
But I have not found any support for it. The keys are in no particular order, so I don't think that I can use ranged queries.
Upvotes: 0
Views: 64
Reputation: 28336
You could certainly handle this with Map Reduce. If you presort your target keys, you could limit the range and possibly improve performance.
{
"inputs": {
"bucket": myBycket,
"index": "myIndex",
"start": firstkey,
"end": lastkey
},
"query": [{
"map": {
"language":"javascript",
"source":"function(v) {
if (v.key == "key1" || v.key == "key2") {
return [<<put what you want returned here>>]
} else {
return []
}
}"
}
}]
}
You should note that according to the docs site javascript Map Reduce has been officially deprecated, so you may want to use Erlang functions for new development.
Upvotes: 1