Skip to content

Commit c9f2d70

Browse files
author
Lauren
authored
Merge pull request #2383 from basho/ej/kv/2i
Add note on backend choice to secondary index section in dev querying
2 parents cd722ce + d1e1f4f commit c9f2d70

File tree

88 files changed

+814
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+814
-286
lines changed

content/riak/kv/2.0.0/developing/getting-started/csharp/querying.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ intrinsic relationships.
124124

125125
## Secondary Indexes
126126

127+
{{% note %}}
128+
Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.0/setup/planning/backend/bitcask) does not support secondary indexes.
129+
130+
See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes.
131+
{{% /note %}}
132+
127133
If you're coming from an SQL world, Secondary Indexes (2i) are a lot
128134
like SQL indexes. They are a way to quickly look up objects based on a
129135
secondary key, without scanning through the whole dataset. This makes it

content/riak/kv/2.0.0/developing/getting-started/erlang/querying.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ intrinsic relationships.
214214

215215
## Secondary Indexes
216216

217+
{{% note %}}
218+
Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.0/setup/planning/backend/bitcask) does not support secondary indexes.
219+
220+
See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes.
221+
{{% /note %}}
222+
217223
If you're coming from an SQL world, Secondary Indexes (2i) are a lot
218224
like SQL indexes. They are a way to quickly look up objects based on a
219225
secondary key, without scanning through the whole dataset. This makes it

content/riak/kv/2.0.0/developing/getting-started/golang/querying.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ aliases:
1818

1919
## Go Version Setup
2020

21-
For the Go version, please download the source from GitHub by either [cloning](https://github.com/basho/taste-of-riak) the source code repository or downloading the [current zip of the master branch](https://github.com/basho/taste-of-riak/archive/master.zip). Ensure that the source is located in your `GOPATH`. The code for this chapter is in `go/ch02/ch02.go`. You may import this code into your favorite editor, or just run it from the command line using the `Makefile` if you are running on a *nix OS.
21+
For the Go version, please download the source from GitHub by either [cloning](https://github.com/basho/taste-of-riak) the source code repository or downloading the [current zip of the master branch](https://github.com/basho/taste-of-riak/archive/master.zip). Ensure that the source is located in your `GOPATH`. The code for this chapter is in `go/ch02/ch02.go`. You may import this code into your favorite editor, or just run it from the command line using the `Makefile` if you are running on a *nix* OS.
2222

2323
>A Quick Note on Querying and Schemas:
2424
>
@@ -340,7 +340,7 @@ func createOrderSummary(customerId string, orders []*Order) *OrderSummary {
340340
}
341341
```
342342

343-
While individual `Customer` and `Order` objects don't change much (or shouldn't change), the `Order Summaries` object will likely change often. It will do double duty by acting as an index for all a customer's orders and also holding some relevant data, such as the order total, etc. If we showed this information in our application often, it's only one extra request to get all the info.
343+
While individual `Customer` and `Order` objects don't change much (or shouldn't change), the `Order Summaries` object will likely change often. It will do double duty by acting as an index for all a customer's orders and also holding some relevant data, such as the order total, etc. If we showed this information in our application often, it's only one extra request to get all the info.
344344

345345
```golang
346346
util.Log.Println("Fetching related data by shared key")
@@ -415,6 +415,12 @@ While this pattern is very easy and extremely fast with respect to queries and c
415415

416416
### Secondary Indexes
417417

418+
{{% note %}}
419+
Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.0/setup/planning/backend/bitcask) does not support secondary indexes.
420+
421+
See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes.
422+
{{% /note %}}
423+
418424
If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL indexes. They are a way to quickly look up objects based on a secondary key, without scanning through the whole dataset. This makes it very easy to find groups of related data by values or ranges of values. To properly show this off, we will add some more data to our application, and add some secondary index entries at the same time:
419425

420426
```golang
@@ -496,7 +502,7 @@ wg.Wait()
496502
close(doneChan)
497503
```
498504

499-
As you may have noticed, ordinary key/value data is opaque to 2i, so we have to add entries to the indexes at the application level.
505+
As you may have noticed, ordinary key/value data is opaque to 2i, so we have to add entries to the indexes at the application level.
500506

501507
Now let's find all of Jane Appleseed's processed orders. We'll lookup the orders by searching the `saleperson_id_int` index for Jane's id of `9000`:
502508

@@ -564,7 +570,7 @@ Easy! We used 2i's range feature to search for a range of values, and demonstra
564570

565571
So to recap:
566572

567-
* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key.
573+
* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key.
568574
* Indexes can have either Integer or Binary(String) keys.
569575
* You can search for specific values or a range of values.
570576
* Riak will return a list of keys that match the index query.

content/riak/kv/2.0.0/developing/getting-started/java/querying.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ branch](https://github.com/basho/taste-of-riak/archive/master.zip).
2525
The code for this chapter is in `/java/Ch02-Schemas-and-Indexes`. You
2626
may import this code into your favorite editor, or just run it from the
2727
command line using the commands in `BuildAndRun.sh` if you are running
28-
on a *nix OS.
28+
on a *nix* OS.
2929

3030
## A Quick Note on Querying and Schemas
3131

@@ -193,6 +193,12 @@ intrinsic relationships.
193193
194194
## Secondary Indexes
195195
196+
{{% note %}}
197+
Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.0/setup/planning/backend/bitcask) does not support secondary indexes.
198+
199+
See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes.
200+
{{% /note %}}
201+
196202
If you're coming from an SQL world, Secondary Indexes (2i) are a lot
197203
like SQL indexes. They are a way to quickly look up objects based on a
198204
secondary key, without scanning through the whole dataset. This makes it

content/riak/kv/2.0.0/developing/getting-started/nodejs/querying.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ intrinsic relationships.
8686

8787
## Secondary Indexes
8888

89+
{{% note %}}
90+
Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.0/setup/planning/backend/bitcask) does not support secondary indexes.
91+
92+
See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes.
93+
{{% /note %}}
94+
8995
If you're coming from an SQL world, Secondary Indexes (2i) are a lot
9096
like SQL indexes. They are a way to quickly look up objects based on a
9197
secondary key, without scanning through the whole dataset. This makes it

content/riak/kv/2.0.0/developing/getting-started/php/querying.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class Item
9494

9595
class OrderSummary
9696
{
97-
public function __construct()
97+
public function __construct()
9898
{
9999
$this->summaries = array();
100100
}
@@ -104,7 +104,7 @@ class OrderSummary
104104

105105
class OrderSummaryItem
106106
{
107-
public function __construct(Order $order)
107+
public function __construct(Order $order)
108108
{
109109
$this->orderId = $order->orderId;
110110
$this->total = $order->total;
@@ -141,8 +141,8 @@ $order1->items = [
141141
15.99
142142
),
143143
new Item(
144-
'PEG10BBF2PP',
145-
'eTablet Pro; 24GB; Grey',
144+
'PEG10BBF2PP',
145+
'eTablet Pro; 24GB; Grey',
146146
399.99
147147
)
148148
];
@@ -231,7 +231,7 @@ $storeSummary = (new Command\Builder\StoreObject($riak))
231231
$storeSummary->execute();
232232
```
233233

234-
While individual `Customer` and `Order` objects don't change much (or shouldn't change), the `Order Summaries` object will likely change often. It will do double duty by acting as an index for all a customer's orders, and also holding some relevant data such as the order total, etc. If we showed this information in our application often, it's only one extra request to get all the info.
234+
While individual `Customer` and `Order` objects don't change much (or shouldn't change), the `Order Summaries` object will likely change often. It will do double duty by acting as an index for all a customer's orders, and also holding some relevant data such as the order total, etc. If we showed this information in our application often, it's only one extra request to get all the info.
235235

236236
```php
237237
// Fetching related data by shared key
@@ -297,6 +297,12 @@ While this pattern is very easy and extremely fast with respect to queries and c
297297

298298
## Secondary Indexes
299299

300+
{{% note %}}
301+
Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.0/setup/planning/backend/bitcask) does not support secondary indexes.
302+
303+
See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes.
304+
{{% /note %}}
305+
300306
If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL indexes. They are a way to quickly lookup objects based on a secondary key, without scanning through the whole dataset. This makes it very easy to find groups of related data by values, or even ranges of values. To properly show this off, we will now add some more data to our application, and add some secondary index entries at the same time.
301307

302308
```php
@@ -323,7 +329,7 @@ unset($key);
323329

324330
```
325331

326-
As you may have noticed, ordinary Key/Value data is opaque to 2i, so we have to add entries to the indexes at the application level.
332+
As you may have noticed, ordinary Key/Value data is opaque to 2i, so we have to add entries to the indexes at the application level.
327333
Now let's find all of Jane Appleseed's processed orders, we'll lookup the orders by searching the `saleperson_id_int` index for Jane's id of `9000`.
328334

329335
```php
@@ -354,7 +360,7 @@ Jane processed orders 1 and 3. We used an "integer" index to reference Jane's i
354360
Now, let's say that the VP of Sales wants to know how many orders came in during October 2013. In this case, we can exploit 2i's range queries. Let's search the `order_date_bin` index for entries between `20131001` and `20131031`.
355361

356362
```php
357-
// Query for orders where the OrderDate bin index is
363+
// Query for orders where the OrderDate bin index is
358364
// between 2013-10-01 and 2013-10-31
359365
$fetchOctoberOrders = (new Command\Builder\QueryIndex($riak))
360366
->inBucket($ordersBucket)
@@ -392,7 +398,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a
392398

393399
So to recap:
394400

395-
* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key.
401+
* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key.
396402
* Indexes can have either Integer or Binary(String) keys
397403
* You can search for specific values, or a range of values
398404
* Riak will return a list of keys (and terms if needed) that match the index query

content/riak/kv/2.0.0/developing/getting-started/python/querying.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ os = order_summary_bucket.new(str(order_summary['customer_id']),
150150
os.store()
151151
```
152152

153-
While individual `Customer` and `Order` objects don't change much (or shouldn't change), the `Order Summaries` object will likely change often. It will do double duty by acting as an index for all customer orders, and also holding some relevant data such as the order total, etc. If we showed this information in our application often, it's only one extra request to get all the info.
153+
While individual `Customer` and `Order` objects don't change much (or shouldn't change), the `Order Summaries` object will likely change often. It will do double duty by acting as an index for all customer orders, and also holding some relevant data such as the order total, etc. If we showed this information in our application often, it's only one extra request to get all the info.
154154

155155
```python
156156
customer = customer_bucket.get('1').data
@@ -162,15 +162,15 @@ Which returns our amalgamated objects:
162162

163163
```python
164164
{
165-
u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210',
166-
u'created_date': u'2013-10-01 14:30:26',
167-
'order_summary': {
165+
u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210',
166+
u'created_date': u'2013-10-01 14:30:26',
167+
'order_summary': {
168168
u'customer_id': 1, u'summaries': [
169-
{u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98},
170-
{u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99},
169+
{u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98},
170+
{u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99},
171171
{u'order_id': 3, u'order_date': u'2013-11-03 17:45:28', u'total': 74.98}
172-
]},
173-
u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street',
172+
]},
173+
u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street',
174174
u'customer_id': 1
175175
}
176176
```
@@ -180,6 +180,12 @@ While this pattern is very easy and extremely fast with respect to queries and c
180180

181181
### Secondary Indexes
182182

183+
{{% note %}}
184+
Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.0/setup/planning/backend/bitcask) does not support secondary indexes.
185+
186+
See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes.
187+
{{% /note %}}
188+
183189
If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL indexes. They are a way to quickly lookup objects based on a secondary key, without scanning through the whole dataset. This makes it very easy to find groups of related data by values, or even ranges of values. To properly show this off, we will now add some more data to our application, and add some secondary index entries at the same time.
184190

185191
```python
@@ -191,7 +197,7 @@ for i in range(1, 4):
191197
order.store()
192198
```
193199

194-
As you may have noticed, ordinary Key/Value data is opaque to 2i, so we have to add entries to the indexes at the application level.
200+
As you may have noticed, ordinary Key/Value data is opaque to 2i, so we have to add entries to the indexes at the application level.
195201
Now let's find all of Jane Appleseed's processed orders, we'll lookup the orders by searching the `saleperson_id_int` index for Jane's id of `9000`.
196202

197203
```python
@@ -224,7 +230,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a
224230

225231
So to recap:
226232

227-
* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key.
233+
* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key.
228234
* Indexes can have either Integer or Binary(String) keys
229235
* You can search for specific values, or a range of values
230236
* Riak will return a list of keys that match the index query

content/riak/kv/2.0.0/developing/getting-started/ruby/querying.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ os.data = order_summary
149149
os.store
150150
```
151151

152-
While individual `Customer` and `Order` objects don't change much (or shouldn't change), the `Order Summaries` object will likely change often. It will do double duty by acting as an index for all a customer's orders, and also holding some relevant data such as the order total, etc. If we showed this information in our application often, it's only one extra request to get all the info.
152+
While individual `Customer` and `Order` objects don't change much (or shouldn't change), the `Order Summaries` object will likely change often. It will do double duty by acting as an index for all a customer's orders, and also holding some relevant data such as the order total, etc. If we showed this information in our application often, it's only one extra request to get all the info.
153153

154154
```ruby
155155
shared_key = '1'
@@ -190,6 +190,12 @@ While this pattern is very easy and extremely fast with respect to queries and c
190190

191191
### Secondary Indexes
192192

193+
{{% note %}}
194+
Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.0/setup/planning/backend/bitcask) does not support secondary indexes.
195+
196+
See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes.
197+
{{% /note %}}
198+
193199
If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL indexes. They are a way to quickly lookup objects based on a secondary key, without scanning through the whole dataset. This makes it very easy to find groups of related data by values, or even ranges of values. To properly show this off, we will now add some more data to our application, and add some secondary index entries at the same time.
194200

195201
```ruby
@@ -206,7 +212,7 @@ If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL ind
206212
end
207213
```
208214

209-
As you may have noticed, ordinary Key/Value data is opaque to 2i, so we have to add entries to the indexes at the application level.
215+
As you may have noticed, ordinary Key/Value data is opaque to 2i, so we have to add entries to the indexes at the application level.
210216
Now let's find all of Jane Appleseed's processed orders, we'll lookup the orders by searching the `saleperson_id_int` index for Jane's id of `9000`.
211217

212218
```ruby
@@ -240,7 +246,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a
240246

241247
So to recap:
242248

243-
* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key.
249+
* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key.
244250
* Indexes can have either Integer or Binary(String) keys
245251
* You can search for specific values, or a range of values
246252
* Riak will return a list of keys that match the index query

content/riak/kv/2.0.1/developing/getting-started/csharp/querying.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ intrinsic relationships.
124124

125125
## Secondary Indexes
126126

127+
{{% note %}}
128+
Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.1/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.1/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.1/setup/planning/backend/bitcask) does not support secondary indexes.
129+
130+
See [Using Secondary Indexes (2i)](/riak/kv/2.0.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes.
131+
{{% /note %}}
132+
127133
If you're coming from an SQL world, Secondary Indexes (2i) are a lot
128134
like SQL indexes. They are a way to quickly look up objects based on a
129135
secondary key, without scanning through the whole dataset. This makes it

content/riak/kv/2.0.1/developing/getting-started/erlang/querying.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ intrinsic relationships.
214214

215215
## Secondary Indexes
216216

217+
{{% note %}}
218+
Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.1/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.1/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.1/setup/planning/backend/bitcask) does not support secondary indexes.
219+
220+
See [Using Secondary Indexes (2i)](/riak/kv/2.0.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes.
221+
{{% /note %}}
222+
217223
If you're coming from an SQL world, Secondary Indexes (2i) are a lot
218224
like SQL indexes. They are a way to quickly look up objects based on a
219225
secondary key, without scanning through the whole dataset. This makes it

0 commit comments

Comments
 (0)