diff --git a/content/riak/kv/2.0.0/developing/getting-started/csharp/querying.md b/content/riak/kv/2.0.0/developing/getting-started/csharp/querying.md index cc5def81ef..b3a559cf22 100644 --- a/content/riak/kv/2.0.0/developing/getting-started/csharp/querying.md +++ b/content/riak/kv/2.0.0/developing/getting-started/csharp/querying.md @@ -124,6 +124,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.0/developing/getting-started/erlang/querying.md b/content/riak/kv/2.0.0/developing/getting-started/erlang/querying.md index 5d7f085a09..f5ac9b640d 100644 --- a/content/riak/kv/2.0.0/developing/getting-started/erlang/querying.md +++ b/content/riak/kv/2.0.0/developing/getting-started/erlang/querying.md @@ -214,6 +214,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.0/developing/getting-started/golang/querying.md b/content/riak/kv/2.0.0/developing/getting-started/golang/querying.md index 8cabb68956..3474414cd1 100644 --- a/content/riak/kv/2.0.0/developing/getting-started/golang/querying.md +++ b/content/riak/kv/2.0.0/developing/getting-started/golang/querying.md @@ -18,7 +18,7 @@ aliases: ## Go Version Setup -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. +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. >A Quick Note on Querying and Schemas: > @@ -340,7 +340,7 @@ func createOrderSummary(customerId string, orders []*Order) *OrderSummary { } ``` -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. +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. ```golang 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 ### Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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: ```golang @@ -496,7 +502,7 @@ wg.Wait() close(doneChan) ``` -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. +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. 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`: @@ -564,7 +570,7 @@ Easy! We used 2i's range feature to search for a range of values, and demonstra So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys. * You can search for specific values or a range of values. * Riak will return a list of keys that match the index query. diff --git a/content/riak/kv/2.0.0/developing/getting-started/java/querying.md b/content/riak/kv/2.0.0/developing/getting-started/java/querying.md index 33c4eb0ee6..614647d7a8 100644 --- a/content/riak/kv/2.0.0/developing/getting-started/java/querying.md +++ b/content/riak/kv/2.0.0/developing/getting-started/java/querying.md @@ -25,7 +25,7 @@ branch](https://github.com/basho/taste-of-riak/archive/master.zip). The code for this chapter is in `/java/Ch02-Schemas-and-Indexes`. You may import this code into your favorite editor, or just run it from the command line using the commands in `BuildAndRun.sh` if you are running -on a *nix OS. +on a *nix* OS. ## A Quick Note on Querying and Schemas @@ -193,6 +193,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.0/developing/getting-started/nodejs/querying.md b/content/riak/kv/2.0.0/developing/getting-started/nodejs/querying.md index a10d5bfd3e..dd42f76e4b 100644 --- a/content/riak/kv/2.0.0/developing/getting-started/nodejs/querying.md +++ b/content/riak/kv/2.0.0/developing/getting-started/nodejs/querying.md @@ -86,6 +86,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.0/developing/getting-started/php/querying.md b/content/riak/kv/2.0.0/developing/getting-started/php/querying.md index 9629ee4a12..e775c04b61 100644 --- a/content/riak/kv/2.0.0/developing/getting-started/php/querying.md +++ b/content/riak/kv/2.0.0/developing/getting-started/php/querying.md @@ -94,7 +94,7 @@ class Item class OrderSummary { - public function __construct() + public function __construct() { $this->summaries = array(); } @@ -104,7 +104,7 @@ class OrderSummary class OrderSummaryItem { - public function __construct(Order $order) + public function __construct(Order $order) { $this->orderId = $order->orderId; $this->total = $order->total; @@ -141,8 +141,8 @@ $order1->items = [ 15.99 ), new Item( - 'PEG10BBF2PP', - 'eTablet Pro; 24GB; Grey', + 'PEG10BBF2PP', + 'eTablet Pro; 24GB; Grey', 399.99 ) ]; @@ -231,7 +231,7 @@ $storeSummary = (new Command\Builder\StoreObject($riak)) $storeSummary->execute(); ``` - 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. + 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. ```php // 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 ## Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```php @@ -323,7 +329,7 @@ unset($key); ``` -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. +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. 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`. ```php @@ -354,7 +360,7 @@ Jane processed orders 1 and 3. We used an "integer" index to reference Jane's i 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`. ```php -// Query for orders where the OrderDate bin index is +// Query for orders where the OrderDate bin index is // between 2013-10-01 and 2013-10-31 $fetchOctoberOrders = (new Command\Builder\QueryIndex($riak)) ->inBucket($ordersBucket) @@ -392,7 +398,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys (and terms if needed) that match the index query diff --git a/content/riak/kv/2.0.0/developing/getting-started/python/querying.md b/content/riak/kv/2.0.0/developing/getting-started/python/querying.md index 65398a82f4..b88a7d0a1e 100644 --- a/content/riak/kv/2.0.0/developing/getting-started/python/querying.md +++ b/content/riak/kv/2.0.0/developing/getting-started/python/querying.md @@ -150,7 +150,7 @@ os = order_summary_bucket.new(str(order_summary['customer_id']), os.store() ``` - 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. + 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. ```python customer = customer_bucket.get('1').data @@ -162,15 +162,15 @@ Which returns our amalgamated objects: ```python { - u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', - u'created_date': u'2013-10-01 14:30:26', - 'order_summary': { + u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', + u'created_date': u'2013-10-01 14:30:26', + 'order_summary': { u'customer_id': 1, u'summaries': [ - {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, - {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, + {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, + {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, {u'order_id': 3, u'order_date': u'2013-11-03 17:45:28', u'total': 74.98} - ]}, - u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', + ]}, + u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', u'customer_id': 1 } ``` @@ -180,6 +180,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```python @@ -191,7 +197,7 @@ for i in range(1, 4): order.store() ``` -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. +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. 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`. ```python @@ -224,7 +230,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.0/developing/getting-started/ruby/querying.md b/content/riak/kv/2.0.0/developing/getting-started/ruby/querying.md index 1b7212672f..07bee6ed08 100644 --- a/content/riak/kv/2.0.0/developing/getting-started/ruby/querying.md +++ b/content/riak/kv/2.0.0/developing/getting-started/ruby/querying.md @@ -149,7 +149,7 @@ os.data = order_summary os.store ``` - 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. + 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. ```ruby shared_key = '1' @@ -190,6 +190,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```ruby @@ -206,7 +212,7 @@ If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL ind end ``` -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. +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. 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`. ```ruby @@ -240,7 +246,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.1/developing/getting-started/csharp/querying.md b/content/riak/kv/2.0.1/developing/getting-started/csharp/querying.md index 37b8c1f3a8..0e5da5d4ae 100644 --- a/content/riak/kv/2.0.1/developing/getting-started/csharp/querying.md +++ b/content/riak/kv/2.0.1/developing/getting-started/csharp/querying.md @@ -124,6 +124,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.1/developing/getting-started/erlang/querying.md b/content/riak/kv/2.0.1/developing/getting-started/erlang/querying.md index eb3857eea7..39ceab20ee 100644 --- a/content/riak/kv/2.0.1/developing/getting-started/erlang/querying.md +++ b/content/riak/kv/2.0.1/developing/getting-started/erlang/querying.md @@ -214,6 +214,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.1/developing/getting-started/golang/querying.md b/content/riak/kv/2.0.1/developing/getting-started/golang/querying.md index d370c46b97..9ecf13959e 100644 --- a/content/riak/kv/2.0.1/developing/getting-started/golang/querying.md +++ b/content/riak/kv/2.0.1/developing/getting-started/golang/querying.md @@ -18,7 +18,7 @@ aliases: ## Go Version Setup -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. +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. >A Quick Note on Querying and Schemas: > @@ -340,7 +340,7 @@ func createOrderSummary(customerId string, orders []*Order) *OrderSummary { } ``` -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. +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. ```golang 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 ### Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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: ```golang @@ -496,7 +502,7 @@ wg.Wait() close(doneChan) ``` -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. +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. 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`: @@ -564,7 +570,7 @@ Easy! We used 2i's range feature to search for a range of values, and demonstra So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys. * You can search for specific values or a range of values. * Riak will return a list of keys that match the index query. diff --git a/content/riak/kv/2.0.1/developing/getting-started/java/querying.md b/content/riak/kv/2.0.1/developing/getting-started/java/querying.md index 4bd743c368..2462579344 100644 --- a/content/riak/kv/2.0.1/developing/getting-started/java/querying.md +++ b/content/riak/kv/2.0.1/developing/getting-started/java/querying.md @@ -25,7 +25,7 @@ branch](https://github.com/basho/taste-of-riak/archive/master.zip). The code for this chapter is in `/java/Ch02-Schemas-and-Indexes`. You may import this code into your favorite editor, or just run it from the command line using the commands in `BuildAndRun.sh` if you are running -on a *nix OS. +on a *nix* OS. ## A Quick Note on Querying and Schemas @@ -193,6 +193,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.1/developing/getting-started/nodejs/querying.md b/content/riak/kv/2.0.1/developing/getting-started/nodejs/querying.md index 5bf8c1d7ed..4c5f1367a6 100644 --- a/content/riak/kv/2.0.1/developing/getting-started/nodejs/querying.md +++ b/content/riak/kv/2.0.1/developing/getting-started/nodejs/querying.md @@ -86,6 +86,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.1/developing/getting-started/php/querying.md b/content/riak/kv/2.0.1/developing/getting-started/php/querying.md index d02c727dda..5babec52f2 100644 --- a/content/riak/kv/2.0.1/developing/getting-started/php/querying.md +++ b/content/riak/kv/2.0.1/developing/getting-started/php/querying.md @@ -94,7 +94,7 @@ class Item class OrderSummary { - public function __construct() + public function __construct() { $this->summaries = array(); } @@ -104,7 +104,7 @@ class OrderSummary class OrderSummaryItem { - public function __construct(Order $order) + public function __construct(Order $order) { $this->orderId = $order->orderId; $this->total = $order->total; @@ -141,8 +141,8 @@ $order1->items = [ 15.99 ), new Item( - 'PEG10BBF2PP', - 'eTablet Pro; 24GB; Grey', + 'PEG10BBF2PP', + 'eTablet Pro; 24GB; Grey', 399.99 ) ]; @@ -231,7 +231,7 @@ $storeSummary = (new Command\Builder\StoreObject($riak)) $storeSummary->execute(); ``` - 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. + 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. ```php // 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 ## Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```php @@ -323,7 +329,7 @@ unset($key); ``` -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. +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. 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`. ```php @@ -354,7 +360,7 @@ Jane processed orders 1 and 3. We used an "integer" index to reference Jane's i 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`. ```php -// Query for orders where the OrderDate bin index is +// Query for orders where the OrderDate bin index is // between 2013-10-01 and 2013-10-31 $fetchOctoberOrders = (new Command\Builder\QueryIndex($riak)) ->inBucket($ordersBucket) @@ -392,7 +398,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys (and terms if needed) that match the index query diff --git a/content/riak/kv/2.0.1/developing/getting-started/python/querying.md b/content/riak/kv/2.0.1/developing/getting-started/python/querying.md index 68766a8e0f..0573e70f12 100644 --- a/content/riak/kv/2.0.1/developing/getting-started/python/querying.md +++ b/content/riak/kv/2.0.1/developing/getting-started/python/querying.md @@ -150,7 +150,7 @@ os = order_summary_bucket.new(str(order_summary['customer_id']), os.store() ``` - 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. + 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. ```python customer = customer_bucket.get('1').data @@ -162,15 +162,15 @@ Which returns our amalgamated objects: ```python { - u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', - u'created_date': u'2013-10-01 14:30:26', - 'order_summary': { + u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', + u'created_date': u'2013-10-01 14:30:26', + 'order_summary': { u'customer_id': 1, u'summaries': [ - {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, - {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, + {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, + {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, {u'order_id': 3, u'order_date': u'2013-11-03 17:45:28', u'total': 74.98} - ]}, - u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', + ]}, + u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', u'customer_id': 1 } ``` @@ -180,6 +180,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```python @@ -191,7 +197,7 @@ for i in range(1, 4): order.store() ``` -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. +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. 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`. ```python @@ -224,7 +230,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.1/developing/getting-started/ruby/querying.md b/content/riak/kv/2.0.1/developing/getting-started/ruby/querying.md index 1726b2ac7e..bd6a2c3aac 100644 --- a/content/riak/kv/2.0.1/developing/getting-started/ruby/querying.md +++ b/content/riak/kv/2.0.1/developing/getting-started/ruby/querying.md @@ -149,7 +149,7 @@ os.data = order_summary os.store ``` - 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. + 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. ```ruby shared_key = '1' @@ -190,6 +190,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +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. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```ruby @@ -206,7 +212,7 @@ If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL ind end ``` -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. +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. 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`. ```ruby @@ -240,7 +246,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.2/developing/getting-started/csharp/querying.md b/content/riak/kv/2.0.2/developing/getting-started/csharp/querying.md index 0317b9471d..5a98bde506 100644 --- a/content/riak/kv/2.0.2/developing/getting-started/csharp/querying.md +++ b/content/riak/kv/2.0.2/developing/getting-started/csharp/querying.md @@ -124,6 +124,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.2/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.2/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.2/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.2/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.2/developing/getting-started/erlang/querying.md b/content/riak/kv/2.0.2/developing/getting-started/erlang/querying.md index d258cdd286..a1cd0ebaae 100644 --- a/content/riak/kv/2.0.2/developing/getting-started/erlang/querying.md +++ b/content/riak/kv/2.0.2/developing/getting-started/erlang/querying.md @@ -214,6 +214,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.2/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.2/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.2/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.2/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.2/developing/getting-started/golang/querying.md b/content/riak/kv/2.0.2/developing/getting-started/golang/querying.md index d3d875b5dd..1fe004394f 100644 --- a/content/riak/kv/2.0.2/developing/getting-started/golang/querying.md +++ b/content/riak/kv/2.0.2/developing/getting-started/golang/querying.md @@ -18,7 +18,7 @@ aliases: ## Go Version Setup -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. +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. >A Quick Note on Querying and Schemas: > @@ -340,7 +340,7 @@ func createOrderSummary(customerId string, orders []*Order) *OrderSummary { } ``` -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. +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. ```golang 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 ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.2/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.2/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.2/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.2/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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: ```golang @@ -496,7 +502,7 @@ wg.Wait() close(doneChan) ``` -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. +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. 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`: @@ -564,7 +570,7 @@ Easy! We used 2i's range feature to search for a range of values, and demonstra So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys. * You can search for specific values or a range of values. * Riak will return a list of keys that match the index query. diff --git a/content/riak/kv/2.0.2/developing/getting-started/java/querying.md b/content/riak/kv/2.0.2/developing/getting-started/java/querying.md index d1dc2e59de..31d94a2a72 100644 --- a/content/riak/kv/2.0.2/developing/getting-started/java/querying.md +++ b/content/riak/kv/2.0.2/developing/getting-started/java/querying.md @@ -25,7 +25,7 @@ branch](https://github.com/basho/taste-of-riak/archive/master.zip). The code for this chapter is in `/java/Ch02-Schemas-and-Indexes`. You may import this code into your favorite editor, or just run it from the command line using the commands in `BuildAndRun.sh` if you are running -on a *nix OS. +on a *nix* OS. ## A Quick Note on Querying and Schemas @@ -193,6 +193,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.2/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.2/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.2/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.2/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.2/developing/getting-started/nodejs/querying.md b/content/riak/kv/2.0.2/developing/getting-started/nodejs/querying.md index 442f4112d3..1618569c0f 100644 --- a/content/riak/kv/2.0.2/developing/getting-started/nodejs/querying.md +++ b/content/riak/kv/2.0.2/developing/getting-started/nodejs/querying.md @@ -86,6 +86,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.2/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.2/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.2/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.2/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.2/developing/getting-started/php/querying.md b/content/riak/kv/2.0.2/developing/getting-started/php/querying.md index 9b023bbf1c..e254e0af37 100644 --- a/content/riak/kv/2.0.2/developing/getting-started/php/querying.md +++ b/content/riak/kv/2.0.2/developing/getting-started/php/querying.md @@ -94,7 +94,7 @@ class Item class OrderSummary { - public function __construct() + public function __construct() { $this->summaries = array(); } @@ -104,7 +104,7 @@ class OrderSummary class OrderSummaryItem { - public function __construct(Order $order) + public function __construct(Order $order) { $this->orderId = $order->orderId; $this->total = $order->total; @@ -141,8 +141,8 @@ $order1->items = [ 15.99 ), new Item( - 'PEG10BBF2PP', - 'eTablet Pro; 24GB; Grey', + 'PEG10BBF2PP', + 'eTablet Pro; 24GB; Grey', 399.99 ) ]; @@ -231,7 +231,7 @@ $storeSummary = (new Command\Builder\StoreObject($riak)) $storeSummary->execute(); ``` - 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. + 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. ```php // 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 ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.2/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.2/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.2/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.2/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```php @@ -323,7 +329,7 @@ unset($key); ``` -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. +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. 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`. ```php @@ -354,7 +360,7 @@ Jane processed orders 1 and 3. We used an "integer" index to reference Jane's i 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`. ```php -// Query for orders where the OrderDate bin index is +// Query for orders where the OrderDate bin index is // between 2013-10-01 and 2013-10-31 $fetchOctoberOrders = (new Command\Builder\QueryIndex($riak)) ->inBucket($ordersBucket) @@ -392,7 +398,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys (and terms if needed) that match the index query diff --git a/content/riak/kv/2.0.2/developing/getting-started/python/querying.md b/content/riak/kv/2.0.2/developing/getting-started/python/querying.md index bafdc0f9bc..f330d71869 100644 --- a/content/riak/kv/2.0.2/developing/getting-started/python/querying.md +++ b/content/riak/kv/2.0.2/developing/getting-started/python/querying.md @@ -150,7 +150,7 @@ os = order_summary_bucket.new(str(order_summary['customer_id']), os.store() ``` - 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. + 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. ```python customer = customer_bucket.get('1').data @@ -162,15 +162,15 @@ Which returns our amalgamated objects: ```python { - u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', - u'created_date': u'2013-10-01 14:30:26', - 'order_summary': { + u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', + u'created_date': u'2013-10-01 14:30:26', + 'order_summary': { u'customer_id': 1, u'summaries': [ - {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, - {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, + {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, + {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, {u'order_id': 3, u'order_date': u'2013-11-03 17:45:28', u'total': 74.98} - ]}, - u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', + ]}, + u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', u'customer_id': 1 } ``` @@ -180,6 +180,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.2/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.2/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.2/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.2/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```python @@ -191,7 +197,7 @@ for i in range(1, 4): order.store() ``` -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. +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. 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`. ```python @@ -224,7 +230,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.2/developing/getting-started/ruby/querying.md b/content/riak/kv/2.0.2/developing/getting-started/ruby/querying.md index e5346a81c5..9c6e2e922f 100644 --- a/content/riak/kv/2.0.2/developing/getting-started/ruby/querying.md +++ b/content/riak/kv/2.0.2/developing/getting-started/ruby/querying.md @@ -149,7 +149,7 @@ os.data = order_summary os.store ``` - 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. + 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. ```ruby shared_key = '1' @@ -190,6 +190,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.2/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.2/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.2/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.2/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```ruby @@ -206,7 +212,7 @@ If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL ind end ``` -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. +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. 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`. ```ruby @@ -240,7 +246,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.4/developing/getting-started/csharp/querying.md b/content/riak/kv/2.0.4/developing/getting-started/csharp/querying.md index e9dbe53fbf..7e4f4d7f51 100644 --- a/content/riak/kv/2.0.4/developing/getting-started/csharp/querying.md +++ b/content/riak/kv/2.0.4/developing/getting-started/csharp/querying.md @@ -124,6 +124,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.4/developing/getting-started/erlang/querying.md b/content/riak/kv/2.0.4/developing/getting-started/erlang/querying.md index 1eb4d5e43b..aa0959f8a4 100644 --- a/content/riak/kv/2.0.4/developing/getting-started/erlang/querying.md +++ b/content/riak/kv/2.0.4/developing/getting-started/erlang/querying.md @@ -214,6 +214,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.4/developing/getting-started/golang/querying.md b/content/riak/kv/2.0.4/developing/getting-started/golang/querying.md index e0531ab242..91002b5ba9 100644 --- a/content/riak/kv/2.0.4/developing/getting-started/golang/querying.md +++ b/content/riak/kv/2.0.4/developing/getting-started/golang/querying.md @@ -18,7 +18,7 @@ aliases: ## Go Version Setup -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. +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. >A Quick Note on Querying and Schemas: > @@ -340,7 +340,7 @@ func createOrderSummary(customerId string, orders []*Order) *OrderSummary { } ``` -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. +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. ```golang 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 ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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: ```golang @@ -496,7 +502,7 @@ wg.Wait() close(doneChan) ``` -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. +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. 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`: @@ -564,7 +570,7 @@ Easy! We used 2i's range feature to search for a range of values, and demonstra So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys. * You can search for specific values or a range of values. * Riak will return a list of keys that match the index query. diff --git a/content/riak/kv/2.0.4/developing/getting-started/java/querying.md b/content/riak/kv/2.0.4/developing/getting-started/java/querying.md index dc5f975ee0..14c1ed66a5 100644 --- a/content/riak/kv/2.0.4/developing/getting-started/java/querying.md +++ b/content/riak/kv/2.0.4/developing/getting-started/java/querying.md @@ -25,7 +25,7 @@ branch](https://github.com/basho/taste-of-riak/archive/master.zip). The code for this chapter is in `/java/Ch02-Schemas-and-Indexes`. You may import this code into your favorite editor, or just run it from the command line using the commands in `BuildAndRun.sh` if you are running -on a *nix OS. +on a *nix* OS. ## A Quick Note on Querying and Schemas @@ -193,6 +193,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.4/developing/getting-started/nodejs/querying.md b/content/riak/kv/2.0.4/developing/getting-started/nodejs/querying.md index 175221bc06..917dd157ed 100644 --- a/content/riak/kv/2.0.4/developing/getting-started/nodejs/querying.md +++ b/content/riak/kv/2.0.4/developing/getting-started/nodejs/querying.md @@ -86,6 +86,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.4/developing/getting-started/php/querying.md b/content/riak/kv/2.0.4/developing/getting-started/php/querying.md index 1196a3cac9..cf57bf30c4 100644 --- a/content/riak/kv/2.0.4/developing/getting-started/php/querying.md +++ b/content/riak/kv/2.0.4/developing/getting-started/php/querying.md @@ -94,7 +94,7 @@ class Item class OrderSummary { - public function __construct() + public function __construct() { $this->summaries = array(); } @@ -104,7 +104,7 @@ class OrderSummary class OrderSummaryItem { - public function __construct(Order $order) + public function __construct(Order $order) { $this->orderId = $order->orderId; $this->total = $order->total; @@ -141,8 +141,8 @@ $order1->items = [ 15.99 ), new Item( - 'PEG10BBF2PP', - 'eTablet Pro; 24GB; Grey', + 'PEG10BBF2PP', + 'eTablet Pro; 24GB; Grey', 399.99 ) ]; @@ -231,7 +231,7 @@ $storeSummary = (new Command\Builder\StoreObject($riak)) $storeSummary->execute(); ``` - 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. + 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. ```php // 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 ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```php @@ -323,7 +329,7 @@ unset($key); ``` -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. +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. 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`. ```php @@ -354,7 +360,7 @@ Jane processed orders 1 and 3. We used an "integer" index to reference Jane's i 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`. ```php -// Query for orders where the OrderDate bin index is +// Query for orders where the OrderDate bin index is // between 2013-10-01 and 2013-10-31 $fetchOctoberOrders = (new Command\Builder\QueryIndex($riak)) ->inBucket($ordersBucket) @@ -392,7 +398,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys (and terms if needed) that match the index query diff --git a/content/riak/kv/2.0.4/developing/getting-started/python/querying.md b/content/riak/kv/2.0.4/developing/getting-started/python/querying.md index ead86999e3..a7c3997223 100644 --- a/content/riak/kv/2.0.4/developing/getting-started/python/querying.md +++ b/content/riak/kv/2.0.4/developing/getting-started/python/querying.md @@ -150,7 +150,7 @@ os = order_summary_bucket.new(str(order_summary['customer_id']), os.store() ``` - 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. + 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. ```python customer = customer_bucket.get('1').data @@ -162,15 +162,15 @@ Which returns our amalgamated objects: ```python { - u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', - u'created_date': u'2013-10-01 14:30:26', - 'order_summary': { + u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', + u'created_date': u'2013-10-01 14:30:26', + 'order_summary': { u'customer_id': 1, u'summaries': [ - {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, - {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, + {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, + {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, {u'order_id': 3, u'order_date': u'2013-11-03 17:45:28', u'total': 74.98} - ]}, - u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', + ]}, + u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', u'customer_id': 1 } ``` @@ -180,6 +180,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```python @@ -191,7 +197,7 @@ for i in range(1, 4): order.store() ``` -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. +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. 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`. ```python @@ -224,7 +230,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.4/developing/getting-started/ruby/querying.md b/content/riak/kv/2.0.4/developing/getting-started/ruby/querying.md index f4154f272d..8b458a40b9 100644 --- a/content/riak/kv/2.0.4/developing/getting-started/ruby/querying.md +++ b/content/riak/kv/2.0.4/developing/getting-started/ruby/querying.md @@ -149,7 +149,7 @@ os.data = order_summary os.store ``` - 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. + 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. ```ruby shared_key = '1' @@ -190,6 +190,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```ruby @@ -206,7 +212,7 @@ If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL ind end ``` -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. +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. 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`. ```ruby @@ -240,7 +246,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.5/developing/getting-started/csharp/querying.md b/content/riak/kv/2.0.5/developing/getting-started/csharp/querying.md index a466c9b55a..db9e8d4a15 100644 --- a/content/riak/kv/2.0.5/developing/getting-started/csharp/querying.md +++ b/content/riak/kv/2.0.5/developing/getting-started/csharp/querying.md @@ -124,6 +124,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.5/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.5/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.5/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.5/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.5/developing/getting-started/erlang/querying.md b/content/riak/kv/2.0.5/developing/getting-started/erlang/querying.md index a263e88830..59161518c4 100644 --- a/content/riak/kv/2.0.5/developing/getting-started/erlang/querying.md +++ b/content/riak/kv/2.0.5/developing/getting-started/erlang/querying.md @@ -214,6 +214,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.5/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.5/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.5/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.5/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.5/developing/getting-started/golang/querying.md b/content/riak/kv/2.0.5/developing/getting-started/golang/querying.md index 6c1b1ad8bc..56be89b6fe 100644 --- a/content/riak/kv/2.0.5/developing/getting-started/golang/querying.md +++ b/content/riak/kv/2.0.5/developing/getting-started/golang/querying.md @@ -18,7 +18,7 @@ aliases: ## Go Version Setup -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. +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. >A Quick Note on Querying and Schemas: > @@ -340,7 +340,7 @@ func createOrderSummary(customerId string, orders []*Order) *OrderSummary { } ``` -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. +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. ```golang 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 ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.5/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.5/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.5/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.5/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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: ```golang @@ -496,7 +502,7 @@ wg.Wait() close(doneChan) ``` -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. +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. 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`: @@ -564,7 +570,7 @@ Easy! We used 2i's range feature to search for a range of values, and demonstra So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys. * You can search for specific values or a range of values. * Riak will return a list of keys that match the index query. diff --git a/content/riak/kv/2.0.5/developing/getting-started/java/querying.md b/content/riak/kv/2.0.5/developing/getting-started/java/querying.md index 36f975988b..19f24c8c30 100644 --- a/content/riak/kv/2.0.5/developing/getting-started/java/querying.md +++ b/content/riak/kv/2.0.5/developing/getting-started/java/querying.md @@ -25,7 +25,7 @@ branch](https://github.com/basho/taste-of-riak/archive/master.zip). The code for this chapter is in `/java/Ch02-Schemas-and-Indexes`. You may import this code into your favorite editor, or just run it from the command line using the commands in `BuildAndRun.sh` if you are running -on a *nix OS. +on a *nix* OS. ## A Quick Note on Querying and Schemas @@ -193,6 +193,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.5/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.5/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.5/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.5/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.5/developing/getting-started/nodejs/querying.md b/content/riak/kv/2.0.5/developing/getting-started/nodejs/querying.md index a0062c41b2..bec2777dc8 100644 --- a/content/riak/kv/2.0.5/developing/getting-started/nodejs/querying.md +++ b/content/riak/kv/2.0.5/developing/getting-started/nodejs/querying.md @@ -86,6 +86,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.5/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.5/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.5/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.5/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.5/developing/getting-started/php/querying.md b/content/riak/kv/2.0.5/developing/getting-started/php/querying.md index f1936b6139..15ec3e033c 100644 --- a/content/riak/kv/2.0.5/developing/getting-started/php/querying.md +++ b/content/riak/kv/2.0.5/developing/getting-started/php/querying.md @@ -94,7 +94,7 @@ class Item class OrderSummary { - public function __construct() + public function __construct() { $this->summaries = array(); } @@ -104,7 +104,7 @@ class OrderSummary class OrderSummaryItem { - public function __construct(Order $order) + public function __construct(Order $order) { $this->orderId = $order->orderId; $this->total = $order->total; @@ -141,8 +141,8 @@ $order1->items = [ 15.99 ), new Item( - 'PEG10BBF2PP', - 'eTablet Pro; 24GB; Grey', + 'PEG10BBF2PP', + 'eTablet Pro; 24GB; Grey', 399.99 ) ]; @@ -231,7 +231,7 @@ $storeSummary = (new Command\Builder\StoreObject($riak)) $storeSummary->execute(); ``` - 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. + 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. ```php // 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 ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.5/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.5/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.5/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.5/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```php @@ -323,7 +329,7 @@ unset($key); ``` -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. +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. 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`. ```php @@ -354,7 +360,7 @@ Jane processed orders 1 and 3. We used an "integer" index to reference Jane's i 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`. ```php -// Query for orders where the OrderDate bin index is +// Query for orders where the OrderDate bin index is // between 2013-10-01 and 2013-10-31 $fetchOctoberOrders = (new Command\Builder\QueryIndex($riak)) ->inBucket($ordersBucket) @@ -392,7 +398,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys (and terms if needed) that match the index query diff --git a/content/riak/kv/2.0.5/developing/getting-started/python/querying.md b/content/riak/kv/2.0.5/developing/getting-started/python/querying.md index be573bd052..69d651f4be 100644 --- a/content/riak/kv/2.0.5/developing/getting-started/python/querying.md +++ b/content/riak/kv/2.0.5/developing/getting-started/python/querying.md @@ -150,7 +150,7 @@ os = order_summary_bucket.new(str(order_summary['customer_id']), os.store() ``` - 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. + 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. ```python customer = customer_bucket.get('1').data @@ -162,15 +162,15 @@ Which returns our amalgamated objects: ```python { - u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', - u'created_date': u'2013-10-01 14:30:26', - 'order_summary': { + u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', + u'created_date': u'2013-10-01 14:30:26', + 'order_summary': { u'customer_id': 1, u'summaries': [ - {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, - {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, + {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, + {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, {u'order_id': 3, u'order_date': u'2013-11-03 17:45:28', u'total': 74.98} - ]}, - u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', + ]}, + u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', u'customer_id': 1 } ``` @@ -180,6 +180,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.5/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.5/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.5/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.5/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```python @@ -191,7 +197,7 @@ for i in range(1, 4): order.store() ``` -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. +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. 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`. ```python @@ -224,7 +230,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.5/developing/getting-started/ruby/querying.md b/content/riak/kv/2.0.5/developing/getting-started/ruby/querying.md index 155d1596f7..7e5d03ebb3 100644 --- a/content/riak/kv/2.0.5/developing/getting-started/ruby/querying.md +++ b/content/riak/kv/2.0.5/developing/getting-started/ruby/querying.md @@ -149,7 +149,7 @@ os.data = order_summary os.store ``` - 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. + 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. ```ruby shared_key = '1' @@ -190,6 +190,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.5/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.5/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.5/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.5/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```ruby @@ -206,7 +212,7 @@ If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL ind end ``` -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. +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. 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`. ```ruby @@ -240,7 +246,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.6/developing/getting-started/csharp/querying.md b/content/riak/kv/2.0.6/developing/getting-started/csharp/querying.md index d3b87f5907..28a59a9513 100644 --- a/content/riak/kv/2.0.6/developing/getting-started/csharp/querying.md +++ b/content/riak/kv/2.0.6/developing/getting-started/csharp/querying.md @@ -124,6 +124,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.6/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.6/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.6/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.6/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.6/developing/getting-started/erlang/querying.md b/content/riak/kv/2.0.6/developing/getting-started/erlang/querying.md index 1f093d813a..cd4bca3a83 100644 --- a/content/riak/kv/2.0.6/developing/getting-started/erlang/querying.md +++ b/content/riak/kv/2.0.6/developing/getting-started/erlang/querying.md @@ -214,6 +214,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.6/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.6/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.6/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.6/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.6/developing/getting-started/golang/querying.md b/content/riak/kv/2.0.6/developing/getting-started/golang/querying.md index b23d611cb1..1010d94d14 100644 --- a/content/riak/kv/2.0.6/developing/getting-started/golang/querying.md +++ b/content/riak/kv/2.0.6/developing/getting-started/golang/querying.md @@ -18,7 +18,7 @@ aliases: ## Go Version Setup -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. +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. >A Quick Note on Querying and Schemas: > @@ -340,7 +340,7 @@ func createOrderSummary(customerId string, orders []*Order) *OrderSummary { } ``` -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. +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. ```golang 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 ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.6/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.6/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.6/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.6/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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: ```golang @@ -496,7 +502,7 @@ wg.Wait() close(doneChan) ``` -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. +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. 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`: @@ -564,7 +570,7 @@ Easy! We used 2i's range feature to search for a range of values, and demonstra So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys. * You can search for specific values or a range of values. * Riak will return a list of keys that match the index query. diff --git a/content/riak/kv/2.0.6/developing/getting-started/java/querying.md b/content/riak/kv/2.0.6/developing/getting-started/java/querying.md index ea7594a8b2..25a032c9af 100644 --- a/content/riak/kv/2.0.6/developing/getting-started/java/querying.md +++ b/content/riak/kv/2.0.6/developing/getting-started/java/querying.md @@ -25,7 +25,7 @@ branch](https://github.com/basho/taste-of-riak/archive/master.zip). The code for this chapter is in `/java/Ch02-Schemas-and-Indexes`. You may import this code into your favorite editor, or just run it from the command line using the commands in `BuildAndRun.sh` if you are running -on a *nix OS. +on a *nix* OS. ## A Quick Note on Querying and Schemas @@ -193,6 +193,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.6/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.6/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.6/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.6/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.6/developing/getting-started/nodejs/querying.md b/content/riak/kv/2.0.6/developing/getting-started/nodejs/querying.md index 9f4154b781..b7ca26120f 100644 --- a/content/riak/kv/2.0.6/developing/getting-started/nodejs/querying.md +++ b/content/riak/kv/2.0.6/developing/getting-started/nodejs/querying.md @@ -86,6 +86,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.6/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.6/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.6/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.6/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.6/developing/getting-started/php/querying.md b/content/riak/kv/2.0.6/developing/getting-started/php/querying.md index 11417eeab8..59484505eb 100644 --- a/content/riak/kv/2.0.6/developing/getting-started/php/querying.md +++ b/content/riak/kv/2.0.6/developing/getting-started/php/querying.md @@ -94,7 +94,7 @@ class Item class OrderSummary { - public function __construct() + public function __construct() { $this->summaries = array(); } @@ -104,7 +104,7 @@ class OrderSummary class OrderSummaryItem { - public function __construct(Order $order) + public function __construct(Order $order) { $this->orderId = $order->orderId; $this->total = $order->total; @@ -141,8 +141,8 @@ $order1->items = [ 15.99 ), new Item( - 'PEG10BBF2PP', - 'eTablet Pro; 24GB; Grey', + 'PEG10BBF2PP', + 'eTablet Pro; 24GB; Grey', 399.99 ) ]; @@ -231,7 +231,7 @@ $storeSummary = (new Command\Builder\StoreObject($riak)) $storeSummary->execute(); ``` - 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. + 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. ```php // 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 ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.6/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.6/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.6/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.6/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```php @@ -323,7 +329,7 @@ unset($key); ``` -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. +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. 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`. ```php @@ -354,7 +360,7 @@ Jane processed orders 1 and 3. We used an "integer" index to reference Jane's i 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`. ```php -// Query for orders where the OrderDate bin index is +// Query for orders where the OrderDate bin index is // between 2013-10-01 and 2013-10-31 $fetchOctoberOrders = (new Command\Builder\QueryIndex($riak)) ->inBucket($ordersBucket) @@ -392,7 +398,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys (and terms if needed) that match the index query diff --git a/content/riak/kv/2.0.6/developing/getting-started/python/querying.md b/content/riak/kv/2.0.6/developing/getting-started/python/querying.md index 312d1ac838..42c2298137 100644 --- a/content/riak/kv/2.0.6/developing/getting-started/python/querying.md +++ b/content/riak/kv/2.0.6/developing/getting-started/python/querying.md @@ -150,7 +150,7 @@ os = order_summary_bucket.new(str(order_summary['customer_id']), os.store() ``` - 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. + 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. ```python customer = customer_bucket.get('1').data @@ -162,15 +162,15 @@ Which returns our amalgamated objects: ```python { - u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', - u'created_date': u'2013-10-01 14:30:26', - 'order_summary': { + u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', + u'created_date': u'2013-10-01 14:30:26', + 'order_summary': { u'customer_id': 1, u'summaries': [ - {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, - {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, + {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, + {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, {u'order_id': 3, u'order_date': u'2013-11-03 17:45:28', u'total': 74.98} - ]}, - u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', + ]}, + u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', u'customer_id': 1 } ``` @@ -180,6 +180,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.6/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.6/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.6/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.6/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```python @@ -191,7 +197,7 @@ for i in range(1, 4): order.store() ``` -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. +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. 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`. ```python @@ -224,7 +230,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.6/developing/getting-started/ruby/querying.md b/content/riak/kv/2.0.6/developing/getting-started/ruby/querying.md index 8c810ba2be..fac4e6d2db 100644 --- a/content/riak/kv/2.0.6/developing/getting-started/ruby/querying.md +++ b/content/riak/kv/2.0.6/developing/getting-started/ruby/querying.md @@ -149,7 +149,7 @@ os.data = order_summary os.store ``` - 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. + 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. ```ruby shared_key = '1' @@ -190,6 +190,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.6/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.6/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.6/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.6/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```ruby @@ -206,7 +212,7 @@ If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL ind end ``` -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. +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. 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`. ```ruby @@ -240,7 +246,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.7/developing/getting-started/csharp/querying.md b/content/riak/kv/2.0.7/developing/getting-started/csharp/querying.md index 7c90ed2b51..b35f784edf 100644 --- a/content/riak/kv/2.0.7/developing/getting-started/csharp/querying.md +++ b/content/riak/kv/2.0.7/developing/getting-started/csharp/querying.md @@ -124,6 +124,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.7/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.7/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.7/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.7/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.7/developing/getting-started/erlang/querying.md b/content/riak/kv/2.0.7/developing/getting-started/erlang/querying.md index cb6ef54b10..52e6efecba 100644 --- a/content/riak/kv/2.0.7/developing/getting-started/erlang/querying.md +++ b/content/riak/kv/2.0.7/developing/getting-started/erlang/querying.md @@ -214,6 +214,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.7/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.7/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.7/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.7/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.7/developing/getting-started/golang/querying.md b/content/riak/kv/2.0.7/developing/getting-started/golang/querying.md index 2524c45907..c6d96881e2 100644 --- a/content/riak/kv/2.0.7/developing/getting-started/golang/querying.md +++ b/content/riak/kv/2.0.7/developing/getting-started/golang/querying.md @@ -18,7 +18,7 @@ aliases: ## Go Version Setup -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. +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. >A Quick Note on Querying and Schemas: > @@ -340,7 +340,7 @@ func createOrderSummary(customerId string, orders []*Order) *OrderSummary { } ``` -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. +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. ```golang 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 ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.7/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.7/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.7/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.7/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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: ```golang @@ -496,7 +502,7 @@ wg.Wait() close(doneChan) ``` -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. +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. 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`: @@ -564,7 +570,7 @@ Easy! We used 2i's range feature to search for a range of values, and demonstra So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys. * You can search for specific values or a range of values. * Riak will return a list of keys that match the index query. diff --git a/content/riak/kv/2.0.7/developing/getting-started/java/querying.md b/content/riak/kv/2.0.7/developing/getting-started/java/querying.md index fda0e405ef..b4764ed58f 100644 --- a/content/riak/kv/2.0.7/developing/getting-started/java/querying.md +++ b/content/riak/kv/2.0.7/developing/getting-started/java/querying.md @@ -25,7 +25,7 @@ branch](https://github.com/basho/taste-of-riak/archive/master.zip). The code for this chapter is in `/java/Ch02-Schemas-and-Indexes`. You may import this code into your favorite editor, or just run it from the command line using the commands in `BuildAndRun.sh` if you are running -on a *nix OS. +on a *nix* OS. ## A Quick Note on Querying and Schemas @@ -193,6 +193,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.7/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.7/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.7/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.7/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.7/developing/getting-started/nodejs/querying.md b/content/riak/kv/2.0.7/developing/getting-started/nodejs/querying.md index 66cf39c229..e9af4cea2c 100644 --- a/content/riak/kv/2.0.7/developing/getting-started/nodejs/querying.md +++ b/content/riak/kv/2.0.7/developing/getting-started/nodejs/querying.md @@ -86,6 +86,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.7/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.7/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.7/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.7/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.0.7/developing/getting-started/php/querying.md b/content/riak/kv/2.0.7/developing/getting-started/php/querying.md index 06460645f7..22e3d1347a 100644 --- a/content/riak/kv/2.0.7/developing/getting-started/php/querying.md +++ b/content/riak/kv/2.0.7/developing/getting-started/php/querying.md @@ -94,7 +94,7 @@ class Item class OrderSummary { - public function __construct() + public function __construct() { $this->summaries = array(); } @@ -104,7 +104,7 @@ class OrderSummary class OrderSummaryItem { - public function __construct(Order $order) + public function __construct(Order $order) { $this->orderId = $order->orderId; $this->total = $order->total; @@ -141,8 +141,8 @@ $order1->items = [ 15.99 ), new Item( - 'PEG10BBF2PP', - 'eTablet Pro; 24GB; Grey', + 'PEG10BBF2PP', + 'eTablet Pro; 24GB; Grey', 399.99 ) ]; @@ -231,7 +231,7 @@ $storeSummary = (new Command\Builder\StoreObject($riak)) $storeSummary->execute(); ``` - 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. + 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. ```php // 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 ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.7/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.7/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.7/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.7/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```php @@ -323,7 +329,7 @@ unset($key); ``` -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. +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. 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`. ```php @@ -354,7 +360,7 @@ Jane processed orders 1 and 3. We used an "integer" index to reference Jane's i 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`. ```php -// Query for orders where the OrderDate bin index is +// Query for orders where the OrderDate bin index is // between 2013-10-01 and 2013-10-31 $fetchOctoberOrders = (new Command\Builder\QueryIndex($riak)) ->inBucket($ordersBucket) @@ -392,7 +398,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys (and terms if needed) that match the index query diff --git a/content/riak/kv/2.0.7/developing/getting-started/python/querying.md b/content/riak/kv/2.0.7/developing/getting-started/python/querying.md index 7a32be2db5..0700ba4e2a 100644 --- a/content/riak/kv/2.0.7/developing/getting-started/python/querying.md +++ b/content/riak/kv/2.0.7/developing/getting-started/python/querying.md @@ -150,7 +150,7 @@ os = order_summary_bucket.new(str(order_summary['customer_id']), os.store() ``` - 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. + 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. ```python customer = customer_bucket.get('1').data @@ -162,15 +162,15 @@ Which returns our amalgamated objects: ```python { - u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', - u'created_date': u'2013-10-01 14:30:26', - 'order_summary': { + u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', + u'created_date': u'2013-10-01 14:30:26', + 'order_summary': { u'customer_id': 1, u'summaries': [ - {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, - {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, + {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, + {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, {u'order_id': 3, u'order_date': u'2013-11-03 17:45:28', u'total': 74.98} - ]}, - u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', + ]}, + u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', u'customer_id': 1 } ``` @@ -180,6 +180,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.7/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.7/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.7/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.7/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```python @@ -191,7 +197,7 @@ for i in range(1, 4): order.store() ``` -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. +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. 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`. ```python @@ -224,7 +230,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.0.7/developing/getting-started/ruby/querying.md b/content/riak/kv/2.0.7/developing/getting-started/ruby/querying.md index 4e496ab298..c71abcf42f 100644 --- a/content/riak/kv/2.0.7/developing/getting-started/ruby/querying.md +++ b/content/riak/kv/2.0.7/developing/getting-started/ruby/querying.md @@ -149,7 +149,7 @@ os.data = order_summary os.store ``` - 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. + 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. ```ruby shared_key = '1' @@ -190,6 +190,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.0.7/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.0.7/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.0.7/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.0.7/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```ruby @@ -206,7 +212,7 @@ If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL ind end ``` -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. +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. 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`. ```ruby @@ -240,7 +246,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.1.1/developing/getting-started/csharp/querying.md b/content/riak/kv/2.1.1/developing/getting-started/csharp/querying.md index d457083178..5b71420a93 100644 --- a/content/riak/kv/2.1.1/developing/getting-started/csharp/querying.md +++ b/content/riak/kv/2.1.1/developing/getting-started/csharp/querying.md @@ -124,6 +124,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.1/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.1/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.1/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.1.1/developing/getting-started/erlang/querying.md b/content/riak/kv/2.1.1/developing/getting-started/erlang/querying.md index 7cc6e11d3c..ce213ec3e6 100644 --- a/content/riak/kv/2.1.1/developing/getting-started/erlang/querying.md +++ b/content/riak/kv/2.1.1/developing/getting-started/erlang/querying.md @@ -214,6 +214,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.1/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.1/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.1/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.1.1/developing/getting-started/golang/querying.md b/content/riak/kv/2.1.1/developing/getting-started/golang/querying.md index e07a45735b..acf2943cdf 100644 --- a/content/riak/kv/2.1.1/developing/getting-started/golang/querying.md +++ b/content/riak/kv/2.1.1/developing/getting-started/golang/querying.md @@ -18,7 +18,7 @@ aliases: ## Go Version Setup -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. +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. >A Quick Note on Querying and Schemas: > @@ -340,7 +340,7 @@ func createOrderSummary(customerId string, orders []*Order) *OrderSummary { } ``` -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. +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. ```golang 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 ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.1/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.1/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.1/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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: ```golang @@ -496,7 +502,7 @@ wg.Wait() close(doneChan) ``` -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. +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. 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`: @@ -564,7 +570,7 @@ Easy! We used 2i's range feature to search for a range of values, and demonstra So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys. * You can search for specific values or a range of values. * Riak will return a list of keys that match the index query. diff --git a/content/riak/kv/2.1.1/developing/getting-started/java/querying.md b/content/riak/kv/2.1.1/developing/getting-started/java/querying.md index 03a5e65977..16a861999c 100644 --- a/content/riak/kv/2.1.1/developing/getting-started/java/querying.md +++ b/content/riak/kv/2.1.1/developing/getting-started/java/querying.md @@ -25,7 +25,7 @@ branch](https://github.com/basho/taste-of-riak/archive/master.zip). The code for this chapter is in `/java/Ch02-Schemas-and-Indexes`. You may import this code into your favorite editor, or just run it from the command line using the commands in `BuildAndRun.sh` if you are running -on a *nix OS. +on a *nix* OS. ## A Quick Note on Querying and Schemas @@ -193,6 +193,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.1/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.1/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.1/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.1.1/developing/getting-started/nodejs/querying.md b/content/riak/kv/2.1.1/developing/getting-started/nodejs/querying.md index bbf0614949..fcfcada91a 100644 --- a/content/riak/kv/2.1.1/developing/getting-started/nodejs/querying.md +++ b/content/riak/kv/2.1.1/developing/getting-started/nodejs/querying.md @@ -86,6 +86,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.1/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.1/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.1/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.1.1/developing/getting-started/php/querying.md b/content/riak/kv/2.1.1/developing/getting-started/php/querying.md index d916369ae0..64a28e15f7 100644 --- a/content/riak/kv/2.1.1/developing/getting-started/php/querying.md +++ b/content/riak/kv/2.1.1/developing/getting-started/php/querying.md @@ -94,7 +94,7 @@ class Item class OrderSummary { - public function __construct() + public function __construct() { $this->summaries = array(); } @@ -104,7 +104,7 @@ class OrderSummary class OrderSummaryItem { - public function __construct(Order $order) + public function __construct(Order $order) { $this->orderId = $order->orderId; $this->total = $order->total; @@ -141,8 +141,8 @@ $order1->items = [ 15.99 ), new Item( - 'PEG10BBF2PP', - 'eTablet Pro; 24GB; Grey', + 'PEG10BBF2PP', + 'eTablet Pro; 24GB; Grey', 399.99 ) ]; @@ -231,7 +231,7 @@ $storeSummary = (new Command\Builder\StoreObject($riak)) $storeSummary->execute(); ``` - 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. + 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. ```php // 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 ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.1/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.1/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.1/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```php @@ -323,7 +329,7 @@ unset($key); ``` -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. +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. 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`. ```php @@ -354,7 +360,7 @@ Jane processed orders 1 and 3. We used an "integer" index to reference Jane's i 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`. ```php -// Query for orders where the OrderDate bin index is +// Query for orders where the OrderDate bin index is // between 2013-10-01 and 2013-10-31 $fetchOctoberOrders = (new Command\Builder\QueryIndex($riak)) ->inBucket($ordersBucket) @@ -392,7 +398,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys (and terms if needed) that match the index query diff --git a/content/riak/kv/2.1.1/developing/getting-started/python/querying.md b/content/riak/kv/2.1.1/developing/getting-started/python/querying.md index ac53dcad2e..f1b32368e2 100644 --- a/content/riak/kv/2.1.1/developing/getting-started/python/querying.md +++ b/content/riak/kv/2.1.1/developing/getting-started/python/querying.md @@ -150,7 +150,7 @@ os = order_summary_bucket.new(str(order_summary['customer_id']), os.store() ``` - 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. + 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. ```python customer = customer_bucket.get('1').data @@ -162,15 +162,15 @@ Which returns our amalgamated objects: ```python { - u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', - u'created_date': u'2013-10-01 14:30:26', - 'order_summary': { + u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', + u'created_date': u'2013-10-01 14:30:26', + 'order_summary': { u'customer_id': 1, u'summaries': [ - {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, - {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, + {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, + {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, {u'order_id': 3, u'order_date': u'2013-11-03 17:45:28', u'total': 74.98} - ]}, - u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', + ]}, + u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', u'customer_id': 1 } ``` @@ -180,6 +180,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.1/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.1/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.1/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```python @@ -191,7 +197,7 @@ for i in range(1, 4): order.store() ``` -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. +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. 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`. ```python @@ -224,7 +230,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.1.1/developing/getting-started/ruby/querying.md b/content/riak/kv/2.1.1/developing/getting-started/ruby/querying.md index 943a8475f2..a5a7ebf7e5 100644 --- a/content/riak/kv/2.1.1/developing/getting-started/ruby/querying.md +++ b/content/riak/kv/2.1.1/developing/getting-started/ruby/querying.md @@ -149,7 +149,7 @@ os.data = order_summary os.store ``` - 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. + 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. ```ruby shared_key = '1' @@ -190,6 +190,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.1/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.1/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.1/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.1/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```ruby @@ -206,7 +212,7 @@ If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL ind end ``` -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. +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. 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`. ```ruby @@ -240,7 +246,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.1.3/developing/getting-started/csharp/querying.md b/content/riak/kv/2.1.3/developing/getting-started/csharp/querying.md index 3ec3105a5b..26cf7fea2b 100644 --- a/content/riak/kv/2.1.3/developing/getting-started/csharp/querying.md +++ b/content/riak/kv/2.1.3/developing/getting-started/csharp/querying.md @@ -124,6 +124,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.3/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.3/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.3/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.3/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.1.3/developing/getting-started/erlang/querying.md b/content/riak/kv/2.1.3/developing/getting-started/erlang/querying.md index 476e0fb600..dcde354c2b 100644 --- a/content/riak/kv/2.1.3/developing/getting-started/erlang/querying.md +++ b/content/riak/kv/2.1.3/developing/getting-started/erlang/querying.md @@ -214,6 +214,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.3/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.3/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.3/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.3/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.1.3/developing/getting-started/golang/querying.md b/content/riak/kv/2.1.3/developing/getting-started/golang/querying.md index 116e0aa149..7a196bb431 100644 --- a/content/riak/kv/2.1.3/developing/getting-started/golang/querying.md +++ b/content/riak/kv/2.1.3/developing/getting-started/golang/querying.md @@ -18,7 +18,7 @@ aliases: ## Go Version Setup -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. +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. >A Quick Note on Querying and Schemas: > @@ -340,7 +340,7 @@ func createOrderSummary(customerId string, orders []*Order) *OrderSummary { } ``` -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. +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. ```golang 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 ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.3/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.3/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.3/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.3/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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: ```golang @@ -496,7 +502,7 @@ wg.Wait() close(doneChan) ``` -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. +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. 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`: @@ -564,7 +570,7 @@ Easy! We used 2i's range feature to search for a range of values, and demonstra So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys. * You can search for specific values or a range of values. * Riak will return a list of keys that match the index query. diff --git a/content/riak/kv/2.1.3/developing/getting-started/java/querying.md b/content/riak/kv/2.1.3/developing/getting-started/java/querying.md index e2db2c09c1..28a57a3ccd 100644 --- a/content/riak/kv/2.1.3/developing/getting-started/java/querying.md +++ b/content/riak/kv/2.1.3/developing/getting-started/java/querying.md @@ -25,7 +25,7 @@ branch](https://github.com/basho/taste-of-riak/archive/master.zip). The code for this chapter is in `/java/Ch02-Schemas-and-Indexes`. You may import this code into your favorite editor, or just run it from the command line using the commands in `BuildAndRun.sh` if you are running -on a *nix OS. +on a *nix* OS. ## A Quick Note on Querying and Schemas @@ -193,6 +193,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.3/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.3/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.3/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.3/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.1.3/developing/getting-started/nodejs/querying.md b/content/riak/kv/2.1.3/developing/getting-started/nodejs/querying.md index 5bcc2ec971..f88789a525 100644 --- a/content/riak/kv/2.1.3/developing/getting-started/nodejs/querying.md +++ b/content/riak/kv/2.1.3/developing/getting-started/nodejs/querying.md @@ -86,6 +86,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.3/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.3/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.3/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.3/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.1.3/developing/getting-started/php/querying.md b/content/riak/kv/2.1.3/developing/getting-started/php/querying.md index 5eb99e81eb..99430740e2 100644 --- a/content/riak/kv/2.1.3/developing/getting-started/php/querying.md +++ b/content/riak/kv/2.1.3/developing/getting-started/php/querying.md @@ -94,7 +94,7 @@ class Item class OrderSummary { - public function __construct() + public function __construct() { $this->summaries = array(); } @@ -104,7 +104,7 @@ class OrderSummary class OrderSummaryItem { - public function __construct(Order $order) + public function __construct(Order $order) { $this->orderId = $order->orderId; $this->total = $order->total; @@ -141,8 +141,8 @@ $order1->items = [ 15.99 ), new Item( - 'PEG10BBF2PP', - 'eTablet Pro; 24GB; Grey', + 'PEG10BBF2PP', + 'eTablet Pro; 24GB; Grey', 399.99 ) ]; @@ -231,7 +231,7 @@ $storeSummary = (new Command\Builder\StoreObject($riak)) $storeSummary->execute(); ``` - 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. + 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. ```php // 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 ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.3/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.3/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.3/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.3/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```php @@ -323,7 +329,7 @@ unset($key); ``` -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. +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. 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`. ```php @@ -354,7 +360,7 @@ Jane processed orders 1 and 3. We used an "integer" index to reference Jane's i 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`. ```php -// Query for orders where the OrderDate bin index is +// Query for orders where the OrderDate bin index is // between 2013-10-01 and 2013-10-31 $fetchOctoberOrders = (new Command\Builder\QueryIndex($riak)) ->inBucket($ordersBucket) @@ -392,7 +398,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys (and terms if needed) that match the index query diff --git a/content/riak/kv/2.1.3/developing/getting-started/python/querying.md b/content/riak/kv/2.1.3/developing/getting-started/python/querying.md index 7c94b4db87..0c5e0cf758 100644 --- a/content/riak/kv/2.1.3/developing/getting-started/python/querying.md +++ b/content/riak/kv/2.1.3/developing/getting-started/python/querying.md @@ -150,7 +150,7 @@ os = order_summary_bucket.new(str(order_summary['customer_id']), os.store() ``` - 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. + 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. ```python customer = customer_bucket.get('1').data @@ -162,15 +162,15 @@ Which returns our amalgamated objects: ```python { - u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', - u'created_date': u'2013-10-01 14:30:26', - 'order_summary': { + u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', + u'created_date': u'2013-10-01 14:30:26', + 'order_summary': { u'customer_id': 1, u'summaries': [ - {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, - {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, + {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, + {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, {u'order_id': 3, u'order_date': u'2013-11-03 17:45:28', u'total': 74.98} - ]}, - u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', + ]}, + u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', u'customer_id': 1 } ``` @@ -180,6 +180,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.3/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.3/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.3/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.3/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```python @@ -191,7 +197,7 @@ for i in range(1, 4): order.store() ``` -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. +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. 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`. ```python @@ -224,7 +230,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.1.3/developing/getting-started/ruby/querying.md b/content/riak/kv/2.1.3/developing/getting-started/ruby/querying.md index 578e3dacf3..abaf73bf97 100644 --- a/content/riak/kv/2.1.3/developing/getting-started/ruby/querying.md +++ b/content/riak/kv/2.1.3/developing/getting-started/ruby/querying.md @@ -149,7 +149,7 @@ os.data = order_summary os.store ``` - 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. + 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. ```ruby shared_key = '1' @@ -190,6 +190,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.3/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.3/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.3/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.3/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```ruby @@ -206,7 +212,7 @@ If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL ind end ``` -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. +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. 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`. ```ruby @@ -240,7 +246,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.1.4/developing/getting-started/csharp/querying.md b/content/riak/kv/2.1.4/developing/getting-started/csharp/querying.md index 8d1e3c1326..3fa6c49e7f 100644 --- a/content/riak/kv/2.1.4/developing/getting-started/csharp/querying.md +++ b/content/riak/kv/2.1.4/developing/getting-started/csharp/querying.md @@ -124,6 +124,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.1.4/developing/getting-started/erlang/querying.md b/content/riak/kv/2.1.4/developing/getting-started/erlang/querying.md index 8363bfb94b..1874ef25f0 100644 --- a/content/riak/kv/2.1.4/developing/getting-started/erlang/querying.md +++ b/content/riak/kv/2.1.4/developing/getting-started/erlang/querying.md @@ -214,6 +214,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.1.4/developing/getting-started/golang/querying.md b/content/riak/kv/2.1.4/developing/getting-started/golang/querying.md index 991a43526e..05ce11d200 100644 --- a/content/riak/kv/2.1.4/developing/getting-started/golang/querying.md +++ b/content/riak/kv/2.1.4/developing/getting-started/golang/querying.md @@ -18,7 +18,7 @@ aliases: ## Go Version Setup -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. +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. >A Quick Note on Querying and Schemas: > @@ -340,7 +340,7 @@ func createOrderSummary(customerId string, orders []*Order) *OrderSummary { } ``` -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. +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. ```golang 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 ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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: ```golang @@ -496,7 +502,7 @@ wg.Wait() close(doneChan) ``` -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. +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. 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`: @@ -564,7 +570,7 @@ Easy! We used 2i's range feature to search for a range of values, and demonstra So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys. * You can search for specific values or a range of values. * Riak will return a list of keys that match the index query. diff --git a/content/riak/kv/2.1.4/developing/getting-started/java/querying.md b/content/riak/kv/2.1.4/developing/getting-started/java/querying.md index d9d0efb5be..b5d6d19181 100644 --- a/content/riak/kv/2.1.4/developing/getting-started/java/querying.md +++ b/content/riak/kv/2.1.4/developing/getting-started/java/querying.md @@ -25,7 +25,7 @@ branch](https://github.com/basho/taste-of-riak/archive/master.zip). The code for this chapter is in `/java/Ch02-Schemas-and-Indexes`. You may import this code into your favorite editor, or just run it from the command line using the commands in `BuildAndRun.sh` if you are running -on a *nix OS. +on a *nix* OS. ## A Quick Note on Querying and Schemas @@ -193,6 +193,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.1.4/developing/getting-started/nodejs/querying.md b/content/riak/kv/2.1.4/developing/getting-started/nodejs/querying.md index 1b7c4d3d04..e374aa2bc3 100644 --- a/content/riak/kv/2.1.4/developing/getting-started/nodejs/querying.md +++ b/content/riak/kv/2.1.4/developing/getting-started/nodejs/querying.md @@ -86,6 +86,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.1.4/developing/getting-started/php/querying.md b/content/riak/kv/2.1.4/developing/getting-started/php/querying.md index 97d2e735f4..5eced10f00 100644 --- a/content/riak/kv/2.1.4/developing/getting-started/php/querying.md +++ b/content/riak/kv/2.1.4/developing/getting-started/php/querying.md @@ -94,7 +94,7 @@ class Item class OrderSummary { - public function __construct() + public function __construct() { $this->summaries = array(); } @@ -104,7 +104,7 @@ class OrderSummary class OrderSummaryItem { - public function __construct(Order $order) + public function __construct(Order $order) { $this->orderId = $order->orderId; $this->total = $order->total; @@ -141,8 +141,8 @@ $order1->items = [ 15.99 ), new Item( - 'PEG10BBF2PP', - 'eTablet Pro; 24GB; Grey', + 'PEG10BBF2PP', + 'eTablet Pro; 24GB; Grey', 399.99 ) ]; @@ -231,7 +231,7 @@ $storeSummary = (new Command\Builder\StoreObject($riak)) $storeSummary->execute(); ``` - 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. + 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. ```php // 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 ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```php @@ -323,7 +329,7 @@ unset($key); ``` -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. +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. 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`. ```php @@ -354,7 +360,7 @@ Jane processed orders 1 and 3. We used an "integer" index to reference Jane's i 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`. ```php -// Query for orders where the OrderDate bin index is +// Query for orders where the OrderDate bin index is // between 2013-10-01 and 2013-10-31 $fetchOctoberOrders = (new Command\Builder\QueryIndex($riak)) ->inBucket($ordersBucket) @@ -392,7 +398,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys (and terms if needed) that match the index query diff --git a/content/riak/kv/2.1.4/developing/getting-started/python/querying.md b/content/riak/kv/2.1.4/developing/getting-started/python/querying.md index b9fea9b57c..e01b91a3c1 100644 --- a/content/riak/kv/2.1.4/developing/getting-started/python/querying.md +++ b/content/riak/kv/2.1.4/developing/getting-started/python/querying.md @@ -150,7 +150,7 @@ os = order_summary_bucket.new(str(order_summary['customer_id']), os.store() ``` - 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. + 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. ```python customer = customer_bucket.get('1').data @@ -162,15 +162,15 @@ Which returns our amalgamated objects: ```python { - u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', - u'created_date': u'2013-10-01 14:30:26', - 'order_summary': { + u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', + u'created_date': u'2013-10-01 14:30:26', + 'order_summary': { u'customer_id': 1, u'summaries': [ - {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, - {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, + {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, + {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, {u'order_id': 3, u'order_date': u'2013-11-03 17:45:28', u'total': 74.98} - ]}, - u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', + ]}, + u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', u'customer_id': 1 } ``` @@ -180,6 +180,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```python @@ -191,7 +197,7 @@ for i in range(1, 4): order.store() ``` -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. +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. 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`. ```python @@ -224,7 +230,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.1.4/developing/getting-started/ruby/querying.md b/content/riak/kv/2.1.4/developing/getting-started/ruby/querying.md index b26ff31df8..83c22d66bc 100644 --- a/content/riak/kv/2.1.4/developing/getting-started/ruby/querying.md +++ b/content/riak/kv/2.1.4/developing/getting-started/ruby/querying.md @@ -149,7 +149,7 @@ os.data = order_summary os.store ``` - 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. + 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. ```ruby shared_key = '1' @@ -190,6 +190,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.1.4/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.1.4/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.1.4/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.1.4/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```ruby @@ -206,7 +212,7 @@ If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL ind end ``` -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. +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. 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`. ```ruby @@ -240,7 +246,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.2.0/developing/getting-started/csharp/querying.md b/content/riak/kv/2.2.0/developing/getting-started/csharp/querying.md index 8df70a09d4..1146011c46 100644 --- a/content/riak/kv/2.2.0/developing/getting-started/csharp/querying.md +++ b/content/riak/kv/2.2.0/developing/getting-started/csharp/querying.md @@ -124,6 +124,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.2.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.2.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.2.0/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.2.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.2.0/developing/getting-started/erlang/querying.md b/content/riak/kv/2.2.0/developing/getting-started/erlang/querying.md index 314879c752..027c338347 100644 --- a/content/riak/kv/2.2.0/developing/getting-started/erlang/querying.md +++ b/content/riak/kv/2.2.0/developing/getting-started/erlang/querying.md @@ -214,6 +214,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.2.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.2.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.2.0/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.2.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.2.0/developing/getting-started/golang/querying.md b/content/riak/kv/2.2.0/developing/getting-started/golang/querying.md index 7f7c3c0f8b..9ee0ef717f 100644 --- a/content/riak/kv/2.2.0/developing/getting-started/golang/querying.md +++ b/content/riak/kv/2.2.0/developing/getting-started/golang/querying.md @@ -18,7 +18,7 @@ aliases: ## Go Version Setup -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. +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. >A Quick Note on Querying and Schemas: > @@ -340,7 +340,7 @@ func createOrderSummary(customerId string, orders []*Order) *OrderSummary { } ``` -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. +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. ```golang 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 ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.2.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.2.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.2.0/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.2.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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: ```golang @@ -496,7 +502,7 @@ wg.Wait() close(doneChan) ``` -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. +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. 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`: @@ -564,7 +570,7 @@ Easy! We used 2i's range feature to search for a range of values, and demonstra So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys. * You can search for specific values or a range of values. * Riak will return a list of keys that match the index query. diff --git a/content/riak/kv/2.2.0/developing/getting-started/java/querying.md b/content/riak/kv/2.2.0/developing/getting-started/java/querying.md index de1184a0ba..6fb130d97c 100644 --- a/content/riak/kv/2.2.0/developing/getting-started/java/querying.md +++ b/content/riak/kv/2.2.0/developing/getting-started/java/querying.md @@ -25,7 +25,7 @@ branch](https://github.com/basho/taste-of-riak/archive/master.zip). The code for this chapter is in `/java/Ch02-Schemas-and-Indexes`. You may import this code into your favorite editor, or just run it from the command line using the commands in `BuildAndRun.sh` if you are running -on a *nix OS. +on a *nix* OS. ## A Quick Note on Querying and Schemas @@ -193,6 +193,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.2.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.2.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.2.0/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.2.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.2.0/developing/getting-started/nodejs/querying.md b/content/riak/kv/2.2.0/developing/getting-started/nodejs/querying.md index bb9245b6a2..feec1029b0 100644 --- a/content/riak/kv/2.2.0/developing/getting-started/nodejs/querying.md +++ b/content/riak/kv/2.2.0/developing/getting-started/nodejs/querying.md @@ -86,6 +86,12 @@ intrinsic relationships. ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.2.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.2.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.2.0/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.2.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + If you're coming from an 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 diff --git a/content/riak/kv/2.2.0/developing/getting-started/php/querying.md b/content/riak/kv/2.2.0/developing/getting-started/php/querying.md index aa6778959b..a37f334126 100644 --- a/content/riak/kv/2.2.0/developing/getting-started/php/querying.md +++ b/content/riak/kv/2.2.0/developing/getting-started/php/querying.md @@ -94,7 +94,7 @@ class Item class OrderSummary { - public function __construct() + public function __construct() { $this->summaries = array(); } @@ -104,7 +104,7 @@ class OrderSummary class OrderSummaryItem { - public function __construct(Order $order) + public function __construct(Order $order) { $this->orderId = $order->orderId; $this->total = $order->total; @@ -141,8 +141,8 @@ $order1->items = [ 15.99 ), new Item( - 'PEG10BBF2PP', - 'eTablet Pro; 24GB; Grey', + 'PEG10BBF2PP', + 'eTablet Pro; 24GB; Grey', 399.99 ) ]; @@ -231,7 +231,7 @@ $storeSummary = (new Command\Builder\StoreObject($riak)) $storeSummary->execute(); ``` - 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. + 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. ```php // 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 ## Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.2.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.2.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.2.0/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.2.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```php @@ -323,7 +329,7 @@ unset($key); ``` -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. +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. 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`. ```php @@ -354,7 +360,7 @@ Jane processed orders 1 and 3. We used an "integer" index to reference Jane's i 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`. ```php -// Query for orders where the OrderDate bin index is +// Query for orders where the OrderDate bin index is // between 2013-10-01 and 2013-10-31 $fetchOctoberOrders = (new Command\Builder\QueryIndex($riak)) ->inBucket($ordersBucket) @@ -392,7 +398,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys (and terms if needed) that match the index query diff --git a/content/riak/kv/2.2.0/developing/getting-started/python/querying.md b/content/riak/kv/2.2.0/developing/getting-started/python/querying.md index 7c2b79f692..bedeb1c6ba 100644 --- a/content/riak/kv/2.2.0/developing/getting-started/python/querying.md +++ b/content/riak/kv/2.2.0/developing/getting-started/python/querying.md @@ -150,7 +150,7 @@ os = order_summary_bucket.new(str(order_summary['customer_id']), os.store() ``` - 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. + 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. ```python customer = customer_bucket.get('1').data @@ -162,15 +162,15 @@ Which returns our amalgamated objects: ```python { - u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', - u'created_date': u'2013-10-01 14:30:26', - 'order_summary': { + u'city': u'Columbus', u'name': u'John Smith', u'zip': u'43210', + u'created_date': u'2013-10-01 14:30:26', + 'order_summary': { u'customer_id': 1, u'summaries': [ - {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, - {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, + {u'order_id': 1, u'order_date': u'2013-10-01 14:42:26', u'total': 415.98}, + {u'order_id': 2, u'order_date': u'2013-10-15 16:43:16', u'total': 359.99}, {u'order_id': 3, u'order_date': u'2013-11-03 17:45:28', u'total': 74.98} - ]}, - u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', + ]}, + u'phone': u'+1-614-555-5555', u'state': u'Ohio', u'address': u'123 Main Street', u'customer_id': 1 } ``` @@ -180,6 +180,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.2.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.2.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.2.0/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.2.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```python @@ -191,7 +197,7 @@ for i in range(1, 4): order.store() ``` -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. +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. 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`. ```python @@ -224,7 +230,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query diff --git a/content/riak/kv/2.2.0/developing/getting-started/ruby/querying.md b/content/riak/kv/2.2.0/developing/getting-started/ruby/querying.md index fe72e4ffd5..2a925735cb 100644 --- a/content/riak/kv/2.2.0/developing/getting-started/ruby/querying.md +++ b/content/riak/kv/2.2.0/developing/getting-started/ruby/querying.md @@ -149,7 +149,7 @@ os.data = order_summary os.store ``` - 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. + 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. ```ruby shared_key = '1' @@ -190,6 +190,12 @@ While this pattern is very easy and extremely fast with respect to queries and c ### Secondary Indexes +{{% note %}} +Secondary indexes in Riak KV require a sorted backend: [Memory](/riak/kv/2.2.0/setup/planning/backend/memory) or [LevelDB](/riak/kv/2.2.0/setup/planning/backend/leveldb). [Bitcask](/riak/kv/2.2.0/setup/planning/backend/bitcask) does not support secondary indexes. + +See [Using Secondary Indexes (2i)](/riak/kv/2.2.0/developing/usage/secondary-indexes) for more information on developing with secondary indexes. +{{% /note %}} + 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. ```ruby @@ -206,7 +212,7 @@ If you're coming from a SQL world, Secondary Indexes (2i) are a lot like SQL ind end ``` -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. +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. 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`. ```ruby @@ -240,7 +246,7 @@ Boom, easy-peasy. We used 2i's range feature to search for a range of values, a So to recap: -* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. +* You can use Secondary Indexes to quickly lookup an object based on a secondary id other than the object's key. * Indexes can have either Integer or Binary(String) keys * You can search for specific values, or a range of values * Riak will return a list of keys that match the index query